Chat API
RAG-basierter Chat mit Vektorsuche und LLM-Integration. Verwendet lokale Embeddings (Ollama), Vektorsuche (Qdrant) und Claude (Anthropic) oder Ollama als LLM.
Endpoints-Übersicht
| Methode | Pfad | Controller | Beschreibung |
|---|---|---|---|
| POST | /api/v1/chat | Api\ChatController | Einfache Chat-Anfrage (JSON) |
| GET | /api/v1/chat/search | Api\ChatController | Chunk-Suche |
| GET | /api/v1/chat/stats | Api\ChatController | Pipeline-Statistiken |
| POST | /chat/{uuid}/message | ChatController | Chat-Nachricht senden (HTML/HTMX) |
JSON API: POST /api/v1/chat
Einfache Chat-Anfrage mit festen Einstellungen.
| Controller | Controller\Api\ChatController |
|---|---|
| Service | Infrastructure\AI\ChatService |
Request
POST /api/v1/chat
Content-Type: application/json
{
"message": "Was ist systemische Therapie?"
}
| Parameter | Typ | Beschreibung |
|---|---|---|
| message | string | Benutzer-Frage (required) |
Hinweis: Dieser Endpunkt verwendet feste Einstellungen: Claude Opus 4.5, Collection "dokumentation_chunks", Limit 5. Für konfigurierbare Optionen den HTML-Endpunkt verwenden.
Response
{
"answer": "Systemische Therapie ist ein psychotherapeutischer Ansatz...",
"sources": [
{
"title": "Einführung in die systemische Therapie",
"content": "...",
"score": 0.89,
"path": "/Documents/therapie/einfuehrung.pdf"
}
],
"model": "claude-opus-4-5-20251101",
"tokens": 1234
}
HTML-Endpunkt: POST /chat/{uuid}/message
Vollständig konfigurierbarer Chat mit Session-Unterstützung.
| Controller | Controller\ChatController |
|---|
Request
POST /chat/{uuid}/message
Content-Type: application/x-www-form-urlencoded
message=Was+ist+systemische+Therapie%3F
&model=anthropic
&collections[]=documents
&collections[]=dokumentation
&contextLimit=5
&systemPromptId=1
&structureId=2
&qualityCheck=1
Parameter
| Parameter | Typ | Default | Beschreibung |
|---|---|---|---|
| message | string | required | Benutzer-Frage |
| model | string | "anthropic" | "anthropic" (Claude) oder "ollama" (lokal) |
| collections[] | string[] | ["documents"] | Qdrant Collections (Array) |
| contextLimit | int | 5 | Max. Kontext-Chunks (3/5/10/15) |
| systemPromptId | int | null | System-Prompt aus content_config |
| structureId | int | null | Output-Struktur |
| qualityCheck | int | 0 | Qualitätsprüfung aktivieren |
| author_profile_id | int | null | Autorenprofil für Schreibstil |
GET /api/v1/chat/search
Suche nach relevanten Chunks ohne LLM-Anfrage.
GET /api/v1/chat/search?q=systemische+therapie&limit=5
Response
{
"results": [
{"id": 42, "score": 0.89, "payload": {...}}
]
}
GET /api/v1/chat/stats
Pipeline-Statistiken (Doc2Vector).
{
"dokumente": 15,
"seiten": 120,
"chunks": 450,
"tokens": 125000,
"analyzed": 400,
"synced": 380
}
RAG-Pipeline
1. Embedding erstellen (OllamaService)
question → mxbai-embed-large → [1024-dim vector]
2. Vektorsuche (QdrantService)
vector → Qdrant :6333 → top-k similar chunks
3. Kontext aufbauen (ChatService)
chunks → formatierter Kontext mit Quellenangaben
max. 3000 tokens (~12000 chars)
4. LLM-Anfrage (ClaudeService oder OllamaService)
system_prompt + rag_prompt + context → answer
5. Response zusammenstellen (ChatService)
answer + sources + metadata + usage
Fehlerbehandlung
| HTTP Code | Bedeutung |
|---|---|
| 400 | Fehlende oder ungültige Parameter |
| 500 | Service-Fehler (Ollama, Qdrant, Claude) |
| 503 | Service nicht verfügbar |