How samarth40/rag-price-control works
This is a tenant-scoped RAG cost-control service: queries enter through the API, may fetch context from an existing RAG backend, then use semantic caching and model routing before returning an answer. Fresh requests are logged and cached; the dashboard displays query results and aggregate metrics. The README also describes BM25-plus-vector tiered retrieval, but the sampled BM25 implementation is not wired into the query orchestrator, so that branch is shown separately.
Main entry points: orchestrator.py Query Orchestrator · main.py FastAPI Service · streamlit_app.py Streamlit Dashboard · semantic_cache.py Semantic Cache
Components 15
User Interfaces
- Streamlit Dashboard
streamlit_app.py - FastAPI Service
app/main.py
Query Runtime
- Query Orchestrator
app/services/orchestrator.py - Semantic Cache
app/services/semantic_cache.py - Redis Cache Store
- Model Router
app/services/model_router.py - Economical Model
- Strong Model
Retrieval
- BM25 Prefilter
app/services/tiered_retrieval.py - Vector Search
Observability
- Event Logging
app/core/observability.py - SQLite Events
- Stats Summary
app/core/observability.py
Other components
- User
- Existing RAG Backend
Connections 17
- User → Streamlit Dashboard: uses
- Streamlit Dashboard → FastAPI Service: submits query
- Streamlit Dashboard → FastAPI Service: requests stats
- FastAPI Service → Query Orchestrator: runs query
- FastAPI Service → Stats Summary: gets summary
- Query Orchestrator → Existing RAG Backend: fetches context
- Existing RAG Backend → Query Orchestrator: returns chunks
- Query Orchestrator → Semantic Cache: looks up and stores
- Semantic Cache → Redis Cache Store: reads and writes
- Query Orchestrator → Model Router: classifies query
- Model Router → Query Orchestrator: returns route
- Query Orchestrator → Economical Model: calls model
- Query Orchestrator → Strong Model: escalates when unsure
- Query Orchestrator → Event Logging: logs request
- Event Logging → SQLite Events: writes events
- Stats Summary → SQLite Events: queries events
- BM25 Prefilter → Vector Search: candidate IDs for reranking