A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.
audit: fix rag_agent_with_database_routing - fix stale Google API key reference, add docstrings, add back-to-top link
Tiioluwani8ec018d693d3
diff --git a/rag_apps/rag_agent_with_database_routing/README.md b/rag_apps/rag_agent_with_database_routing/README.mdindex 5273a82..b55dc93 100644--- a/rag_apps/rag_agent_with_database_routing/README.md+++ b/rag_apps/rag_agent_with_database_routing/README.md@@ -1,3 +1,4 @@+<a id="top"></a># RAG Agent with Database Routing> A RAG system that intelligently routes queries across three specialized databases covering product information, customer support, and financial data. When no relevant documents are found, a fallback agent performs live web research to still return a useful answer.@@ -43,7 +44,7 @@ cd Hands-On-AI-Engineering/rag_apps/rag_agent_with_database_routingcp .env.example .env```-Add your Google API key to `.env`.+Add your ORQ_API_KEY to `.env`.## Usage@@ -104,3 +105,5 @@ Qdrant retrieves top-k documents from the selected collection▼Streamlit displays the answer with routing badge, source docs, and reasoning```++[Back to top](#top)diff --git a/rag_apps/rag_agent_with_database_routing/rag_agent/pipeline.py b/rag_apps/rag_agent_with_database_routing/rag_agent/pipeline.pyindex def554e..cf34993 100644--- a/rag_apps/rag_agent_with_database_routing/rag_agent/pipeline.py+++ b/rag_apps/rag_agent_with_database_routing/rag_agent/pipeline.py@@ -27,6 +27,8 @@ RAG_SYSTEM = (@dataclassclass PipelineResult:+ """The final answer plus routing and retrieval metadata for a single query."""+answer: strrouting: RoutingDecisiondocs: list[RetrievedDoc] = field(default_factory=list)diff --git a/rag_apps/rag_agent_with_database_routing/rag_agent/retriever.py b/rag_apps/rag_agent_with_database_routing/rag_agent/retriever.pyindex 1a8a432..c40ac4e 100644--- a/rag_apps/rag_agent_with_database_routing/rag_agent/retriever.py+++ b/rag_apps/rag_agent_with_database_routing/rag_agent/retriever.py@@ -18,6 +18,8 @@ from .embeddings import OrqEmbeddings@dataclassclass RetrievedDoc:+ """A single document retrieved from a Qdrant collection, with its similarity score."""+text: strscore: floatsource: strdiff --git a/rag_apps/rag_agent_with_database_routing/rag_agent/router.py b/rag_apps/rag_agent_with_database_routing/rag_agent/router.pyindex 8eae20c..5192e4a 100644--- a/rag_apps/rag_agent_with_database_routing/rag_agent/router.py+++ b/rag_apps/rag_agent_with_database_routing/rag_agent/router.py@@ -34,6 +34,8 @@ _KEYWORDS: dict[str, list[str]] = {class RoutingDecision(BaseModel):+ """Holds which database a query was routed to and why."""+database: Literal["products", "support", "financial"]reasoning: str