How halivekp/khula-gyan works
Khula Gyan is a bilingual Nepali municipal-services guide. Its main workflow takes a question and municipality from the user, retrieves matching charter passages, generates a response, and returns either grounded citations or a refusal. The graph also shows charter ingestion and the documented evaluation harness. Relationships among unsampled ingestion stages follow the README’s workflow; only documented or indexed relationships are shown.
Main entry points: answer.py Answer generation · run_eval.py Evaluation runner · build_index.py Index builder · process_document.py Document processing
Components 25
Charter ingestion
- Index builder
scripts/build_index.py - Document processing
scripts/process_document.py - Page extraction
src/ingest/extract.py - Text repair
src/ingest/clean.py - Chunk creation
src/ingest/chunk.py - Embedding store
src/ingest/embed_store.py
Passage retrieval
- Filtered dense search
src/retrieval/search.py
Answer generation
- Answer generation
src/generation/answer.py - Prompt construction
src/generation/prompt.py - LLM client
src/generation/llm.py - Spend reservation
src/generation/spend.py - Fake generator
src/generation/fake_llm.py - Evidence guard
src/generation/guard.py - Response validation
src/generation/schema.py - Language detection
src/generation/language.py
User interface
- Streamlit interface
frontend/app.py - Ask pipeline
src/pipeline.py
Evaluation
- Evaluation runner
eval/run_eval.py - Answer judge
eval/judge.py - Evaluation results log
eval/results_log.py
Other components
- Questioner
- Charter files
data - Chroma index
- Chat API
- Tesseract OCR
Connections 25
- Questioner → Streamlit interface: asks
README.md - Charter files → Index builder: indexes
README.md - Index builder → Document processing: processes
scripts/build_index.py - Document processing → Page extraction: extracts pages
scripts/process_document.py - Document processing → Text repair: repairs text
scripts/process_document.py - Index builder → Chunk creation: creates chunks
scripts/build_index.py - Index builder → Embedding store: stores embeddings
scripts/build_index.py - Embedding store → Chroma index: writes index
README.md - Streamlit interface → Ask pipeline: calls ask
frontend/app.py - Ask pipeline → Filtered dense search: retrieves passages
README.md - Chroma index → Filtered dense search: supplies passages
README.md - Ask pipeline → Answer generation: generates response
README.md - Answer generation → Language detection: detects language
src/generation/answer.py - Answer generation → Prompt construction: builds messages
src/generation/answer.py - Answer generation → LLM client: requests completion
src/generation/answer.py - LLM client → Chat API: calls API
src/generation/llm.py - LLM client → Spend reservation: reserves cost
src/generation/llm.py - LLM client → Fake generator: dispatches offline
src/generation/fake_llm.py - Answer generation → Response validation: validates response
src/generation/answer.py - Answer generation → Evidence guard: checks evidence
src/generation/answer.py - Document processing → Tesseract OCR: uses for scans
README.md - Evaluation runner → Filtered dense search: retrieves passages
eval/run_eval.py - Evaluation runner → Answer generation: evaluates answers
eval/run_eval.py - Evaluation runner → Answer judge: optionally judges
eval/run_eval.py - Evaluation runner → Evaluation results log: logs runs
eval/run_eval.py