RAG-Chat

Retrieval-Augmented Generation Chat mit semantischer Suche und Session-Persistenz.

Tool/chat
API-Referenz/docs/api/chat
LLMClaude Opus 4.5 (Anthropic) / Ollama (lokal)
Embeddingmxbai-embed-large (Ollama)
VektorenQdrant
Datenbankki_content (chat_sessions, chat_messages)

Web-UI Routen

RouteMethodeBeschreibung
/chatGETNeue Session erstellen, Redirect zu /chat/{uuid}
/chat/{uuid}GETSession anzeigen (Sidebar + Nachrichten)
/chat/{uuid}/messagePOSTNachricht senden (HTMX)
/chat/{uuid}/titlePOSTSession-Titel aktualisieren (HTMX)
/chat/{uuid}/system-promptGETSystem-Prompt Modal laden (HTMX)
/chat/{uuid}/system-promptPOSTSystem-Prompt speichern (HTMX)
/chat/{uuid}DELETESession löschen (HTMX)
/chat/sessionsGETSession-Liste Partial (HTMX)

Features

Session-Verwaltung

Konfiguration

Token & Kosten

Datenbank-Schema

Session-Persistenz in ki_content:

chat_sessions

SpalteTypBeschreibung
idINT AUTO_INCREMENTPrimary Key
uuidVARCHAR(36) UNIQUESession-UUID für URLs
titleVARCHAR(255)Session-Titel (auto/manuell)
modelVARCHAR(50)LLM-Modell (anthropic/ollama)
collectionVARCHAR(50)Qdrant-Collection
context_limitINTAnzahl RAG-Quellen (Default: 5)
created_atTIMESTAMPErstellungszeitpunkt
last_activityTIMESTAMPLetzte Aktivität

chat_messages

SpalteTypBeschreibung
idINT AUTO_INCREMENTPrimary Key
session_idINT NOT NULLFK zu chat_sessions (CASCADE DELETE)
roleENUM('user','assistant')Nachrichtenrolle
contentTEXTNachrichteninhalt
tokens_inputINTInput-Tokens (Claude)
tokens_outputINTOutput-Tokens (Claude)
sourcesJSONRAG-Quellen mit Scores
modelVARCHAR(50)Verwendetes Modell
created_atTIMESTAMPErstellungszeitpunkt

RAG-Pipeline

User Query (Text)
    ↓
Embedding erzeugen (mxbai-embed-large)
    ↓
Qdrant: Ähnliche Chunks finden (Top-K)
    ↓
Kontext zusammenstellen
    ↓
LLM (Claude/Ollama): Antwort generieren
    ↓
Response + Quellenangaben + Tokens speichern

Siehe auch