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
34 lines
978 B
Python
34 lines
978 B
Python
"""Template rows to API shapes.
|
|
|
|
Both are built explicitly rather than validated from the row: the blueprint id
|
|
and the description live inside `config`, and `yaml` is rendered per request,
|
|
so there is nothing on the row to read them from.
|
|
"""
|
|
|
|
import yaml
|
|
|
|
from app.api.templates.schemas import TemplateDetail, TemplateSummary
|
|
from app.models import Template
|
|
|
|
|
|
def summary(row: Template) -> TemplateSummary:
|
|
return TemplateSummary(
|
|
id=row.id,
|
|
config_id=row.config.get("id", ""),
|
|
name=row.name,
|
|
version=row.version,
|
|
description=row.config.get("description", ""),
|
|
)
|
|
|
|
|
|
def detail(row: Template) -> TemplateDetail:
|
|
return TemplateDetail(
|
|
id=row.id,
|
|
config_id=row.config.get("id", ""),
|
|
name=row.name,
|
|
version=row.version,
|
|
description=row.config.get("description", ""),
|
|
config=row.config,
|
|
yaml=yaml.safe_dump(row.config, allow_unicode=True, sort_keys=False, width=80),
|
|
)
|