How abhijitwebdev/medic-guidelines-rag works
Medical Guideline Assistant answers general questions from its pinned government-guideline corpus, with citations and refusals enforced by three gates. The main user path runs through the API and assistant orchestration; corpus ingestion and indexing prepare the material it searches. Account/history storage and caching support the application. Relationships reflect the README and available source-index references; some implementation details, including several retrieval and ingestion stages, were not sampled.
Main entry points: assistant.py Assistant · search.py Hybrid Retrieval · llm.py Model Client · pipeline.py Corpus Ingestion
Components 26
Application
- HTTP API
src/rag_project/api.py - Assistant
src/rag_project/assistant.py - Accounts and History
src/rag_project/db/users.py
Guideline Corpus
- Corpus Ingestion
src/rag_project/ingest/pipeline.py - Pinned Manifest
src/rag_project/corpus/manifest.py - PDF Parsing
src/rag_project/ingest/parse.py - Chunking
src/rag_project/ingest/chunk.py - Index Building
src/rag_project/indexing/build.py - Embedding
src/rag_project/indexing/embed.py - Vector Store
src/rag_project/indexing/store.py
Answer Pipeline
- Query Rewrite
src/rag_project/retrieval/rewrite.py - HyDE
src/rag_project/retrieval/hyde.py - Hybrid Retrieval
src/rag_project/retrieval/search.py - BM25 Search
src/rag_project/indexing/bm25.py - Passage Reranking
src/rag_project/retrieval/rerank.py - Intent Gate
src/rag_project/guardrails/input_gate.py - Confidence Gate
src/rag_project/guardrails/confidence.py - Corrective Retrieval
src/rag_project/retrieval/corrective.py - Answer Generation
src/rag_project/generation/generate.py - Output Gate
src/rag_project/guardrails/output_gate.py
Supporting Services
- Model Client
src/rag_project/llm.py - Cache
src/rag_project/cache.py - Database Engine
src/rag_project/db/engine.py
Other components
- Questioner
- Government Guidelines
- OpenAI Service
Connections 27
- Questioner → HTTP API: asks
src/rag_project/api.py - HTTP API → Assistant: invokes
src/rag_project/api.py - HTTP API → Accounts and History: uses accounts
src/rag_project/api.py - Corpus Ingestion → Pinned Manifest: verifies and loads
src/rag_project/ingest/pipeline.py - Corpus Ingestion → PDF Parsing: parses documents
src/rag_project/ingest/pipeline.py - Corpus Ingestion → Chunking: chunks sections
src/rag_project/ingest/pipeline.py - Government Guidelines → Pinned Manifest: documents listed
README.md - Index Building → Embedding: builds vectors
- Index Building → Vector Store: writes index
- Assistant → Intent Gate: checks intent
src/rag_project/assistant.py - Assistant → Hybrid Retrieval: retrieves passages
README.md - Assistant → Passage Reranking: reranks passages
src/rag_project/assistant.py - Assistant → Confidence Gate: judges confidence
src/rag_project/assistant.py - Assistant → Corrective Retrieval: retries retrieval
README.md - Assistant → Answer Generation: generates answer
src/rag_project/assistant.py - Assistant → Output Gate: validates answer
src/rag_project/assistant.py - Query Rewrite → Hybrid Retrieval: rewrites query
README.md - HyDE → Hybrid Retrieval: blends query vector
README.md - Hybrid Retrieval → BM25 Search: searches lexical
src/rag_project/retrieval/search.py - Hybrid Retrieval → Vector Store: searches dense
src/rag_project/retrieval/search.py - Confidence Gate → Corrective Retrieval: requests retry
README.md - Answer Generation → Model Client: calls model
src/rag_project/generation/generate.py - Intent Gate → Model Client: classifies intent
src/rag_project/guardrails/input_gate.py - Output Gate → Model Client: judges support
src/rag_project/guardrails/output_gate.py - Model Client → OpenAI Service: sends prompts
src/rag_project/llm.py - Assistant → Cache: caches results
src/rag_project/assistant.py - Accounts and History → Database Engine: persists accounts
src/rag_project/db/users.py