How lorekeeper-ku/lorekeeper works
LoreKeeper is a conversational story-writing and canon-management application. A user message enters the Streamlit UI, is handled by a function-calling chat loop, and may read approved lore, create or propose canon changes, write a verified scene, or request artwork. Approved facts persist in SQLite; conversation and pending drafts remain in session context. The principal scene workflow retrieves canon, generates text, checks claims, and repairs contradictions. The README documents these capabilities; arrows below are limited to relationships shown in excerpts, indexed references, or README statements.
Main entry points: chat_tools.py Validated tools · ui_backend.py Message backend · orchestrator.py Scene workflow · canon_verifier.py Continuity checker
Components 26
Chat experience
- Streamlit UI
app.py - Chat components
lorekeeper_ui/components.py - Message backend
generation_engine/ui_backend.py - Tool chat loop
generation_engine/chat_orchestrator.py - Validated tools
generation_engine/chat_tools.py - Conversation context
generation_engine/conversation.py
Canon management
- Canon SQLite store
canon_memory/canon_store.py - Canon retrieval
canon_memory/canon_retriever.py - Knowledge graph
canon_memory/knowledge_graph.py - Canon memory
canon_memory/memory.py - Canon proposals
generation_engine/canon_editor.py
Story and continuity
- Character creation
generation_engine/character_creator.py - Scene generation
generation_engine/ai_story_generator.py - Scene workflow
generation_engine/orchestrator.py - Text visual workflow
generation_engine/team_pipeline.py - Continuity checker
continuity_checker/canon_verifier.py - Contradiction classifier
continuity_checker/contradiction_classifier.py - Addition judge
continuity_checker/addition_judge.py - Predicate policy
continuity_checker/predicate_policy.py - Fact relevance
continuity_checker/relevance.py - NLI comparator
continuity_checker/nli_comparator.py
Visuals
- Image generation checks
multimodal/visuals.py - Vision result models
multimodal/model.py
Shared services
- AI provider client
shared/ai_client.py - Shared contracts
shared/schemas.py
Other components
- User
Connections 33
- User → Streamlit UI: sends message
README.md - Streamlit UI → Chat components: renders chat
app.py - Streamlit UI → Message backend: handles request
app.py - Chat components → Message backend: submits request
lorekeeper_ui/components.py - Message backend → Tool chat loop: runs conversation
generation_engine/ui_backend.py - Tool chat loop → Validated tools: executes calls
generation_engine/chat_orchestrator.py - Tool chat loop → AI provider client: requests tool choice
generation_engine/chat_orchestrator.py - Validated tools → Canon SQLite store: reads and writes
generation_engine/chat_tools.py - Validated tools → Canon memory: retrieves canon
generation_engine/chat_tools.py - Validated tools → Canon proposals: proposes changes
generation_engine/chat_tools.py - Validated tools → Character creation: creates character
generation_engine/chat_tools.py - Validated tools → Scene generation: writes scene
generation_engine/chat_tools.py - Validated tools → Text visual workflow: requests visuals
generation_engine/chat_tools.py - Validated tools → Image generation checks: generates image
generation_engine/chat_tools.py - Message backend → Scene workflow: runs scene pipeline
generation_engine/ui_backend.py - Message backend → Text visual workflow: runs team workflow
generation_engine/ui_backend.py - Message backend → Conversation context: uses conversation state
generation_engine/ui_backend.py - Canon memory → Canon retrieval: retrieves facts
canon_memory/memory.py - Canon memory → Canon SQLite store: accesses facts
canon_memory/memory.py - Canon retrieval → Canon SQLite store: loads world facts
canon_memory/canon_retriever.py - Canon retrieval → Knowledge graph: builds graph
canon_memory/canon_retriever.py - Scene workflow → Continuity checker: verifies scene
generation_engine/orchestrator.py - Scene workflow → Scene generation: generates and repairs
generation_engine/orchestrator.py - Continuity checker → Fact relevance: selects facts
continuity_checker/canon_verifier.py - Continuity checker → Contradiction classifier: classifies claims
continuity_checker/canon_verifier.py - Continuity checker → NLI comparator: compares claims
continuity_checker/nli_comparator.py - Contradiction classifier → Predicate policy: checks predicates
continuity_checker/contradiction_classifier.py - Contradiction classifier → Addition judge: judges additions
continuity_checker/contradiction_classifier.py - Image generation checks → AI provider client: requests image
multimodal/visuals.py - Image generation checks → Vision result models: returns check result
multimodal/visuals.py - Canon SQLite store → Shared contracts: validates facts
canon_memory/canon_store.py - Image generation checks → Shared contracts: uses asset contracts
multimodal/visuals.py - Scene workflow → Shared contracts: uses report contracts
generation_engine/orchestrator.py