Dialogorientierte KI per Access: KI-Bots auf Basis von ChatGPT oder Rasa starten

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

SystemVorteilNachteil
ChatGPTSchnell einsatzbereitWenig Kontrolle, API-Kosten
RasaLokal, trainierbar, offenMehr Initialaufwand

Tabellenstruktur (Beispiel)

TabelleZweck
tblDialogeGesprÀchsverlauf
tblSitzungenKonversationen 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

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert