A modern Python framework for building intelligent AI agents with advanced tracing, history management, and seamless LLM integration
Project description
Peargent
A modern Python framework for building intelligent AI agents with advanced tracing, history management, and seamless LLM integration.
Features
- Advanced Tracing - Track every action, decision, and API call with detailed telemetry and database persistence
- Smart History Management - Built-in conversation history with intelligent context windowing and buffer management
- Multi-LLM Support - Seamlessly switch between OpenAI, Anthropic, Groq, and more
- Type-Safe Tools - Pydantic-powered tool system with automatic validation
- Agent Pools - Run multiple agents concurrently with shared context
- Streaming Support - Real-time streaming responses with event handling
- Cost Tracking - Monitor token usage and costs across all LLM providers
Installation
pip install peargent
Optional Dependencies
For PostgreSQL database tracing:
pip install peargent[postgresql]
Quick Start
Basic Agent
from peargent import create_agent
from peargent.models import groq
agent = create_agent(
name="assistant",
persona="You are a helpful AI assistant.",
model=groq("llama-3.3-70b-versatile")
)
result = agent.run("What is the capital of France?")
print(result)
Agent with Tools
from peargent import create_agent, tool
from peargent.models import openai
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"The weather in {city} is sunny and 72 degrees F"
agent = create_agent(
name="weather_bot",
persona="You are a weather assistant.",
model=openai("gpt-4"),
tools=[get_weather]
)
result = agent.run("What's the weather in San Francisco?")
print(result)
Database Tracing
from peargent import create_agent
from peargent.models import openai
from peargent.telemetry import DatabaseTracer
# SQLite
tracer = DatabaseTracer(
db_type="sqlite",
db_path="./traces.db"
)
agent = create_agent(
name="traced_agent",
persona="You are a helpful assistant.",
model=openai("gpt-4o"),
tracer=tracer
)
result = agent.run("Explain quantum computing")
# All traces automatically saved to database
Streaming Responses
from peargent import create_agent
from peargent.models import openai
agent = create_agent(
name="streaming_agent",
persona="You are a helpful assistant.",
model=openai("gpt-4o")
)
for chunk in agent.stream("Tell me a story"):
print(chunk, end="", flush=True)
Agent Pools
from peargent import AgentPool
from peargent.models import openai, groq
pool = AgentPool(
agents=[
{"name": "researcher", "persona": "Research expert", "model": openai("gpt-4o")},
{"name": "writer", "persona": "Content writer", "model": groq("llama-3.3-70b-versatile")}
]
)
results = pool.run_all("Explain artificial intelligence")
for agent_name, result in results.items():
print(f"{agent_name}: {result}")
Core Concepts
Agents
Agents are autonomous entities that can process requests, use tools, maintain conversation history, and interact with LLMs.
Tools
Tools are Python functions decorated with @tool that agents can call. They're automatically validated using Pydantic schemas.
Tracing
The telemetry system tracks all agent activities including LLM calls, tool usage, token consumption, and costs. Traces can be saved to SQLite or PostgreSQL databases.
History Management
Built-in conversation history with configurable buffer sizes, context windowing, and automatic truncation strategies.
Models
Unified interface for multiple LLM providers:
openai()- OpenAI modelsanthropic()- Anthropic Claude modelsgroq()- Groq models- More providers coming soon
Documentation
Full documentation is available at [your-docs-url-here]
Examples
Check out the /examples directory for more comprehensive examples:
- Multi-agent pools
- Database tracing
- Streaming responses
- Custom tools
- Cost tracking
- And more!
Requirements
- Python >= 3.9
- requests >= 2.31
- python-dotenv >= 1.0
- pydantic >= 2.0
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Created by Quanta-Naut
Links
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file peargent-0.1.0.tar.gz.
File metadata
- Download URL: peargent-0.1.0.tar.gz
- Upload date:
- Size: 67.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
986fa892d93cb7a99f0f990cc22fcbb381d6fd622d3aac7c6c8ce1c62228e4a9
|
|
| MD5 |
6ae1fe4ba6d55dcb8aaf112f8402bd5f
|
|
| BLAKE2b-256 |
d9ed0fbc5860c66c61f4ac4157f363d5c4239760884e6c3aed080a8e755b9f93
|
File details
Details for the file peargent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: peargent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 84.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7435643228fbf6d9ad34b7e3bf5ba7517b45c4e78fa0225a44415732b64e097
|
|
| MD5 |
657a3a5359421ad33efce5ba320622f0
|
|
| BLAKE2b-256 |
4cd1b8a8f407c5534302df760fb92f3e1dfd0f5233d723dac8575490615a1873
|