How langchain-ai/retrieval-agent-template works
Project type and purpose
• This is a template “retrieval agent” built on LangGraph. It’s not a traditional full-stack web app but rather a graph-based chat bot service that:
• Indexes user documents into a vector store (“index graph”)
• Maintains chat state and retrieves context on user queries (“retrieval graph”)
• Leverages external vector DBs (Elastic, MongoDB Atlas, Pinecone) and LLM APIs (OpenAI, Anthropic, Cohere)
File structure
• Top-level: configuration & metadata (.env.example, pyproject.toml, Makefile, GitHub workflows)
• src/retrieval_graph/ – core Python modules:
• configuration.py – loads .env into config objects
• graph.py – graph definitions (indexer & retrieval graphs)
• index_graph.py – indexer-specific logic
• retrieval.py – retrieval-specific orchestration
• prompts.py, utils.py, state.py, graph.py – prompt templates, helpers, conversation state
• static/ – screenshots for documentation
• tests/ – unit & integration tests
Key insights from the README
• Two distinct graphs:
a. Index Graph: receives documents, embeds, persists via vector store
b. Retrieval Graph: receives user query, refines via query_model, fetches similar docs from vector store (filtered by user_id), generates answer via response_model
• Configurable providers for storage (elastic, mongodb, pinecone) and models (embedding, query, response)