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
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
"""Loader for the shared fixture corpus — seeds and tests draw from it.
|
||||
|
||||
The corpus is product content (German knowledge documents of the fictional
|
||||
SME "Nordwind Maschinenbau GmbH"). PyYAML is available through
|
||||
uvicorn[standard]; it becomes a declared dependency with the template
|
||||
import in M6.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import yaml
|
||||
|
||||
FIXTURES_DIR = Path(__file__).resolve().parent
|
||||
CORPUS_DIR = FIXTURES_DIR / "corpus"
|
||||
|
||||
|
||||
@dataclass
|
||||
class CorpusDoc:
|
||||
slug: str
|
||||
title: str
|
||||
department: str
|
||||
visibility: str
|
||||
content_md: str
|
||||
grants: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
def load_corpus() -> list[CorpusDoc]:
|
||||
docs: list[CorpusDoc] = []
|
||||
for path in sorted(CORPUS_DIR.glob("*.md")):
|
||||
text = path.read_text()
|
||||
if not text.startswith("---\n"):
|
||||
raise ValueError(f"corpus file without frontmatter: {path.name}")
|
||||
_, frontmatter, body = text.split("---\n", 2)
|
||||
meta = yaml.safe_load(frontmatter)
|
||||
docs.append(
|
||||
CorpusDoc(
|
||||
slug=meta["id"],
|
||||
title=meta["title"],
|
||||
department=meta["department"],
|
||||
visibility=meta["visibility"],
|
||||
grants=list(meta.get("grants", [])),
|
||||
content_md=body.strip() + "\n",
|
||||
)
|
||||
)
|
||||
return docs
|
||||
|
||||
|
||||
def load_golden_queries() -> list[dict[str, Any]]:
|
||||
return yaml.safe_load((FIXTURES_DIR / "golden_queries.yaml").read_text())
|
||||
|
||||
|
||||
def load_conversation_snippets() -> list[dict[str, Any]]:
|
||||
"""Short chats whose LAST message is a topic-losing follow-up, with the
|
||||
corpus slug the conversation is really about — for comparing topic-summary
|
||||
retrieval against retrieval over the raw last message."""
|
||||
return yaml.safe_load((FIXTURES_DIR / "conversation_snippets.yaml").read_text())
|
||||
Reference in New Issue
Block a user