A modular multi-agent-system designed to integrate seamlessly into e-learning platforms, acting as a smart learning assistant. It consists of:
- ๐ Supervisor / Router Node โ Directs incoming requests to the most suitable worker / agent / node for processing.
- ๐ Self-Corrective RAG Agent โ Retrieves and generates answers by first searching internal documents. If no results are found, it rewrites the query; if still no relevant results appear, it falls back to web search, and finally verifies its own output against sources to combat hallucinations.
- ๐ง Long-Term Memory Node โ Extracts personal information from learner interactions, enabling valuable analytics for educators and platform owners.
- ๐ Computations Node โ Performs basic algebra calculations today, with planned upgrades to handle calculus operations such as integration and differentiation for STEM learners.
- Self-Corrective_RAG sub-graph in action: https://youtu.be/9tdjUe1EOGM
- (Web-Fallback) Self-Corrective_RAG sub-graph in action: https://youtu.be/Z460EwiRhe8
- Long-Term User Memory module in action: https://youtu.be/lDHMzpfKkjI
- Calculators node in action: https://youtu.be/ZLCACAmxWRE
This project is a highly capable intelligent agent system designed to reason, calculate, learn from interactions, and provide accurate answers through an advanced retrieval-augmented generation (RAG) pipeline.
It consists of several key components:
- Supports arithmetic operations using dedicated subagents.
- Validates results to ensure accuracy.
- Captures, stores, and updates structured user profile data across sessions.
- Example memory schema:
class Profile(BaseModel):
"""Represents structured user profile information."""
name: Optional[str] = Field(description="User's name", default=None)
bachelor: Optional[str] = Field(description="Bachelor's degree subject", default=None)
master: Optional[str] = Field(description="Master's degree subject", default=None)
phd: Optional[str] = Field(description="PhD subject", default=None)
connections: list[str] = Field(description="User's personal connections (friends, family, coworkers)", default_factory=list)
interests: list[str] = Field(description="User's interests", default_factory=list)Stored using a combination of:
- ๐๏ธ In-memory store (for session-based reasoning)
- ๐ PostgreSQL (for persistent cross-session memory)
A subgraph agent responsible for:
-
Retrieving relevant documents
-
Generating an answer
-
Checking for hallucinations
-
If hallucinated:
- Attempts regeneration or query reformulation (up to a configurable retry limit)
- Falls back to web search if needed
git clone https://github.com/your-org/multi-agent-system.git
cd multi-agent-systempip install -r requirements.txtMake sure you have:
- Python 3.11+
- PostgreSQL running and accessible
- Environment variables set (e.g. OpenAI API keys, etc.)
After cloning the repository and installing dependencies, launch the agent using:
langgraph devThis will open the agent in your browser via LangGraph Studio, providing a full interactive environment. You can test the entire agent pipeline โ from memory capture to calculations and RAG-based responses. All local code changes will be reflected live in the Studio session. All required dependencies are already included in the provided requirements.
The main entry point for this system is the compiled LangGraph agent. Here's a basic example of how to interact with it programmatically:
from langchain_core.messages import HumanMessage
config = {"configurable": {"thread_id": "1", "user_id": "1"}}
# Example user message to initiate profile memory
input_messages = [HumanMessage(content="Hi my name is Lance.")]
# Run the graph
for chunk in graph.stream({"messages": input_messages}, config, stream_mode="values"):
chunk["messages"][-1].pretty_print()user_id: used to isolate memory and personalize responsesretries: max attempts for the RAG agentweb_fallback: toggle fallback behavior
- Retrieve documents
- Generate candidate answer
- Validate for hallucination
- Retry / reformulate
- Fallback to web search
- Return the final answer
Automatically extracts and stores:
- Academic history
- Interests
- Social graph
- Conversational tutoring agent with memory
- Personal knowledge assistant
- Domain-specific customer support
- Adaptive recommendation systems
- ๐ Python
- ๐ง OpenAI GPT (via
langchain_openai) - ๐ ๏ธ LangGraph & LangChain
- ๐ฆ Pydantic
- ๐ PostgreSQL
- ๐ TrustCall Extractor
- GUI interface with streamlit or FastAPI
- Additional calculator tools (e.g., statistics, matrix math)
- Real-time memory editing via API
Pull requests are welcome! For major changes, please open an issue first to discuss what youโd like to change.
- [Ans IMRAN]