ApeAgent
ApeAgent is a framework created by Macaque Consulting to develop intelligent agents capable of executing specific functions (tools) sequentially or in parallel, while maintaining conversation context. This multi-agent approach is ideal for complex systems requiring efficient token usage and detailed process control..
Installation
pip install apeagent
Multi-Agent System Advantages
The multi-agent orchestration in ApeAgent optimizes token usage and enhances model accuracy in complex environments. Key benefits include:
- Token consumption reduction: Each agent uses only the necessary context for each query, optimizing costs and speed.
- Detailed process control: Specialized agents enable granular control and easy debugging, perfect for systems that require precise task management.
- Reduced hallucinations: By dividing tasks into specialized agents, the system minimizes incoherent or inaccurate responses.
- Capability for self-supervision or "judge" systems: You can include an agent to verify responses from other agents before presenting them to the user.
- Efficiency and parallelism: Agents can execute tasks in parallel and maintain context in long conversations.
Agent Configuration Parameters
When configuring an agent in ApeAgent, you can adjust its behavior through several parameters:
name: Agent name, without spaces.instructions: System role message that guides the agent (defines its purpose).functions: Tools or agents the agent can access, listed as a list.model: Model to use (currently integrates with OpenAI models).temperature: Controls the agent's response creativity.parallel_tool_calls: Allows the agent to run tools in parallel.memory_enabled: Allows the agent to keep conversation context.memory_max_conversations: Max number of interactions the agent stores in memory.debug: Enables console output for debugging.
Defining Tools
Tools are functions the agent can use to perform specific tasks. They must be defined with the @Agent.tool decorator and include typing and descriptive comments to help the model understand their purpose and use.
Simple Tool Example
from apeagent import Agent
from typing import Dict
@Agent.tool
def add(x: float, y: float) -> Dict[str, float]:
"""Adds two numbers and returns the result."""
return {"result": x + y}
Basic Agent Configuration
calculator_agent = Agent(
name="Calculator",
instructions="You are an agent that can perform simple mathematical operations.",
functions=[add],
model="gpt-4o",
temperature=0.0
)
Advanced Example: Multi-Agent System with Hierarchy
Tool for Weather Consultation
@Agent.tool
def get_weather(city: str) -> Dict[str, str]:
"""Provides current weather information for a specific city using the OpenWeather API."""
# Weather query implementation...
...
Configuring Specialized Agents and Main Agent
weather_agent = Agent(
name="Weather_Agent",
instructions="You are an agent specialized in providing weather information.",
functions=[get_weather],
model="gpt-4o",
temperature=0.0
)
main_agent = Agent(
name="Main_Agent",
instructions="You are a versatile assistant that can: 1. Provide weather information. 2. Perform mathematical operations.",
functions=[weather_agent, calculator_agent],
model="gpt-4o",
temperature=0.5,
parallel_tool_calls=True,
memory_enabled=True,
memory_max_conversations=40,
debug=True
)
Using the Main Agent
weather_query = "What's the weather like in Barcelona?"
weather_response = main_agent.call(weather_query)
print("Agent (weather):", weather_response)
add_query = "Add 7 and 5"
add_response = main_agent.call(add_query)
print("Agent (addition):", add_response)
Output Example
Agent (weather): The temperature in Barcelona is 20°C with clear skies.
Agent (addition): The result is 12.
Metadata
Release files for apeagent 0.1.0
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 |
|---|---|---|---|---|
| apeagent-0.1.0.tar.gz | 6.1 kB | Without provenance | Details for apeagent-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apeagent-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for apeagent-0.1.0-py3-none-any.whl |
Total release size: 12.3 kB
Release files / apeagent-0.1.0.tar.gz
| Download URL | apeagent-0.1.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2cae764fe19a24a2695d214afdd84a2ab686d8424b4d2997c3549281d072afe
|
|
BLAKE2b-256 checksum How to use checksums |
442424be3b4c6725006ecd5cd0c7c48bc9b10cbbaf18c8531b9d1d82f5e62b5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / apeagent-0.1.0-py3-none-any.whl
| Download URL | apeagent-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf305a91fb53a8f66abf19ec19c7902e890f60fa3adefdd55f3c2c4ab4ae8298
|
|
BLAKE2b-256 checksum How to use checksums |
3e6daae23965c7ae4c1dc713ae2b74f31eceb997d0ce335755645090a0d6a091
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for apeagent 0.1.0
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.