Skip to main content

Ergonomic LLM Agent Augmented with Tools

Project description

Agentia: Ergonomic LLM Agent Augmented with Tools

Getting Started

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.

Agent Config File

Agentia supports creating agents from config files:

  1. 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"]
  1. In your python code:
agent = Agent.load_from_config("./alice.toml")
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentia-0.0.14.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

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

agentia-0.0.14-py3-none-any.whl (50.6 kB view details)

Uploaded Python 3

File details

Details for the file agentia-0.0.14.tar.gz.

File metadata

  • Download URL: agentia-0.0.14.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for agentia-0.0.14.tar.gz
Algorithm Hash digest
SHA256 ab13da103329ce58091a67949d94f4e48b91627ee0310bd0bfe6ba42637e1146
MD5 31f4b8d1f9a43449a625a1da26d99159
BLAKE2b-256 5d66717d220450d8020acae82a549ffd8e0b18d6f6ab0458d188bdd5c0936ef4

See more details on using hashes here.

File details

Details for the file agentia-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: agentia-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 50.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for agentia-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 03dd8eeb556cfae260fbf3e425a4aaaecdbeea759ad27715b39c7d7ffca51637
MD5 1484331be1a2d6fd65c3e8f8e592afa2
BLAKE2b-256 686750a0548fef0b700ebd085dee07641e6dfd1f2c35a5c79c1421e60f3b85aa

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