This project implements a sophisticated Math Agent using Langflow. The agent is designed to solve mathematical problems by leveraging a combination of a local knowledge base, web search capabilities, and powerful language models.
- Knowledge Base: Utilizes a Qdrant vector store to maintain a persistent knowledge base of math problems and their solutions.
- Web Search: Integrates with the Tavily API for real-time web searches when a solution is not found in the local knowledge base.
- Advanced Language Models: Powered by Google's Gemini Flash 2.0, capable of handling large input tokens for complex problems. It initially used Groq providers with Llama 4 Scout.
- Guardrails:
- An input guardrail, using a system prompt, ensures the agent only responds to math-related queries.
- A
qwen34B model is used for output guardrails, leveraging its local tool-calling capabilities.
- Human-in-the-Loop: Includes a review process for users to validate and approve new solutions before they are added to the knowledge base.
- KB Management: A Node.js server with dedicated endpoints manages fetching and updating the knowledge base from a JSON file.
- Embeddings: Uses
nomic-embedfor generating high-quality embeddings for the Qdrant vector store.
- Python 3.10
- Node.js and npm
- An instance of Qdrant (local or cloud)
- API keys for:
- Google Gemini
- Tavily
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install
uv(a fast Python package installer):pip install uv
-
Create a virtual environment and install Python dependencies:
uv venv source .venv/bin/activate # On Windows use `.venv\Scripts\activate` uv pip install -U langflow
-
Set up the Node.js server:
npm install
-
Configure Environment Variables: Create a
.envfile in the root of the project and add your API keys:GEMINI_API_KEY="your_gemini_api_key" TAVILY_API_KEY="your_tavily_api_key" QDRANT_URL="your_qdrant_instance_url" QDRANT_API_KEY="your_qdrant_api_key"
-
Start the Node.js server for KB management:
node node_server.js
-
Run the Langflow application:
uv run langflow run
-
Access the Langflow UI: Open your web browser and navigate to
http://127.0.0.1:7860. -
Import the Flow: Import the
Math Agent.jsonfile into the Langflow interface to load the pre-built agent. -
Interact with the Agent: Use the chat interface in Langflow to ask the Math Agent your math-related questions.
Git Link for the Math Agent Frontend
https://github.com/NandeeshaHK/quant-talk