Skip to main content

A lightweight LLM orchestration framework for building Multi-Agent AI systems.

Project description

microAgents Framework

A lightweight LLM orchestration framework for building Multi-Agent AI systems. The framework provides an easy way to create and orchestrate multiple AI agents with XML-style tool calls.

Key Features

🚀 Universal Tool Calling Support

  • Works with ANY LLM API that follows OpenAI-compatible format
  • Unique Feature: Enables function/tool calling even with models that don't natively support it
  • XML-based tool calling format that's intuitive and human-readable

Framework Comparison

Framework Core Abstractions Size & Complexity Dependencies & Integration Key Advantages Limitations/Trade-offs
LangChain Agent, Chain 405K LOC
+166MB
Many vendor wrappers
(OpenAI, Pinecone, etc)
Many app wrappers (QA, Summarization)
Rich ecosystem
Extensive tooling
Large community
Heavy footprint
Complex setup
JSON schema based
CrewAI Agent, Chain 18K LOC
+173MB
Many vendor & app wrappers
(OpenAI, Anthropic, etc)
Role-based agents
Built-in collaboration
Complex hierarchies
Heavy dependencies
SmolAgent Agent 8K LOC
+198MB
Some integrations
(DuckDuckGo, HuggingFace)
Simplified agent design Limited tool ecosystem
Large package size
LangGraph Agent, Graph 37K LOC
+51MB
Some DB integrations
(PostgresStore, SqliteSaver)
Graph-based flows
DAG support
Complex DAG definitions
JSON schema based
AutoGen Agent 7K LOC
+26MB (core)
Optional integrations
(OpenAI, Pinecone)
Lightweight core
Modular design
Limited built-in tools
microAgents Agent, Tool ~2K LOC
<1MB
Minimal
(requests, urllib3)
✓ Universal tool calling
✓ XML-based format
✓ Ultra lightweight
✓ Simple integration
✓ Any OpenAI-compatible LLM
Bring your own tools
No built-in vendors

Key Differentiators

  • Ultra Lightweight: microAgents is <1MB, compared to hundreds of MB for other frameworks
  • Universal Compatibility: Works with any OpenAI-compatible API endpoint
  • XML Tool Calls: More readable and intuitive than JSON schemas
  • Minimal Dependencies: Only core HTTP libraries required
  • Simple Integration: Direct function integration without wrapper classes
  • LLM Agnostic: Works with any LLM that follows OpenAI's API format, including those without native function calling

Installation

You can install microAgents directly from PyPI:

pip install microAgents

Or install from source for development:

git clone https://github.com/prabhjots664/MicroAgents.git
cd MicroAgents
pip install -e .

Quick Start

Here's a complete example showing how to create a multi-agent math system:

from microAgents.llm import LLM
from microAgents.core import MicroAgent, Tool, MessageStore

# Initialize LLM with your API
llm = LLM(
    base_url="https://api.hyperbolic.xyz/v1",
    api_key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJrYW1hbHNpbmdoZ2FsbGFAZ21haWwuY29tIiwiaWF0IjoxNzM1MjI2ODIzfQ.1wZmIzTZUWLzr-uP7Qtib_kkXNZmH_yQtSn1lP9S2z0",
    model="Qwen/Qwen2.5-Coder-32B-Instruct",
    max_tokens=4000,
    temperature=0.8,
    top_p=0.9
)

# Define tools for basic math operations
def add_numbers(a: float, b: float) -> float:
    return a + b

def multiply_numbers(a: float, b: float) -> float:
    return a * b

# Create specialized agents
math_agent = MicroAgent(
    llm=llm,
    prompt="You are a math assistant. Handle basic arithmetic operations.",
    toolsList=[
        Tool("add", "Add two numbers", add_numbers),
        Tool("multiply", "Multiply two numbers", multiply_numbers)
    ]
)

# Create message store for conversation history
message_store = MessageStore()

# Use the agent
response = math_agent.execute_agent(
    "First add 3 and 5, then multiply the result by 2", 
    message_store
)
print(response)

Multi-Agent Orchestration Example

Here's an example of creating multiple specialized agents and orchestrating them:

from microAgents.llm import LLM
from microAgents.core import MicroAgent, Tool, MessageStore

# Initialize LLM
llm = LLM(
    base_url="https://api.hyperbolic.xyz/v1",
    api_key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJrYW1hbHNpbmdoZ2FsbGFAZ21haWwuY29tIiwiaWF0IjoxNzM1MjI2ODIzfQ.1wZmIzTZUWLzr-uP7Qtib_kkXNZmH_yQtSn1lP9S2z0",
    model="Qwen/Qwen2.5-Coder-32B-Instruct",
    max_tokens=4000,
    temperature=0.8,
    top_p=0.9
)

# Define tools for different agents
def add_numbers(a: float, b: float) -> float:
    return a + b

def multiply_numbers(a: float, b: float) -> float:
    return a * b

def factorial(n: int) -> int:
    if n == 0:
        return 1
    return n * factorial(n - 1)

# Create specialized agents
simple_math_agent = MicroAgent(
    llm=llm,
    prompt="You are a simple math assistant. Handle basic arithmetic operations.",
    toolsList=[
        Tool("add", "Add two numbers", add_numbers),
        Tool("multiply", "Multiply two numbers", multiply_numbers)
    ]
)

advanced_math_agent = MicroAgent(
    llm=llm,
    prompt="You are an advanced math assistant. Handle complex math operations.",
    toolsList=[
        Tool("factorial", "Calculate factorial", factorial)
    ]
)

# Create an orchestrator agent
class Orchestrator(MicroAgent):
    def __init__(self):
        super().__init__(
            llm=llm,
            prompt="""You are a math query analyzer. For each query:
1. If it contains basic arithmetic, output exactly: SIMPLE_MATHS NEEDED
2. If it contains advanced math, output exactly: ADVANCED_MATHS NEEDED
3. If unsure, output exactly: UNKNOWN_MATH_TYPE""",
            toolsList=[]
        )
        self.simple_math_agent = simple_math_agent
        self.advanced_math_agent = advanced_math_agent

    def execute_agent(self, query: str, message_store: MessageStore) -> str:
        # Get initial analysis from orchestrator
        analysis = super().execute_agent(query, message_store)
        
        if "SIMPLE_MATHS NEEDED" in analysis:
            result = self.simple_math_agent.execute_agent(query, message_store)
            return f"Simple Math Agent: {result}"
        elif "ADVANCED_MATHS NEEDED" in analysis:
            result = self.advanced_math_agent.execute_agent(query, message_store)
            return f"Advanced Math Agent: {result}"
        else:
            return "Unable to determine the appropriate agent for this query."

# Use the orchestrated system
message_store = MessageStore()
orchestrator = Orchestrator()

# Example queries
queries = [
    "What is 15 plus 27?",  # Will use simple_math_agent
    "Calculate 5 factorial",  # Will use advanced_math_agent
    "First add 3 and 5, then multiply the result by 2"  # Will use simple_math_agent
]

for query in queries:
    response = orchestrator.execute_agent(query, message_store)
    print(f"Query: {query}")
    print(f"Response: {response}\n")

This example demonstrates:

  • Creating multiple specialized agents with different tools
  • Building an orchestrator agent to route queries
  • Using a message store to maintain conversation history
  • Coordinating multiple agents to handle different types of tasks

Examples

  • math_demo.py: Basic math operations using tool calls

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

microagents-1.3.3.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

microagents-1.3.3-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file microagents-1.3.3.tar.gz.

File metadata

  • Download URL: microagents-1.3.3.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for microagents-1.3.3.tar.gz
Algorithm Hash digest
SHA256 5e47cd902f515a37f7ce07c6925653e5cdda2da045ee2bbb2334b67cadb821ec
MD5 98fc9b03485c3afaa0ba8578b90b0817
BLAKE2b-256 0f5cd28e93ec57826181ddf6defa5f1638c2058b360a4c9cb617355cb0b92c44

See more details on using hashes here.

File details

Details for the file microagents-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: microagents-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for microagents-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9dc2e63154b17319e922a614d2114d54aa42773e3da146626254838516a32e5b
MD5 b83e52bdb702a95934628e5cc24bf871
BLAKE2b-256 fca03334676b4d27e2b203b77caa06776efb2c6570890f44bac6e743f44f14c3

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