Quick start
The purpose of this guide is to provide step-by-step instructions to gain familiarity with the overall development process of the Open Autonomy framework.
We will show how to use the CLI to run a local deployment of the Hello World AI agent, which comprises:
- 4 Docker containers implementing the 4 agent instances of the AI agent, and
- 4 Docker containers implementing a Tendermint node for each agent instance.
Before starting this guide, ensure that your machine satisfies the framework requirements and that you have followed the set up guide. As a result you should have a Pipenv workspace folder.
Step-by-step instructions
Note
On MacOS and Windows, running Docker containers requires having Docker Desktop running as well. If you're using one of those operating systems, remember to start Docker Desktop before you run AI agent.
-
Fetch the Hello World AI agent from the remote registry. Within the workspace folder (not the local registry) run:
autonomy fetch valory/hello_world:0.1.0:<hash> --serviceThis command will download the AI agent package corresponding to the specified hash from the remote IPFS registry and store it in the
hello_worldfolder locally. -
Build the Docker image of the agent blueprint:
cd hello_world autonomy build-imageThis command reads the contents of the
service.yamlfile, which specifies the agent blueprint(s) that compose the AI agent, together with some configuration parameters. With this information, the command builds the Docker image of the agent blueprint by downloading the appropriate components from the remote registry. After the command finishes, check that the image has been created:docker image ls | grep hello_world -
Prepare and build the AI agent deployment:
-
Prepare a
keys.jsonfile containing wallet address and the private key for each of the agent instances. This file must specify as many keys as instances you want to deploy for the AI agent.Example of a
keys.jsonfileWARNING: Use this file for testing purposes only. Never use the keys or addresses provided in this example in a production environment or for personal use.
keys.json[ { "address": "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65", "private_key": "0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a" }, { "address": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc", "private_key": "0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba" }, { "address": "0x976EA74026E726554dB657fA54763abd0C3a0aa9", "private_key": "0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e" }, { "address": "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955", "private_key": "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356" } ] -
Export the environment variable
ALL_PARTICIPANTSwith all the agent instances' addresses:export ALL_PARTICIPANTS='[ "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65", "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc", "0x976EA74026E726554dB657fA54763abd0C3a0aa9", "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955" ]' -
(Optional) Export environment variables to customize the AI agent configuration.
Example of exported environment variables
export HELLO_WORLD_STRING_0="Your HELLO WORLD message for Agent instance 0" export HELLO_WORLD_STRING_1="Your HELLO WORLD message for Agent instance 1" export HELLO_WORLD_STRING_2="Your HELLO WORLD message for Agent instance 2" export HELLO_WORLD_STRING_3="Your HELLO WORLD message for Agent instance 3" -
Build the AI agent deployment:
autonomy deploy build keys.json -ltmThis command takes the configuration parameters specified inside the
service.yamland overrides them with the environment variables defined above. With the parameters defined, and the agent blueprint image ready, the output of this command is a Docker Compose deployment stored in theabci_build_*folder. The command takes care of configuring the necessary Tendermint images connected to each of the agent instances.
-
-
Run the AI agent:
cd abci_build_* autonomy deploy runThis command runs the Docker Compose deployment for the Hello World AI agent locally with four agent instances connected to four Tendermint nodes.
You can cancel the local execution at any time by pressing Ctrl+C.
At this point you should see a (verbose) output of the agent instance logs, which should look something like this:
(...)
abci0 | [2022-01-01 00:00:00,000] [INFO] [agent] arrived block with timestamp: 2022-00-00 00:00:00.000000
abci0 | [2022-01-01 00:00:00,000] [INFO] [agent] current AbciApp time: 2022-00-00 00:00:00.000000
abci0 | [2022-01-01 00:00:00,000] [INFO] Created a new local deadline for the next `begin_block` request from the Tendermint node: 2022-00-00 00:00:00.000000
abci2 | [2022-01-01 00:00:00,000] [INFO] [agent] 'select_keeper' round is done with event: Event.DONE
abci2 | [2022-01-01 00:00:00,000] [INFO] [agent] scheduling timeout of 30.0 seconds for event Event.ROUND_TIMEOUT with deadline 2022-00-00 00:00:00.000000
abci2 | [2022-01-01 00:00:00,000] [INFO] [agent] Entered in the 'print_message' round for period 2
abci2 | [2022-01-01 00:00:00,000] [INFO] [agent] Entered in the 'print_message' behaviour
abci2 | Agent agent (address 0x976EA74026E726554dB657fA54763abd0C3a0aa9) in period 2 says: HELLO_WORLD!
abci2 | [2022-01-01 00:00:00,000] [INFO] [agent] printed_message=Agent agent (address 0x976EA74026E726554dB657fA54763abd0C3a0aa9) in period 2 says: HELLO_WORLD!
(...)
The logs of a single agent instance or Tendermint node can be inspected in another terminal with, e.g.,
docker logs <container_id> --follow
where <container_id> refers to the Docker container ID for an agent instance
(abci0, abci1, abci2 and abci3) or a Tendermint node (node0, node1, node2 and node3).
Try to inspect the AI agent logs yourself and identify when they say the default "HELLO_WORLD!" message or your custom message.