How d-hackmt/8hr-marathon works
Purpose and Entry Points
Enterprise agentic RAG for answering technical-document questions while rejecting irrelevant, jailbreak, and injection requests. Runtime entry points are FastAPI (app/main.py), Streamlit chat UI (ui/app.py), ingestion CLI (app/ingestion/processor.py), and evaluation UI (evals/app.py).
Request Boundary and Safety
app/main.py exposes /query and applies NeMo Guardrails before agent execution. Guardrails are defined in app/guardrails/rails.py and app/guardrails/colang_rules.py; blocked requests return without retrieval. This is the primary untrusted-user-input boundary, with output filtering also applied around generated answers.
Agent Orchestration
LangGraph coordinates the conversation workflow in app/agents/graph.py, carrying history and intermediate state via app/agents/state.py. The planner (app/agents/nodes/planner.py) classifies intent: conversational questions route directly to response generation, while technical/document requests route to retrieval. LangGraph memory preserves thread-level conversational context.
Retrieval and Answer Generation
The retriever node (app/agents/nodes/retriever.py) embeds the query, searches Qdrant, and locally reranks candidates before response construction. Retrieval services are separated into Gemini embedding integration (app/services/retrieval/embedding.py), Qdrant Cloud access (app/services/retrieval/qdrant_service.py), and FlashRank ranking (app/services/retrieval/ranking_service.py). The responder (app/agents/nodes/responder.py) receives either planner-only context or reranked source context and produces the final answer.
LLM Access and Observability
All generation is routed through the Portkey client in app/gateway/client.py, which fronts Groq/Llama calls and supports primary/fallback credentials. Configuration and external-service credentials are centralized in app/config.py. The deployed path depends on Portkey, Groq, Gemini Embeddings, Qdrant Cloud, Pydantic Logfire, and LangSmith; tracing spans the API and agent-node execution path.
Document Ingestion and Indexing
The ingestion CLI traverses source documents, dispatches format-specific local parsers, chunks extracted text, persists JSON artifacts, embeds chunks, and writes vectors to Qdrant. Core coordination is app/ingestion/processor.py; parsing boundary implementations are under app/ingestion/loaders/ and chunking is app/ingestion/chunking/splitter.py. Source corpora reside in DATA/true_data and DATA/noisy_data; generated local parse outputs are under processed_data/true and processed_data/noisy.
User and Quality Feedback Loops
The Streamlit client in ui/app.py calls the FastAPI backend and surfaces reasoning-step transparency. The separate evaluation application (evals/app.py) runs an evaluation pipeline (evals/pipeline.py) against curated datasets such as evals/golden_dataset.json, using RAGAS metrics plus custom measurement. It is operationally separate from live serving but validates guardrails, retrieval, and answer quality against the same backend.
Main entry points: retriever.py Retriever node · responder.py Responder node · rails.py NeMo Guardrails · graph.py LangGraph workflow
Components 23
Live Serving
- Streamlit chat UI · Displays answer and reasoning-step transparency.
ui/app.py - FastAPI API · Exposes the /query request boundary.
app/main.py - NeMo Guardrails · Rejects jailbreak, injection, and irrelevant requests; filters output.
app/guardrails/rails.py - Colang rules
app/guardrails/colang_rules.py - Portkey client · Routes generation through primary and fallback credentials.
app/gateway/client.py - Groq / Llama
Agent Workflow
- LangGraph workflow · Carries conversation state and thread memory.
app/agents/graph.py - Conversation state
app/agents/state.py - Intent planner · Routes conversational requests directly and technical requests to retrieval.
app/agents/nodes/planner.py - Retriever node · Embeds, searches, and reranks technical-document candidates.
app/agents/nodes/retriever.py - Responder node · Builds the final answer from planner or source context.
app/agents/nodes/responder.py
Retrieval
- Gemini embeddings
app/services/retrieval/embedding.py - Qdrant access
app/services/retrieval/qdrant_service.py - FlashRank reranker
app/services/retrieval/ranking_service.py - Qdrant Cloud
Ingestion & Indexing
- Ingestion CLI · Traverses, parses, chunks, embeds, and indexes documents.
app/ingestion/processor.py - Source corpora · True and noisy technical-document inputs.
DATA/true_data - Format parsers
- Text chunker
app/ingestion/chunking/splitter.py - Processed artifacts · Generated true/noisy parse artifacts.
processed_data/true
Evaluation
- Evaluation UI
evals/app.py - Evaluation pipeline · Uses RAGAS and custom measurements against curated cases.
evals/pipeline.py - Golden dataset
evals/golden_dataset.json
Connections 25
- Streamlit chat UI → FastAPI API: query requests
- FastAPI API → NeMo Guardrails: validate input/output
- Colang rules → NeMo Guardrails: defines policies
- NeMo Guardrails → LangGraph workflow: allowed requests
- LangGraph workflow → Conversation state: reads and updates
- LangGraph workflow → Intent planner: dispatches
- Intent planner → Retriever node: technical/document intent
- Intent planner → Responder node: conversational context
- Retriever node → Gemini embeddings: embed query
- Retriever node → Qdrant access: search candidates
- Retriever node → FlashRank reranker: rerank candidates
- Qdrant access → Qdrant Cloud: vector queries
- Retriever node → Responder node: reranked sources
- Responder node → Portkey client: generate answer
- Portkey client → Groq / Llama: LLM calls
- Responder node → NeMo Guardrails: answer filtering
- Ingestion CLI → Source corpora: traverses
- Ingestion CLI → Format parsers: parses documents
- Format parsers → Text chunker: extracted text
- Text chunker → Processed artifacts: persist chunks
- Text chunker → Gemini embeddings: embed chunks
- Gemini embeddings → Qdrant access: chunk vectors
- Evaluation UI → Evaluation pipeline: runs evaluation
- Golden dataset → Evaluation pipeline: test cases
- Evaluation pipeline → FastAPI API: validates backend