Basic classes and utils for developing agents
Project description
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
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
agentutil-0.2.0.tar.gz
(10.5 kB
view details)
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
agentutil-0.2.0-py3-none-any.whl
(11.8 kB
view details)
File details
Details for the file agentutil-0.2.0.tar.gz.
File metadata
- Download URL: agentutil-0.2.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a03cff2817196897004b835a4490c45a0f94ff46c7c29c9e93e9c99946475ae2
|
|
| MD5 |
897aec391447500bfb8a1ce843ac849f
|
|
| BLAKE2b-256 |
ad79e2f52e70db59b3d79dbbcfd19ddcb7e72a15032bfd51551378e20ec48dbc
|
File details
Details for the file agentutil-0.2.0-py3-none-any.whl.
File metadata
- Download URL: agentutil-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
392d24abbce1a81daf20adb67ee084a06ef1e9992ad7e719630b9256ea8fff23
|
|
| MD5 |
badf9ffd26a5665da3b17bc7abc481af
|
|
| BLAKE2b-256 |
00c1119d9b903f6cee574b8eec43a060bab27a0719a379c9bb3b82b22aef634c
|