Warum dialogorientierte KI?
Weil Deine Nutzer nicht nur âeine Antwortâ wollen.
Sondern RĂŒckfragen stellen. Und Kontext haben.
Du brauchst also Chatlogik.
Und zwar steuerbar, nachvollziehbar, eingebettet in Deine Access-Anwendung.
ChatGPT kann das.
Rasa auch â lokal, mit mehr Kontrolle.
Access steuert den Dialog. GPT liefert die Sprache.
Ich zeig Dir, wie Du das baust.
Vergleich: ChatGPT vs. Rasa
System | Vorteil | Nachteil |
---|---|---|
ChatGPT | Schnell einsatzbereit | Wenig Kontrolle, API-Kosten |
Rasa | Lokal, trainierbar, offen | Mehr Initialaufwand |
Tabellenstruktur (Beispiel)
Tabelle | Zweck |
---|---|
tblDialoge | GesprÀchsverlauf |
tblSitzungen | Konversationen pro User |
Kontextlogik mit GPT
ChatGPT braucht alle bisherigen Nachrichten im Prompt.
Du baust also einen Array aus Rollen und Texten.
Schritt 1: GesprÀchsverlauf auslesen
Function BaueChatArray(sitzungID As Long) As String
Dim rs As DAO.Recordset
Dim json As String
Set rs = CurrentDb.OpenRecordset("SELECT Rolle, Nachricht FROM tblDialoge WHERE SitzungID=" & sitzungID & " ORDER BY ID")
json = """messages"":["
Do While Not rs.EOF
json = json & "{""role"":""" & rs!Rolle & """,""content"":""" & Replace(rs!Nachricht, """", "\""") & """},"
rs.MoveNext
Loop
If Right(json, 1) = "," Then json = Left(json, Len(json) - 1)
json = json & "]"
BaueChatArray = json
End Function
Schritt 2: JSON an GPT senden
Function SendeGPTChat(sitzungID As Long) As String
Dim http As Object
Dim apiKey As String
Dim url As String
Dim body As String
apiKey = "DEIN_API_KEY"
url = "https://api.openai.com/v1/chat/completions"
body = "{" & BaueChatArray(sitzungID) & ",""model"":""gpt-4"",""temperature"":0.5}"
Set http = CreateObject("MSXML2.ServerXMLHTTP")
http.Open "POST", url, False
http.setRequestHeader "Content-Type", "application/json"
http.setRequestHeader "Authorization", "Bearer " & apiKey
http.Send body
SendeGPTChat = ExtrahiereGPTAntwort(http.responseText)
End Function
Antwort speichern
Sub SpeichereAntwort(sitzungID As Long, antwort As String)
CurrentDb.Execute "INSERT INTO tblDialoge (SitzungID, Rolle, Nachricht) VALUES (" & _
sitzungID & ", 'assistant', '" & Replace(antwort, "'", "''") & "')"
End Sub
Beispiel: Nachricht senden
Sub SendeUserNachricht(sitzungID As Long, eingabe As String)
CurrentDb.Execute "INSERT INTO tblDialoge (SitzungID, Rolle, Nachricht) VALUES (" & _
sitzungID & ", 'user', '" & Replace(eingabe, "'", "''") & "')"
Dim antwort As String
antwort = SendeGPTChat(sitzungID)
Call SpeichereAntwort(sitzungID, antwort)
MsgBox antwort
End Sub
Rasa als Alternative
Rasa lÀuft lokal mit eigenem Intent-Training.
Per REST erreichbar:
POST http://localhost:5005/webhooks/rest/webhook
Body: { "sender": "Benutzer123", "message": "Wie ist der Lagerbestand?" }
Access-Anbindung:
Function RasaAntwort(senderID As String, nachricht As String) As String
Dim http As Object
Dim jsonRequest As String
jsonRequest = "{""sender"":""" & senderID & """,""message"":""" & Replace(nachricht, """", "\""") & """}"
Set http = CreateObject("MSXML2.ServerXMLHTTP")
http.Open "POST", "http://localhost:5005/webhooks/rest/webhook", False
http.setRequestHeader "Content-Type", "application/json"
http.Send jsonRequest
RasaAntwort = http.responseText ' ggf. Parsing notwendig
End Function
Was sinnvoll ist
- GPT fĂŒr freie Dialoge (z.âŻB. technische ErklĂ€rungen)
- Rasa fĂŒr strukturierte Prozesse (z.âŻB. Bestellabfragen)
- Access als UI + Kontextdatenbank
- Kontext = Vorteil: Access weiĂ, wer, wann, was gefragt hat
Was Du beachten musst
- GPT kostet pro Anfrage â prĂŒf die Token-Anzahl
- Rasa braucht Training und Pflege
- Logge alle Nachrichten
- Baue Feedback-Schleifen ein (âWar die Antwort hilfreich?â)
âGPT redet, Rasa denkt â Access protokolliert.â
Wenn Du das kombinieren willst â ich helf Dir.
Chat-UI in Access. KI im Hintergrund. Klarer Ablauf.
Keine Antworten