How muradyanhaykaz05-blip/electronic-comms-law-qa works
This is a bilingual legal-question-answering RAG application. Users ask in Armenian or English; the API retrieves law excerpts, builds a language-appropriate prompt, calls a configured LLM, and checks article citations. A separate benchmark workflow scores answers for accuracy and hallucinations and reports operational metrics. The README documents ingestion and database loading; sampled source confirms the retrieval and scoring paths. Unsampled implementation details and some runtime wiring are represented only where the README supports them.
Main entry points: app.py Ask workflow · __init__.py Provider registry · retriever.py Hybrid retrieval · base.py Provider interface
Components 28
User interface
- Web interface
static/index.html - Browser client
static/app.js
API workflows
- FastAPI server
app.py - Ask workflow
app.py - Benchmark runner
app.py - Question set
benchmark/questions.json
Retrieval and scoring
- Hybrid retrieval
rag/retriever.py - Query embeddings
rag/retriever.py - Postgres search
rag/pgvector_store.py - Context and prompt
rag/pipeline.py - Citation parsing
rag/article_numbers.py - Citation checking
rag/pipeline.py - Judge scoring
rag/scoring.py
LLM providers
- Provider registry
providers/__init__.py - Provider interface
providers/base.py - Gemini adapter
providers/gemini_provider.py - OpenAI adapter
providers/openai_provider.py - Grok adapter
providers/grok_provider.py - OpenRouter adapter
providers/openrouter_provider.py - Cost estimates
providers/pricing.py
Law corpus
- Law chunk store
db/schema.sql - Armenian ingestion
data/ingest.py - English ingestion
data/ingest_en.py - Pre-ingested articles
data/articles.json - English articles
data/articles_en.json - Embedding loader
data/load_to_pgvector.py
Other components
- Questioner
- LLM services
Connections 35
- Questioner → Browser client: asks
README.md - Browser client → FastAPI server: calls API
README.md - FastAPI server → Web interface: serves
README.md - FastAPI server → Ask workflow: routes ask
app.py - FastAPI server → Benchmark runner: routes benchmark
app.py - Ask workflow → Hybrid retrieval: builds context
app.py - Hybrid retrieval → Query embeddings: encodes query
rag/retriever.py - Hybrid retrieval → Postgres search: searches
rag/retriever.py - Postgres search → Law chunk store: queries
rag/pgvector_store.py - Ask workflow → Context and prompt: builds prompt
app.py - Context and prompt → Hybrid retrieval: retrieves chunks
rag/pipeline.py - Ask workflow → Provider registry: selects provider
app.py - Provider registry → Gemini adapter: configures
providers/__init__.py - Provider registry → OpenAI adapter: configures
providers/__init__.py - Provider registry → Grok adapter: configures
providers/__init__.py - Provider registry → OpenRouter adapter: configures
providers/__init__.py - Gemini adapter → Provider interface: implements
providers/gemini_provider.py - Grok adapter → Provider interface: extends
providers/grok_provider.py - OpenRouter adapter → Provider interface: extends
providers/openrouter_provider.py - OpenAI adapter → Provider interface: implements
providers/base.py - Ask workflow → Citation checking: checks citations
app.py - Citation checking → Citation parsing: parses numbers
rag/pipeline.py - Benchmark runner → Question set: loads questions
README.md - Benchmark runner → Hybrid retrieval: builds contexts
app.py - Benchmark runner → Judge scoring: scores answers
app.py - Judge scoring → Provider interface: calls judge
rag/scoring.py - Benchmark runner → Cost estimates: estimates cost
README.md - Gemini adapter → LLM services: streams responses
providers/gemini_provider.py - Grok adapter → LLM services: calls API
providers/grok_provider.py - OpenRouter adapter → LLM services: calls API
providers/openrouter_provider.py - Armenian ingestion → Pre-ingested articles: produces
- English ingestion → English articles: produces
- Pre-ingested articles → Embedding loader: loads chunks
README.md - English articles → Embedding loader: loads chunks
README.md - Embedding loader → Law chunk store: embeds and upserts
README.md