Simulated demo of the RAG Math Routing Agent pipeline. Enter a math question, watch the routing and retrieval steps, and see a generated solution (simulation).
High-level components: API Gateway, Math Router, Knowledge Base, Web Search (MCP), DSPy reasoning engine, Feedback system.
Unified System and Data Flow Architecture
math-routing-agent/
├─ math_agent/
│ ├─ core.py # orchestrates request -> routing -> solution
│ ├─ routing_agent.py # routing & decision logic (KB vs Web vs DSPy)
│ ├─ knowledge_base.py# FAISS embeddings & retrieval
│ ├─ web_search.py # MCP + web search adaptors
│ └─ feedback_system.py # feedback storage & KB updater
def route_request(query):
# 1) check knowledge base similarity threshold
hits = kb.search(query, k=5)
if hits and hits[0].score > 0.8:
return 'knowledge', hits[0]
# 2) otherwise call web search (MCP) and DSPy reasoning
results = web_search.fetch(query)
return 'web', results
def generate_solution(query, context):
# Build prompt with retrieved context and call LLM orchestrator
prompt = build_prompt(query, context)
answer = llm_orchestrator.call(prompt)
return answer
def ingest_feedback(solution_id, rating, corrected_solution=None):
db.insert_feedback(solution_id, rating, corrected_solution)
if rating >= 4 and corrected_solution:
kb.upsert(corrected_solution)