Pablan, as it stands
Self-hosted knowledge management for SMEs: a split-screen Markdown editor whose sections an LLM refines while you write, and RAG question answering over the documents that result. FastAPI + Postgres/pgvector on the back, SvelteKit on the front, everything OpenAI-compatible and self-hostable. Squashed into a single commit; the development history stays local. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA43ZJda8Rbp2hKXNy8f6b
This commit is contained in:
co-authored by
Claude Opus 5
parent
68d3a43191
commit
784b76baf7
@@ -0,0 +1,44 @@
|
||||
"""Query mode helpers (the SSE contract itself lives in
|
||||
test_conversations_api.py)."""
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
from app.models import MessageRole
|
||||
from app.modes.query import _topic_transcript
|
||||
|
||||
|
||||
def _msg(role: MessageRole, content: str) -> SimpleNamespace:
|
||||
return SimpleNamespace(role=role, content=content)
|
||||
|
||||
|
||||
def test_topic_transcript_needs_prior_context() -> None:
|
||||
# A first message alone has no earlier context: the topic fallback is a
|
||||
# no-op, so a first-message miss stays a genuine no-answer.
|
||||
conversation = SimpleNamespace(messages=[])
|
||||
assert _topic_transcript(conversation, "Wie beantrage ich Urlaub?") == ""
|
||||
|
||||
|
||||
def test_topic_transcript_includes_history_and_current() -> None:
|
||||
conversation = SimpleNamespace(
|
||||
messages=[
|
||||
_msg(MessageRole.user, "Wie beantrage ich Urlaub?"),
|
||||
_msg(MessageRole.assistant, "Über das Personalportal."),
|
||||
]
|
||||
)
|
||||
transcript = _topic_transcript(conversation, "Und was war meine erste Frage?")
|
||||
assert "Urlaub" in transcript
|
||||
assert "erste Frage" in transcript
|
||||
assert transcript.count("User:") == 2
|
||||
|
||||
|
||||
def test_topic_transcript_does_not_duplicate_the_current_message() -> None:
|
||||
# The current message may already be persisted as the last stored turn.
|
||||
conversation = SimpleNamespace(
|
||||
messages=[
|
||||
_msg(MessageRole.user, "Erste Frage."),
|
||||
_msg(MessageRole.assistant, "Antwort."),
|
||||
_msg(MessageRole.user, "Zweite Frage."),
|
||||
]
|
||||
)
|
||||
transcript = _topic_transcript(conversation, "Zweite Frage.")
|
||||
assert transcript.count("Zweite Frage.") == 1
|
||||
Reference in New Issue
Block a user