Skip to content

NandeeshaHK/MathAgent_LF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Math Agent

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.

Features

  • 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 qwen3 4B 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-embed for generating high-quality embeddings for the Qdrant vector store.

Prerequisites

  • Python 3.10
  • Node.js and npm
  • An instance of Qdrant (local or cloud)
  • API keys for:
    • Google Gemini
    • Tavily

Installation and Setup

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-directory>
  2. Install uv (a fast Python package installer):

    pip install uv
  3. 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 
  4. Set up the Node.js server:

    npm install
  5. Configure Environment Variables: Create a .env file 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"
    

How to Use

  1. Start the Node.js server for KB management:

    node node_server.js
  2. Run the Langflow application:

    uv run langflow run
  3. Access the Langflow UI: Open your web browser and navigate to http://127.0.0.1:7860.

  4. Import the Flow: Import the Math Agent.json file into the Langflow interface to load the pre-built agent.

  5. Interact with the Agent: Use the chat interface in Langflow to ask the Math Agent your math-related questions.

Math Agent

Git Link for the Math Agent Frontend https://github.com/NandeeshaHK/quant-talk

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published