Skip to main content

AgentUtil

Basic classes and utilities for developing agent-based applications.

Installation

pip install agentutil

Or, if you are developing locally:

pip install -e .

Or, if you are use uv:

uv add agentutil

Usage

Importing

from agentutil.utils.agentAssistant import TestAgentAssistant, AgentAssistant
from agentutil.agent import Agent  # or your custom agent class
from agentutil.utils.models import News

Example: Custom Assistant and Agent

import asyncio
from agentutil.utils.agentAssistant import AgentAssistant
from agentutil.agent import Agent
from agentutil.utils.models import News

class SJAssistant(AgentAssistant):
    def __init__(self):
        super().__init__()

    def publish_article(self, news_id: str, news: News):
        print("MY CUSTOM PUBLISH...")
        await asyncio.sleep(1)

    def update_news_status(
        self,
        news_id: str,
        new_status: str,
        title: str = None,
        cms_news_id: int = None,
        cost: int = None,
        duration=None
    ):
        print("MY CUSTOM UPDATE...")

assistant = SJAssistant()

# Example agent class inheriting from Agent
class MasterAgent(Agent):
    async def run(self, data):
        print("Running MasterAgent...")

agent = MasterAgent(assitant=assistant)
agent.assitant.update_news_status("master_agent", "running")

asyncio.run(agent.assitant.publish_article(News(title="Sample"), "test"))

Custom Agent package structure

ai_engine/graphs/agent1
├── __init__.py
├── agent.py
├── config.py
│
├── form
│   ├── __init__.py
│   └── agent_form.py
│
├── agents
│   ├── __init__.py
│   ├── node1.py
│   ├── node2.py
│   .
│   :
│   └── nodeN.py
│
├── models
│   ├── __init__.py
│   └──  models.py
│
├── outputformats
│   ├── __init__.py
│   └── formats.py
│
├── prompts
│   ├── __init__.py
│   └──  prompts.py
│
└── tools
    ├── __init__.py
    ├── tools1.py
    ├── tools2.py
    .
    :
    └── toolsN.py

your agent.py file should be like this:

from agentutil.agent import Agent
from .form.agent_form import NewsForm
from .config import AGENT_CONFIG

class MasterAgent(Agent):
    def __init__(self, assistant=None, form=None):
        super().__init__(assitant=assistant)
        self.form = NewsForm
        self.config = AGENT_CONFIG

    async def run(self, data):
        # your custom agent graph
        pass

your config.py should contains these fields:

AGENT_CONFIG = {
    "name": "نام خط تولید",
    "description": "توضیحات مربوط به خط تولید",
    "parameters": {
    }
}

your form.agent_form.py should be like this:

from django import forms

class NewsForm(forms.Form):
    pass

License

MIT

Release files for agentutil 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentutil 0.2.0
File Size Uploaded
agentutil-0.2.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentutil 0.2.0
File Interpreter ABI Platform
agentutil-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / agentutil-0.2.0.tar.gz

Download URL agentutil-0.2.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a03cff2817196897004b835a4490c45a0f94ff46c7c29c9e93e9c99946475ae2
BLAKE2b-256 checksum
How to use checksums
ad79e2f52e70db59b3d79dbbcfd19ddcb7e72a15032bfd51551378e20ec48dbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Release files / agentutil-0.2.0-py3-none-any.whl

Download URL agentutil-0.2.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
392d24abbce1a81daf20adb67ee084a06ef1e9992ad7e719630b9256ea8fff23
BLAKE2b-256 checksum
How to use checksums
00c1119d9b903f6cee574b8eec43a060bab27a0719a379c9bb3b82b22aef634c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.19

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page