Skip to main content

A lightweight Python package for managing multi-agent orchestration. Easily define agents with custom instructions, tools, and models, and orchestrate their interactions seamlessly. Perfect for building modular, collaborative AI systems.

Project description

Agents Manager

PyPI version License: MIT Python Version Downloads

A lightweight Python package for managing multi-agent orchestration. Easily define agents with custom instructions, tools, and models, and orchestrate their interactions seamlessly. Perfect for building modular, collaborative AI systems.

Features

  • Define agents with specific roles and instructions
  • Assign models to agents (e.g., OpenAI models)
  • Equip agents with tools for performing tasks
  • Seamlessly orchestrate interactions between multiple agents

Supported Models

  • OpenAI
  • Grok
  • DeepSeek
  • Anthropic
  • Llama
  • Genai

Installation

Install the package via pip:

pip install agents-manager

Quick Start

from agents_manager import Agent, AgentManager
from agents_manager.models import OpenAi, Anthropic, Genai

from dotenv import load_dotenv

load_dotenv()

# Define the OpenAi model
openaiModel = OpenAi(name="gpt-4o-mini")

#Define the Anthropic model
anthropicModel = Anthropic(
        name="claude-3-5-sonnet-20241022",
        max_tokens= 1024,
        stream=True,
    )

#Define the Genai model
genaiModel = Genai(name="gemini-2.0-flash-001")

def multiply(a: int, b: int) -> int:
    """
    Multiply two numbers.
    """
    return a * b


def transfer_to_agent_3_for_math_calculation() -> Agent:
    """
    Transfer to agent 3 for math calculation.
    """
    return agent3


def transfer_to_agent_2_for_math_calculation() -> Agent:
    """
    Transfer to agent 2 for math calculation.    
    """
    return agent2

# Define agents
agent3 = Agent(
    name="agent3",
    instruction="You are a maths teacher, explain properly how you calculated the answer.",
    model=genaiModel,
    tools=[multiply]
)

agent2 = Agent(
    name="agent2",
    instruction="You are a maths calculator bro",
    model=anthropicModel,
    tools=[transfer_to_agent_3_for_math_calculation]
)

agent1 = Agent(
    name="agent1",
    instruction="You are a helpful assistant",
    model=openaiModel,
    tools=[transfer_to_agent_2_for_math_calculation]
)

# Initialize Agent Manager and run agent
agent_manager = AgentManager()
agent_manager.add_agent(agent1)

response = agent_manager.run_agent("agent1", "What is 2 multiplied by 3?")
print(response["content"])

You can run for stream response as well.

response_stream = agent_manager.run_agent_stream("agent1", [
    {"role": "user", "content": "What is 2 multiplied by 3?"},
])
for chunk in response_stream:
    print(chunk["content"], end="")

You can also run the agent with a dictionary as the input content.

response = agent_manager.run_agent("agent1", {"role": "user", "content": "What is 2 multiplied by 3?"})

You can also run the agent with a list of history of messages as the input.

response = agent_manager.run_agent("agent1", [
    {"role": "user", "content": "What is 2 multiplied by 3?"},
])

More models

from agents_manager.models import Grok, DeepSeek, Llama

#Define the Grok model
modelGrok = Grok(name="grok-2-latest")


#Define the DeepSeek model
modelDeepSeek = DeepSeek(name="deepseek-chat")


#Define the Llama model
modelLlama = Llama(name="llama3.1-70b")

Troubleshooting

While using Genai model with functions, if you get the following error:

google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties: should be non-empty for OBJECT type\n', 'status': 'INVALID_ARGUMENT'}}

It is because google genai does not support functions without parameters. You can fix this by providing a dummy parameter. Please let me know if you have a better solution for this.

How It Works

  1. Define Agents: Each agent has a name, a specific role (instruction), and a model.
  2. Assign Tools: Agents can be assigned tools (functions) to perform tasks.
  3. Create an Agent Manager: The AgentManager manages the orchestration of agents.
  4. Run an Agent: Start an agent to process a request and interact with other agents as needed.

Use Cases

  • AI-powered automation systems
  • Multi-agent chatbots
  • Complex workflow orchestration
  • Research on AI agent collaboration

Contributing

Contributions are welcome! Feel free to submit issues and pull requests.

License

MIT License

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

agents_manager-1.1.7.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

agents_manager-1.1.7-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file agents_manager-1.1.7.tar.gz.

File metadata

  • Download URL: agents_manager-1.1.7.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for agents_manager-1.1.7.tar.gz
Algorithm Hash digest
SHA256 c5dd75c4e1e0de332bd938a0b16c0c489f42bc722195a287acc2c93bd0a6ba18
MD5 ea7781e69d51dc1aa9ca2cb16052abb9
BLAKE2b-256 898c3b7061417bbadfd429fa942385d6001c4a6b6d230373ce939ccb64ee34c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for agents_manager-1.1.7.tar.gz:

Publisher: publish-to-pypi.yml on sandeshnaroju/agents_manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agents_manager-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: agents_manager-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for agents_manager-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 38a29bc4d748614d407269cf2b90ae877e358e4369484cb9b940a210e13505ab
MD5 5d002d8bc66bb4c634cb0af9355d2680
BLAKE2b-256 588526b5e4b16b4601d6e6d97bbe4cea4b100534402cae1a3a5e1ddf3d30551a

See more details on using hashes here.

Provenance

The following attestation bundles were made for agents_manager-1.1.7-py3-none-any.whl:

Publisher: publish-to-pypi.yml on sandeshnaroju/agents_manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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