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
24 lines
793 B
Python
24 lines
793 B
Python
"""Render a template's Markdown skeleton and title into a new draft document."""
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from app.authoring.schema import AuthoringTemplate
|
|
from app.models import User
|
|
|
|
|
|
def render_title(template: AuthoringTemplate, user: User) -> str:
|
|
today = datetime.now(UTC).date().isoformat()
|
|
return (
|
|
template.title_template.replace("{{user.name}}", user.name)
|
|
.replace("{{date}}", today)
|
|
.strip()
|
|
)
|
|
|
|
|
|
def render_skeleton(template: AuthoringTemplate) -> str:
|
|
"""The Markdown the editor opens with: the skeleton verbatim, normalized
|
|
to a single trailing newline. An empty skeleton yields an empty document
|
|
the author fills from scratch."""
|
|
skeleton = template.skeleton.strip()
|
|
return f"{skeleton}\n" if skeleton else ""
|