Skip to main content

RouteAgent is a lightweight Python library that optimizes AI task performance by intelligently routing prompts to specialized LLM agents. Building on the concept of RouteLLM, it leverages multi-agent systems to enhance accuracy in AI applications.

Project description

📍 RouteAgent: Route Queries to AI Agents

RouteAgent is a lightweight Python library that optimizes AI task performance by intelligently routing prompts to specialized LLM agents. Building on the concept of RouteLLM, it leverages multi-agent systems to enhance accuracy in AI applications.

🚀 Quick Start

Before you start Routing and Managing Multi-Agent workflows, make sure that your Open AI API key is set up. if not follow the instructions below to set up your API key.

🔑 Setting Up Your API Key

Choose your operating system and follow the instructions:

💻 Windows
  1. Open the Start menu and search for "Environment Variables"
  2. Click on "Edit the system environment variables"
  3. Click the "Environment Variables" button
  4. Under "System variables", click "New"
  5. Set the variable name as OPENAI_API_KEY
  6. Set the variable value as your OpenAI API key
  7. Click "OK" to save

Alternatively, you can use the command prompt:

setx OPENAI_API_KEY "your-api-key-here"

Remember to restart your command prompt after setting the variable!

🍎 macOS and Linux
  1. Open Terminal
  2. Edit your shell configuration file (e.g., ~/.bash_profile, ~/.zshrc)
  3. Add the following line:
    export OPENAI_API_KEY="your-api-key-here"```
    
  4. Save the file and run:
    source ~/.bash_profile
    

or ( if you are using Zsh)

source ~/.zshrc

📦 Installation

pip install routeagent

📝 Example Usage

from routeagent import Router


def maths_tutor(prompt: str):
    # Add your Maths Tutor Logic here - Use Rag Workflows, Function Calls, etc
    return f"""
    Activated the Maths Tutor
    The Prompt was {prompt}
    """


def science_tutor(prompt: str):
    # Add your Science Tutor Logic here - Use Rag Workflows, Function Calls, etc
    return f"""
    Activated the Science Tutor
    The Prompt was {prompt}
    """


controller = Router(
    model="gpt-4o", # Optional - The Model to use for the Router
    agent_1=maths_tutor,
    description_1="The agent is specifically designed to answer maths questions and excels in doing so",
    agent_2=science_tutor,
    description_2="The agent is specifically designed to answer science ( Biology, Chemistry, Physics)"
                  " questions and excels in doing so"
) # The Router Class is used to route prompts to the respective agents

response = controller("What is meant by dy/dx?")
print(response)

The Router class takes in two types of arguments, agent and description. The agent is the functions that will be called with exactly one parameter, that is the prompt. The description is the description of the agent that will be used in the decision making process of which agent to route the prompt to.

Note: The Router class can take in any number of agents and descriptions, but the minimum number of agents and descriptions should be 2. The agents and descriptions should be passed in the format of agent_(num) and description_(num). The number given to description and agent should be the same for a particular agent

Tutorial

How to Use RouteAgent: A Guide to Intelligent AI Task Routing

🤔 Questions? Issues?

If you encounter any problems or have questions about the improvements RouteAgent suggests, feel free to open an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

routeagent-0.2.5.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

routeagent-0.2.5-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file routeagent-0.2.5.tar.gz.

File metadata

  • Download URL: routeagent-0.2.5.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1025-azure

File hashes

Hashes for routeagent-0.2.5.tar.gz
Algorithm Hash digest
SHA256 1d8b734dfbccf0e10aba0227d86f8934418fde06708703c2560ef6aff9de2990
MD5 305827b1cb752d9d1124c858898b4d4b
BLAKE2b-256 fc5d0bb61a3c42c07fa28019815e5ca4559833016f97d76851b792fefce4ca92

See more details on using hashes here.

File details

Details for the file routeagent-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: routeagent-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1025-azure

File hashes

Hashes for routeagent-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2145ea3c9233c5c02d36640b9ce4544694bcf80494347e7ff480829926ab7ffc
MD5 6c763fb08eb0e1ae33d8bb1ccf81d2e7
BLAKE2b-256 ffd733ad0ccd90543967b6746d1a33c118e4e03f3cd54e0e094a2138c8bd2da4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page