feat: Langzeit-Erinnerungen (#3b) und WebSocket-Streaming-Chat (#4, erster Increment)
#3b Langzeit-Erinnerungen: - Store: memories-Tabelle + add/get/delete_memory (pro Nutzer) - API: GET/POST/DELETE /api/me/memories - chat.py injiziert Nutzer-Erinnerungen als System-Kontext ins LLM (sessionunabhaengig) - ?debug zeigt memories_len #4 Echtzeit (erster Increment): - WS /ws/chat: dauerhafter Kanal, Event-Folge ack -> semantic -> audio (binaer) -> done - Auth (Token-Query), Session-Gedaechtnis und Erinnerungen wie bei POST /api/chat - Fehler als error-Event (422/403/502) - Tests: 38 gruen (Erinnerungs-CRUD/Injektion, WebSocket-Streaming/Auth) - Doku aktualisiert (README, BEDIENUNGSANLEITUNG, Architektur) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
16a964032e
commit
531b57e08d
12 changed files with 389 additions and 9 deletions
|
|
@ -50,6 +50,22 @@ def test_no_session_id_is_stateless(monkeypatch):
|
|||
assert captured["history"] == [] # ohne session_id kein Gedaechtnis
|
||||
|
||||
|
||||
def test_memories_injected_as_context(monkeypatch):
|
||||
captured = {}
|
||||
base = _install_stubs(monkeypatch, captured)
|
||||
|
||||
# Erinnerung fuer den (anonymen) Nutzer ablegen.
|
||||
deps.get_store().ensure_anonymous_user()
|
||||
deps.get_store().add_memory("anonymous", "heisst Anna")
|
||||
|
||||
# Ohne session_id -> kein Verlauf, aber Erinnerung wird trotzdem injiziert.
|
||||
r = client.post("/api/chat?debug=true", json={"text": "Hallo", **base})
|
||||
assert r.status_code == 200
|
||||
assert r.json()["memories_len"] == 1
|
||||
assert captured["history"][0]["role"] == "system"
|
||||
assert "heisst Anna" in captured["history"][0]["content"]
|
||||
|
||||
|
||||
def test_history_limited_by_setting(monkeypatch):
|
||||
from app.config import settings
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue