ums.agent
Run as Agent
The env. variable AGENTS_LIST
is used to identify the agents classes/ task handlers.
It must contain he the package name and a variable name in this package divided by :
.
Then, the variable contains a list of agent classes (subclasses of ums.agent.agent.BasicAgent
)
For example AGENTS_LIST=ums.example.example:AGENT_CLASSES
, then in file ./ums/example/example.py
a variable AGENT_CLASSES
exists.
One line in this file, e.g., is AGENT_CLASSES = [MyExtractAudioAgent, MyExtractImageAgent]
.
When starting the Docker container of the agent, the classes specified in AGENTS_LIST
are loaded and if the agent receives a task, the task is sent to the agent classes' handle
methods.
Run Single Task
For development it might be cumbersome to always require a running management container and sending messages. Hence, tasks can be run manually from the terminal (still in the container and using the agent classes), but without having a management.
This also uses the AGENTS_LIST
env. variable, but the tasks are sent via command line:
There are three ways to send a task (if the agent's Docker container is running):
docker compose exec agent_all python -m ums.agent -d
- Run a dummy task
- Possibly
agent_all
needs to be changed to the service name (seedocker-compose.yml
) of the agent's Docker container
cat ./msg.json | docker compose exec -T agent_all python -m ums.agent -i
- Send the task (json of
AgentMessage
) via STDIN from file./msg.json
to the agent
- Send the task (json of
docker compose exec agent_all python -m ums.agent -f msg.json
- Get the task from the json file, the files are searched for by full name, in the shared, and the persistent directory.
If the Agent's Docker container is not running, a temporary container can be started.
For the dummy message, the command would be docker compose run --rm --entrypoint "" agent_all python -m ums.agent -d
.
(Again, change agent_all
for the service name in docker-compose.yml
.)
1# Agenten Plattform 2# 3# (c) 2024 Magnus Bender 4# Institute of Humanities-Centered Artificial Intelligence (CHAI) 5# Universitaet Hamburg 6# https://www.chai.uni-hamburg.de/~bender 7# 8# source code released under the terms of GNU Public License Version 3 9# https://www.gnu.org/licenses/gpl-3.0.txt 10 11""" 12 13## Run as Agent 14 15The env. variable `AGENTS_LIST` is used to identify the agents classes/ task handlers. 16It must contain he the package name and a variable name in this package divided by `:`. 17Then, the variable contains a list of agent classes (subclasses of `ums.agent.agent.BasicAgent`) 18 19For example `AGENTS_LIST=ums.example.example:AGENT_CLASSES`, then in file `./ums/example/example.py` a variable `AGENT_CLASSES` exists. 20One line in this file, e.g., is `AGENT_CLASSES = [MyExtractAudioAgent, MyExtractImageAgent]`. 21 22When starting the Docker container of the agent, the classes specified in `AGENTS_LIST` are loaded and if the agent receives a task, the task is sent to the agent classes' `handle` methods. 23 24## Run Single Task 25 26For development it might be cumbersome to always require a running management container and sending messages. 27Hence, tasks can be run manually from the terminal (still in the container and using the agent classes), but without having a management. 28 29This also uses the `AGENTS_LIST` env. variable, but the tasks are sent via command line: 30 31There are three ways to send a task (if the agent's Docker container is running): 32- `docker compose exec agent_all python -m ums.agent -d` 33 - Run a dummy task 34 - Possibly `agent_all` needs to be changed to the service name (see `docker-compose.yml`) of the agent's Docker container 35- `cat ./msg.json | docker compose exec -T agent_all python -m ums.agent -i` 36 - Send the task (json of `AgentMessage`) via STDIN from file `./msg.json` to the agent 37- `docker compose exec agent_all python -m ums.agent -f msg.json` 38 - Get the task from the json file, the files are searched for by full name, in the shared, and the persistent directory. 39 40If the Agent's Docker container is not running, a temporary container can be started. 41For the dummy message, the command would be `docker compose run --rm --entrypoint "" agent_all python -m ums.agent -d`. 42(Again, change `agent_all` for the service name in `docker-compose.yml`.) 43 44""" 45 46from ums.agent.agent import ( 47 AgentCapability, 48 BasicAgent, 49 ExtractAgent, 50 ExtractAudioAgent, ExtractImageAgent, ExtractTextAgent, 51 SolveAgent, 52 GatekeeperAgent 53)