← BACK

multi-agent-system

Python ⭐ 0

Multi-Agent AI Orchestration System

This project is a multi-agent AI system designed to handle user requests by coordinating between different specialized AI agents. It demonstrates a hierarchical architecture, intent recognition, and robust error handling.


🏛️ Architecture

This system uses a three-level hierarchical agent architecture:

  • Level 1 (Super Agent): The central orchestrator. [cite_start]It receives user requests, delegates tasks to mid-level agents, and returns the final response. [cite: 12]
  • Level 2 (Mid-Level Agents):
    • [cite_start]Intent Analysis Agent: Interprets the user's natural language query to determine their goal (intent) and key information (entity). [cite: 14]
    • [cite_start]Error Monitoring Agent: Logs any errors that occur within the system to a file for later review. [cite: 15]
  • [cite_start]Level 3 (Task Agents): Worker agents that perform specific, predefined operations. [cite: 16]

Communication Flow

The communication flows from top to bottom and back up.

graph TD
    User -->|Request| A[L1: Super Agent];
    A -->|"What's the intent?"| B[L2: Intent Agent];
    B -->|"Intent: get_weather<br/>Entity: London"| A;
    A -->|"Get weather for London"| C[L3: Weather Agent];
    C -->|API Call| D[External Weather API];
    C -.->|Logs Error| E[L2: Error Monitoring Agent];
    D -->|Weather Data| C;
    C -->|Weather Info| A;
    A -->|Final Response| User;

(This is a Mermaid diagram. It will render automatically on platforms like GitHub.)


✨ Features Implemented

  • [cite_start]Hierarchical Agent System: A three-level architecture for clear separation of concerns. [cite: 23]
  • [cite_start]Natural Language Intent Recognition: Uses the Groq LLM to understand user queries and map them to appropriate agents. [cite: 27]
  • Dynamic Task Routing: The Super Agent dynamically calls the correct task agent based on the recognized intent.
  • [cite_start]Centralized Error Logging: A dedicated Error Monitoring Agent captures and logs failures from other agents. [cite: 31]
  • Expandable Agent Registration: New task agents can be added easily using a simple decorator, requiring no changes to the core system logic.
  • Implemented Task Agents:
    • [cite_start]get_weather: Retrieves current weather for a specified location. [cite: 17]
    • [cite_start]get_news: Fetches the latest news headlines for a given topic. [cite: 18]

🚀 Setup and Installation

  1. Clone the repository:

    git clone <your-repo-url>
    cd multi-agent-system
    
  2. Create and activate a virtual environment:

    python -m venv venv
    # On Windows: venv\Scripts\activate
    # On macOS/Linux: source venv/bin/activate
    
  3. Install the required dependencies:

    pip install -r requirements.txt
    
  4. Configure API keys:

    • Create a file named .env in the root directory.
    • Add your API keys to the .env file:
      GROQ_API_KEY="YOUR_GROQ_API_KEY"
      WEATHER_API_KEY="YOUR_OPENWEATHERMAP_API_KEY"
      NEWS_API_KEY="YOUR_NEWS_API_KEY"
      
  5. Run the application:

    python main.py
    

🎬 Demo

(You will add a link to your demo video here later)