A framework for creating AI agents.
Project description
Agenty
A Pythonic framework for building AI agents and LLM pipelines, powered by pydantic-ai. The framework emphasizes simplicity and maintainability without sacrificing power, making it an ideal choice for rapid prototyping.
[!Caution] Initial Development: Agenty is under active development. Expect frequent breaking changes until we reach a stable release.
Agenty provides a clean, type-safe interface for creating:
- Conversational AI agents with structured inputs and outputs
- LLM pipelines
- Complex agent interactions with minimal boilerplate
Key Features
- Intuitive Pythonic interfaces that feel natural to use
- Structured Agent I/O for predictable behavior
- Agent Pipelines to enable sequential workflows
- Jinja2 templates for prompts and messages for dynamic context
- Built on pydantic-ai for type validation
- Automatic conversation history management
The framework is currently only officially tested with the OpenAI API (through a proxy such as LiteLLM/OpenRouter) although theoretically it supports all the models supported by pydantic-ai.
[!TIP] Looking for a more mature alternative? Check out atomic-agents, which heavily inspired this project.
Installation
pip install agenty
Or with uv:
uv add agenty
Quick Preview
Here's a simple example to get started:
import asyncio
from agenty import Agent
from pydantic_ai.models.openai import OpenAIModel
async def main():
agent = Agent(
model=OpenAIModel(
"gpt-4o",
api_key="your-api-key"
),
system_prompt="You are a helpful and friendly AI assistant."
)
response = await agent.run("Hello, how are you?")
print(response)
asyncio.run(main())
In most cases, to build a custom AI agent, you'll want to create your own class that inherits from Agent. The below is functionally equivalent to the above code (and is the recommended way to use this framework)
import asyncio
from agenty import Agent
from pydantic_ai.models.openai import OpenAIModel
class Assistant(Agent):
model = OpenAIModel("gpt-4o", api_key="your-api-key")
system_prompt = "You are a helpful and friendly AI assistant."
async def main():
agent = Assistant()
response = await agent.run("Hello, how are you?")
print(response)
asyncio.run(main())
Simple Tools
Functions can be used as tools through a simple decorator pattern.
-
Define Your Agent: Create a custom class that inherits from the base Agent class.
-
Implement Tool Methods: Add methods to your agent class that will serve as tools. Each method should include a docstring that describes the tool. You can even add parameter descriptions in the docstring and pydantic-ai implements griffe to automatically generate tool parameter descriptions.
-
Register Tools: Use the
@tooldecorator to mark methods as tools. The decorator automatically registers these methods, making them available for your agent to use during execution. No additional configuration is needed.
Here's an example of a roulette game agent:
import asyncio
import random
from agenty import Agent, tool
from pydantic_ai.models.openai import OpenAIModel
class RouletteAgent(Agent):
model = OpenAIModel("gpt-4o", api_key="your-api-key")
system_prompt = "You're a dice game, you should roll the die and see if the number matches the user's guess."
def __init__(self, player_name: str, num_sides: int = 10, **kwargs):
super().__init__(**kwargs)
self.player_name = player_name
self.num_sides = num_sides
@tool
def get_player_name(self) -> str:
"""Get the player's name."""
return self.player_name
@tool
def roll_die(self) -> int:
"""Roll a n-sided die and return the result."""
num = random.randint(1, self.num_sides)
print(f"Rolled a {num}!")
return num
async def main():
agent = RouletteAgent(player_name="John", num_sides=6)
response = await agent.run("I guess the number will be 3!")
print(response)
asyncio.run(main())
You can read more about function tools by pydantic-ai. (underlying implementation of agenty tools)
📚 Like what you see? Read the Documentation to learn more!
Requirements
- Python >= 3.12
License
MIT License - see the LICENSE file for details.
Author
Jonathan Chun (@jonchun)
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 agenty-0.1.6.tar.gz.
File metadata
- Download URL: agenty-0.1.6.tar.gz
- Upload date:
- Size: 112.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf445ed7ab5073346fe9925589d0b9ea7a6dcc858cdbf771a628591d8e2229ea
|
|
| MD5 |
379400bf0587e959b337b9d512c106ba
|
|
| BLAKE2b-256 |
9308d67e56ed21ea58633370f93cde8a4879d9d974774adbf1caf5f324e610a6
|
File details
Details for the file agenty-0.1.6-py3-none-any.whl.
File metadata
- Download URL: agenty-0.1.6-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1301613572a37f53bb09c45bf8dd0a49c542c83be1317a5b7b5ada240a4969b4
|
|
| MD5 |
3f88c50e7440fb0de6bda9a1cd830df3
|
|
| BLAKE2b-256 |
8391b67a5e0f06d2a912f8408b8dc5b9b6873a4c9c7a5fe398118198d1148002
|