Agent Pipeline

How a question flows through AgentIQ's LangGraph agent, from routing decision to streamed, cited answer.

Architecture

User Query
Natural language question, 1–2000 characters
Router Node
GPT-4o-mini classifies the query as retrieval, web_search, or direct — a single-word decision, no explanation.
One of three paths, by route decision
FAISS Retrieval
Local vector search over ~30 AI/ML research documents, embedded with all-MiniLM-L6-v2. Top chunks by cosine similarity feed the generator as grounded context.
Tavily Web Search
Live web search for time-sensitive or current-events questions — news, recent releases, anything that changes over time.
Direct LLM
GPT-4o-mini answers conversational or general-knowledge questions directly from training data, no retrieval step.
Generator Node
Synthesises retrieved context (or answers directly, for the direct route) into a grounded response, citing sources inline by title. Direct-route answers skip this node and stream straight from the router's downstream LLM call.
Streamed Response
Server-Sent Events over POST /chat/stream — token chunks, then a sources list, then a done signal — rendered progressively in the chat UI.

Memory & Observability

Session Memory
A LangGraph MemorySaver checkpoints every turn, keyed by session_id, giving each conversation full multi-turn history. It's process-local — memory resets if the API process restarts.
Reference-only components
The backend repo also includes standalone Pinecone and LlamaIndex implementations (retrieval/pinecone_store.py, retrieval/llamaindex_loader.py). Neither is wired into this graph — FAISS is the only vector backend the live agent queries.

Technology Stack

ComponentTechnologyNotes
Agent OrchestrationLangGraphStateGraph with conditional routing edges
Router / Generator LLMGPT-4o-miniClassifies intent, then synthesises the cited answer
Embeddingsall-MiniLM-L6-v2sentence-transformers, used to build the FAISS index
Vector StoreFAISSLocal index over the research-paper corpus
Web SearchTavily Search APILive results for current-events queries
MemoryLangGraph MemorySaverProcess-local, keyed by session_id — multi-turn history per session
APIFastAPIPOST /chat (JSON) and POST /chat/stream (SSE)