📍 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
- Open the Start menu and search for "Environment Variables"
- Click on "Edit the system environment variables"
- Click the "Environment Variables" button
- Under "System variables", click "New"
- Set the variable name as
OPENAI_API_KEY - Set the variable value as your OpenAI API key
- 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
- Open Terminal
- Edit your shell configuration file (e.g.,
~/.bash_profile,~/.zshrc) - Add the following line:
export OPENAI_API_KEY="your-api-key-here"```
- 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.
Metadata
Release files for routeagent 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| routeagent-0.2.5.tar.gz | 4.6 kB | Without provenance | Details for routeagent-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| routeagent-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for routeagent-0.2.5-py3-none-any.whl |
Total release size: 10.0 kB
Release files / routeagent-0.2.5.tar.gz
| Download URL | routeagent-0.2.5.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d8b734dfbccf0e10aba0227d86f8934418fde06708703c2560ef6aff9de2990
|
|
BLAKE2b-256 checksum How to use checksums |
fc5d0bb61a3c42c07fa28019815e5ca4559833016f97d76851b792fefce4ca92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1025-azure
|
Release files / routeagent-0.2.5-py3-none-any.whl
| Download URL | routeagent-0.2.5-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2145ea3c9233c5c02d36640b9ce4544694bcf80494347e7ff480829926ab7ffc
|
|
BLAKE2b-256 checksum How to use checksums |
ffd733ad0ccd90543967b6746d1a33c118e4e03f3cd54e0e094a2138c8bd2da4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1025-azure
|
Security for routeagent 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.