-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Open
Copy link
Labels
Description
Summary
Refactor the RAG4EIC codebase to use LangGraph instead of LangChain for orchestrating the LLM workflow. LangGraph enables more flexible, graph-based workflows using nodes, edges, and tool calls. This will improve modularity, maintainability, and enable advanced RAG behaviors (e.g., conditional tool use, branching, multi-hop reasoning).
Requirements
- Replace LangChain chains/runnables with LangGraph graphs (nodes and edges):
- Each node represents an atomic operation (e.g., LLM prompt, retriever, tool call, response formatting)
- Edges control data flow and can branch based on conditions (e.g., decide whether to call a retriever or respond directly)
- Integrate tool calls (e.g., retrieval, calculator, custom tools) within the graph
- Support for:
- User message input node
- Decide node (determine if retrieval is needed)
- Retriever node(s) (arxiv, indico, or both)
- LLM response node
- Tool-calling node (for advanced queries)
- Output formatting node
- Ensure all existing RAG features are mapped to graph nodes/edges (e.g., feedback, trace logging, source attribution)
Implementation Plan
-
Research LangGraph
- Review LangGraph documentation and examples
- Understand node/edge API and tool call patterns
-
Design the Graph Structure
- Draw out the flow as a directed graph:
- Start → User Input Node → Decide Node
- If retrieval needed → Retriever Node(s) → LLM Node → Output Node
- If not → LLM Node → Output Node
- Add tool call node for specialized tools (e.g., calculator, DB query)
- Start → User Input Node → Decide Node
- Allow branching for arxiv/indico/both retrievers based on user selection
- Add nodes for logging, feedback, and error handling
- Draw out the flow as a directed graph:
-
Refactor Chains to Graph Nodes
- Convert each "chain" or function in LangChain to a node in LangGraph
- Wire up edges for data flow, including conditional branches (if/else)
-
Integrate Tool Calls
- Implement tool-calling pattern per LangGraph's API (e.g., for retrieval, calculators, or custom actions)
- Register tools and expose them as nodes in the graph
-
Testing & Migration
- Write unit/integration tests for each node and the overall graph
- Ensure all features work as before (or better)
- Migrate streamlit UI to use LangGraph backend
-
Documentation
- Document the new architecture and graph structure
- Add diagrams showing node/edge layout
- Provide migration/usage instructions for contributors
References
- LangGraph GitHub
- LangGraph Docs
- LangChain to LangGraph migration guide
- Existing chains in
LangChainUtils/LLMChains.pyandpages/2_RAG-ChatBot.py
Future Improvements
- Add more tool call support (e.g., web search, citation generator)
- Enable multi-agent or multi-hop reasoning via graph branches
- Visualize the workflow graphically in documentation or UI
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Todo