How khushi-1304/the-relay works
The Relay is an asynchronous, citation-grounded RAG service. An HTTP client submits a research question; the API applies bounded admission, quota checks, and retry handling before invoking the pipeline. The pipeline retrieves page-aware evidence, refuses insufficiently supported questions, builds model context, calls a configured provider, and verifies citations with a bounded correction attempt. The main internal layers are the BM25 retrieval stack and traffic-control mechanisms. The README documents these capabilities; some implementation details, especially unsampled reliability and monitoring code, are represented only where the excerpts or README support their relationships.
Main entry points: routes.py Research Endpoint · orchestrator.py Pipeline Orchestrator · retriever.py Passage Retriever · main.py FastAPI App
Components 25
HTTP API
- FastAPI App
app/main.py - Research Endpoint
app/api/routes.py - Request Schemas
app/api/schemas.py - Runtime Settings
app/config.py
Traffic Control
- Admission Queue
app/reliability/queue_manager.py - Sliding Quotas
app/reliability/rate_limiter.py - Retry Policy
app/reliability/retry_policy.py - Request Telemetry
app/reliability/telemetry.py - Results Logger
app/monitoring/results_logger.py
Research Pipeline
- Pipeline Orchestrator
app/pipeline/orchestrator.py - Context Builder
app/pipeline/context_builder.py - Citation Verifier
app/pipeline/answer_verifier.py
Evidence Retrieval
- Passage Retriever
app/retrieval/retriever.py - PDF Loader
app/retrieval/document_loader.py - Page Chunker
app/retrieval/chunker.py - BM25 Index
app/retrieval/index.py - Heuristic Reranker
app/retrieval/reranker.py
Model Providers
- Provider Interface
app/providers/base.py - Groq Adapter
app/providers/groq_provider.py - Stand-in Adapter
app/providers/standin_provider.py
Stand-in Service
- Stand-in HTTP API
standin_service/main.py - Behavior Simulator
standin_service/simulator.py - Simulator Settings
standin_service/config.py
Other components
- HTTP Client
- Groq API
Connections 24
- HTTP Client → FastAPI App: sends request
app/main.py - FastAPI App → Research Endpoint: mounts routes
app/main.py - Research Endpoint → Request Schemas: validates input
app/api/routes.py - Research Endpoint → Admission Queue: admits request
app/api/routes.py - Research Endpoint → Sliding Quotas: checks quota
app/api/routes.py - Research Endpoint → Retry Policy: evaluates retry
app/api/routes.py - Research Endpoint → Pipeline Orchestrator: runs pipeline
app/api/routes.py - Research Endpoint → Request Telemetry: records trace
app/api/routes.py - Research Endpoint → Results Logger: logs results
- FastAPI App → Runtime Settings: loads settings
app/main.py - Pipeline Orchestrator → Passage Retriever: retrieves passages
app/pipeline/orchestrator.py - Pipeline Orchestrator → Context Builder: builds context
app/pipeline/orchestrator.py - Pipeline Orchestrator → Provider Interface: invokes provider
app/pipeline/orchestrator.py - Pipeline Orchestrator → Citation Verifier: checks citations
app/pipeline/orchestrator.py - Passage Retriever → PDF Loader: loads papers
app/retrieval/retriever.py - Passage Retriever → Page Chunker: builds chunks
app/retrieval/retriever.py - Passage Retriever → BM25 Index: searches index
app/retrieval/retriever.py - Passage Retriever → Heuristic Reranker: reranks candidates
app/retrieval/retriever.py - Provider Interface → Groq Adapter: implemented by
app/providers/groq_provider.py - Provider Interface → Stand-in Adapter: implemented by
app/providers/standin_provider.py - Groq Adapter → Groq API: sends completion
app/providers/groq_provider.py - Stand-in Adapter → Stand-in HTTP API: sends completion
app/providers/standin_provider.py - Stand-in HTTP API → Behavior Simulator: checks admission
standin_service/main.py - Behavior Simulator → Simulator Settings: uses profile
standin_service/simulator.py