Ergonomic LLM Agent Augmented with Tools
Project description
Agentia: Ergonomic LLM Agents
Getting Started
Run agents with tools.
from agentia import Agent
from typing import Annotated
# Define a tool as a python function
def get_weather(location: Annotated[str, "The city name"]):
"""Get the current weather in a given location"""
return { "temperature": 72 }
# Create an agent
agent = Agent(tools=[get_weather])
# Run the agent with the tool
response = await agent.run("What is the weather like in boston?")
print(response)
# Output: The current temperature in Boston is 72°F.
The Magic Decorator
Create agent-powered magic functions.
Support both plain types and pydantic models as input and output.
from agentia import magic
from pydantic import BaseModel
class Forcast(BaseModel):
location: str
temperature_degree: int
@magic
async def get_weather(weather_forcast: str) -> Forcast:
"""Create weather forcase object based on the input string"""
...
forcast = await get_weather("The current temperature in Boston is 72°F")
print(forcast.location) # Output: Boston
print(forcast.temperature_degree) # Output: 22
Supported Parameter and Result Types
- Any types that can be passed to
pydantic.TypeAdaptor:- Builtin types:
int,float,str,bool,tuple[_],list[_],dict[_, _] - Enums:
Literal['A', 'B', ...],StrEnum,IntEnum, andEnum - dataclasses
- Builtin types:
pydantic.BaseModelsubclasses
Agent Config File
Agentia supports creating agents from config files:
- Create a config file at
./alice.toml
[agent]
name = "Alice" # This is the only required field
icon = "👩"
instructions = "You are a helpful assistant"
model = "openai/o3-mini"
plugins = ["calc", "clock", "web"]
- In your python code:
agent = Agent.load_from_config("./alice.toml")
- Alternatively, start a REPL:
uvx agentia alice
Multi-Agent Orchestration (Experimental)
Multi-agent orchestration is achieved by making leader/parent agents dispatching sub-tasks to their sub-agents.
from agentia import Agent, CommunicationEvent, AssistantMessage
coder = Agent(
model="openai/gpt-4o-mini",
name="Coder",
description="programmar",
)
reviewer = Agent(
model="openai/gpt-4o-mini",
name="Code Reviewer",
description="code reviewer",
)
leader = Agent(
model="openai/gpt-4o-mini",
name="Leader",
description="Leader agent",
subagents=[
coder,
reviewer,
],
)
run = leader.run(
"Ask your subagents to write a quicksort algorithm in python, review and improve it until it is perfect."
events=True,
)
async for e in run:
if isinstance(e, CommunicationEvent):
subagent_name = coder.name if e.child == coder.id else reviewer.name
if e.response is None:
print(f"[DISPATCH -> {subagent_name}]")
print(e.message)
print("[DISPATCH END]")
print()
else:
print(f"[RESPONSE <- {subagent_name}]")
print(e.response)
print("[RESPONSE END]")
print()
if isinstance(e, AssistantMessage):
print(e.content)
print()
Multi-agent orchestration in agent config files:
[agent]
name = "Leader"
# ... other fields
# Create two subagent config files in the same directory: coder.toml and reviewer.toml
subagents = ["coder", "reviewer"]
Project details
Release history Release notifications | RSS feed
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 agentia-0.0.17.tar.gz.
File metadata
- Download URL: agentia-0.0.17.tar.gz
- Upload date:
- Size: 40.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
147924e3076a3513f6dbc7a6d30fa8bd0ee28ece1af2070204344ceb6b0d66bd
|
|
| MD5 |
64d7a9d0d0efe00680d8d27fb2547664
|
|
| BLAKE2b-256 |
21ccefb7b429367618182346422d4e92dc13fa098342d8e08b1a18ea93e44ba4
|
File details
Details for the file agentia-0.0.17-py3-none-any.whl.
File metadata
- Download URL: agentia-0.0.17-py3-none-any.whl
- Upload date:
- Size: 51.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11404fb57150b46f77488b0ff8a0fd3e78a2a9c49fcd80d0fb59ed220f5bcbd2
|
|
| MD5 |
a12f7177354c79858c829b8154420e70
|
|
| BLAKE2b-256 |
1ac953d63bba76089471358f3a4b05f89e802e257342117a29faf8bcdbc321b5
|