-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doc mech #118
base: main
Are you sure you want to change the base?
Doc mech #118
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**1.** Clone the [Mech client](https://github.com/valory-xyz/mech-client) repository: | ||
|
||
``` | ||
poetry new my_project | ||
cd my_project | ||
git clone https://github.com/valory-xyz/mech-client.git | ||
cd mech-client | ||
poetry shell | ||
poetry add mech-client | ||
poetry install | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to fetch the repo instead of installing the package?
**2.** Setting up an EOA account: | ||
**b.** Click on the account icon, then on “Add account or hardware wallet”, then “Add a new Ethereum account”, provide a name for the account and then click on “Add account”; | ||
|
||
- *Option 1* (manual creation): | ||
**c.** Select the newly created account and then click on the top-right menu icon and then “Account details”. You can find the private key by clicking “Show private key”. | ||
|
||
**a.** Install browser extension of Metamask and open it; | ||
|
||
**b.** Click on the account icon, then on “Add account or hardware wallet”, then “Add a new Ethereum account”, provide a name for the account and then click on “Add account”; | ||
|
||
**c.** Select the newly created account and then click on the top-right menu icon and then “Account details”. You can find the private key by clicking “Show private key”. | ||
|
||
**d.** Copy this key in the file `ethereum_private_key.txt` in your project folder (do not include any leading or trailing spaces, tabs or newlines or any other character); | ||
|
||
- *Option 2* (using [open-autonomy](https://github.com/valory-xyz/open-autonomy)): | ||
|
||
**a.** Use the following to generate a private key: | ||
``` | ||
autonomy generate-key ethereum -n 1 | ||
``` | ||
|
||
This creates a file keys.json in which the private key can be found on the key “private_key”. | ||
|
||
**b.** Copy this key in the file `ethereum_private_key.txt`. | ||
**d.** Copy this key in the file `ethereum_private_key.txt` in your project folder (do not include any leading or trailing spaces, tabs or newlines or any other character); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed?
In order to find which tools the Mech uses, click on its service id, and then "View code" in the window which opens. Open the folder `mech` and then `service.yaml`. Copy the IPFS hash which follows `agent: valory/mech:0.1.0` and open the corresponding | ||
file by going to https://gateway.autonolas.tech/ipfs/ with the copied hash at the end of this address. Open the `mech` folder and then the file `aea-config.yaml`. In this file, the keys of the dictionary `tools_to_package_hash` are the | ||
names of the tools that this service uses. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not accurate. The aea config does not contain the tools that the mech is using, it is only a template with default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably the best option would be to point to the metadata and make sure that they are always updated.
@@ -149,6 +125,8 @@ mechx interact "write a short poem" --tool openai-gpt-3.5-turbo --chain-config g | |||
you should receive a response as follows: | |||
 | |||
|
|||
If not, you can note the request id provided in the logs, convert it to hexadecimal (using this [tool](https://www.rapidtables.com/convert/number/decimal-to-hex.html) for instance), find the Mech on this [page](https://mech.olas.network/mechs) (by searching for its service id or address for instance) and click on its address. You should see the list of requests sent to this Mech. You can find your request using its id (in hexadecimal format). Then click on "Delivers Data" to see the response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace the link with a simple bash command.
|
||
**2.** Click on the button "Mint". | ||
|
||
**3.** Click on the `Prefill address` button in order to fill the `owner address` field. You will need to have funds on this address in order to deploy the service. For the hash of the metadata file, click on "Generate Hash & File". The hash should be the one found [there](https://github.com/valory-xyz/mech-predict/blob/main/packages/packages.json) for the key `service/valory/mech/`. Select first the prefix and fill the field with the remaining part. The version is contained in this key (e.g. `service/valory/mech/0.1.0`). For the agent id, follow the instructions on the opened page (we suggest agent id = 9 to test). The number of slots corresponds to the number of agents that the service contains (we suggest 1 to test). For the cost of agent bound, we suggest that you use a small value (e.g., 1000000000000000 GörliWei = 0.001 GörliETH). We suggest to write threshold = 1 to test. Then click on submit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not point to main
, as the info can get outdated.
|
||
First, you need to configure the service. | ||
|
||
Ensure you have a file with the agent address and private key (`keys.json`). You can generate a new private key file using the Open Autonomy CLI: | ||
|
||
```bash | ||
autonomy generate-key ethereum -n 1 | ||
``` | ||
|
||
This is only to create a file with the right format. You need to replace the address by your own agent address and the private key by the one of this address. You do not need to change the ledger. | ||
|
||
You need to create a `.1env` file which contains the service configuration parameters. We provide a prefilled template (`.example_agent.env`). You will need to use an [OpenAI API key](https://platform.openai.com/account/api-keys) in the configuration. | ||
|
||
Run the following, where `network` is replaced by the name of the network (gnosis or base): | ||
|
||
```bash | ||
# Copy the prefilled template | ||
cp .example_service_network.env .1env | ||
``` | ||
|
||
##### Environment Variables | ||
|
||
You will need customize the agent's behaviour by setting the environment variables in the `.1env` file. The following table provides a description and templates for these variables. You can find also additional instructions below it. | ||
|
||
| Name | Type | Sample Value | Description | | ||
| -------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | | ||
| `ON_CHAIN_SERVICE_ID` | `int` | 1966 | The id of the service in Olas Service Registry | | ||
| `NUM_AGENTS` | `int` | 1 | Number of workers in the service. | | ||
| `TOOLS_TO_PACKAGE_HASH` | `dict` | `{"openai-gpt-3.5-turbo-instruct":"bafybeigz5brshryms5awq5zscxsxibjymdofm55dw5o6ud7gtwmodm3vmq","openai-gpt-3.5-turbo":"bafybeigz5brshryms5awq5zscxsxibjymdofm55dw5o6ud7gtwmodm3vmq","openai-gpt-4":"bafybeigz5brshryms5awq5zscxsxibjymdofm55dw5o6ud7gtwmodm3vmq"}` | Tracks services for each tool packages. | | ||
| `API_KEYS` | `dict` | `{"openai":["dummy_api_key"], "google_api_key":["dummy_api_key"]}` | Tracks API keys for each service. | | ||
| `ETHEREUM_LEDGER_RPC_0` | `str` | | RPC for ethereum. | | ||
| `GNOSIS_RPC_0` | `str` | | RPC for ethereum. | | ||
| `ETHEREUM_LEDGER_CHAIN_ID` | `str` | 100 | The id of the chain. | | ||
| `ALL_PARTICIPANTS` | `list` | `'["0x6A69696C29808F0A6638230fC0Cc752080c5dd7F"]'` | The list of addresses of workers. | | ||
| `RESET_PAUSE_DURATION` | `int` | 100 | Parameter which tells how long the Mech pauses between periods of work. | | ||
| `SAFE_CONTRACT_ADDRESS` | `str` | `0x8c18415836A6E2e61d1E9cc33F0a1b5Ac2219372` | Address of the service's safe contract. | | ||
| `MECH_TO_CONFIG` | `dict` | `{"0x895c50590a516b451668a620a9ef9b8286b9e72d":{"use_dynamic_pricing":false,"is_marketplace_mech":false}}` | Tracks mech's config. | | ||
| `MECH_TO_SUBSCRIPTION` | `dict` | `{"0x895c50590a516b451668a620a9ef9b8286b9e72d":{"tokenAddress":"0x0000000000000000000000000000000000000000","tokenId":"1"}}` | Tracks mech's subscription details. | | ||
| `MECH_MARKETPLACE_ADDRESS` | `str` | `"0x735FAAb1c4Ec41128c367AFb5c3baC73509f70bB"` | Marketplace for posting and delivering requests served by agent mechs. | | ||
| `HASH_CHECKPOINT_ADDRESS` | `str` | `0x694e62BDF7Ff510A4EE66662cf4866A961a31653` | Address of a contract recording metadata. | | ||
| `AGENT_REGISTRY_ADDRESS` | `str` | `"0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA"` | Smart contract which registers the agents. | | ||
| `LOG_DIR` | `str` | | Path for storing the logs. | | ||
|
||
⚠️ The variables `ETHEREUM_LEDGER_RPC_0` and `GNOSIS_RPC_0` are expected to be identical. | ||
|
||
⚠️ The address in the variables `MECH_TO_CONFIG` and `MECH_TO_SUBSCRIPTION` should be identical and correspond | ||
to the address of the Mech contract. | ||
|
||
The variables `AGENT_REGISTRY_ADDRESS` and `MECH_MARKETPLACE_ADDRESS` can be found [there](https://github.com/valory-xyz/autonolas-registries/blob/main/docs/configuration.json) and [there](https://github.com/valory-xyz/ai-registry-mech/blob/main/docs/configuration.json) respectively. They correspond respectively to the "ServiceRegistryL2" address and "MechMarketPlaceProxy" address. You need to select the ones which correspond to the chosen network. | ||
|
||
You can add your custom tool by adding its name and hash to the variable `TOOLS_TO_PACKAGE_HASH`. | ||
|
||
For the variable `LOG_DIR`, create a folder `tmp` and copy its absolute path, and set the variable `LOG_DIR` to this path. | ||
|
||
If you want to run a legacy Mech, the `MECH_MARKETPLACE_ADDRESS` is optional. Otherwise this variable needs to be defined. | ||
Furthermore, in the variable `MECH_TO_CONFIG`, the value corresponding to the key `is_marketplace_mech` should be set to true. | ||
Note that even in this case, the Mech won't run without changing also the other variables. | ||
|
||
Ensure that the variable `ALL_PARTICIPANTS` in the file `.agentenv` contains the same agent instance address as in `keys.json`. | ||
|
||
Once you are done modifying the `.1env` file, run the following: | ||
|
||
```bash | ||
# Source the env file | ||
source .1env | ||
``` | ||
|
||
Finally, in the file `run_service.sh`, change the line `autonomy deploy build -ltm` to `autonomy deploy build -ltm -n k`, | ||
where k is replaced by the number of agents in your service. For instance for 1 agent: `autonomy deploy build -ltm -n 1`. | ||
|
||
The rest of the common environment variables are present in the [service.yaml](https://github.com/valory-xyz/mech/blob/main/packages/valory/services/mech/service.yaml), which are customizable too. | ||
|
||
#### Running the service | ||
|
||
|
||
1. Run the service: | ||
|
||
``` | ||
poetry shell | ||
poetry install | ||
bash run_service.sh | ||
``` | ||
|
||
2. Build the docker container by running the following: | ||
|
||
``` | ||
cd mech | ||
build_dir=$(ls -d abci_build_????/ 2>/dev/null || echo "abci_build") | ||
autonomy deploy run --build-dir $build_dir | ||
``` | ||
|
||
|
||
3. In a separate terminal, run the following to see the logs: | ||
|
||
``` | ||
container = $(basename "$(ls -d ../*/abci_build_????/ 2>/dev/null | head -n 1)" | sed -E 's/^abci_build_//') | ||
container = "mech${container}_abci_0" | ||
docker logs -f container | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could point to the README instead of duplicating the information here.
docs/mech-tool/index.md
Outdated
| `AGENT_REGISTRY_ADDRESS` | `str` | `"0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA"` | Smart contract which registers the agents. | | ||
| `LOG_DIR` | `str` | | Path for storing the logs. | | ||
|
||
⚠️ The variables `CONNECTION_LEDGER_CONFIG_LEDGER_APIS_GNOSIS_ADDRESS` and `CONNECTION_LEDGER_CONFIG_LEDGER_APIS_ETHEREUM_ADDRESS` are expected to be identical. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why these should be the same? We need a note that explain that and also say that we do not need to add this for base
``` | ||
|
||
Replace `<prompt>` by a string which corresponds to the request to send to the Mech, and `<chain-config>` by one of the keys in the dictionary found in the file `.mech_client/configs/mechs.json` (for instance "gnosis"). In the dictionary corresponding to this key, replace the value of `priority_mech_address` with the address of the mech you want to send the request to. | ||
Change `<bool>` to True in order to use the off-chain method, and False otherwise. | ||
Change `<bool>` to True in order to use the off-chain method, and False otherwise. Finally, change `<tool>` to the name of the tool you want to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should update this when we have a way for say which is the tool that a deployed mech has
|
||
You can find a script for triggering this function [there](https://github.com/Sfgangloff/ai-registry-mech/tree/main/scripts/mech_registration) for each payment model. Clone the repository: | ||
**3.** _Alternatively_, you can also find a script for triggering this function [there](https://github.com/Sfgangloff/ai-registry-mech/tree/main/scripts/mech_registration) for each payment model. In order to use it, clone the repository: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove this for the moment, since this is not working
|
||
First, you need to configure the service. | ||
|
||
Ensure you have a file with the agent address and private key (`keys.json`). You can generate a new private key file using the Open Autonomy CLI: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure you have a file with the agent address and private key (`keys.json`). You can generate a new private key file using the Open Autonomy CLI: | |
There is a need to have a file with the agent instance address and private key (`keys.json`). You can generate a new private key file using the Open Autonomy CLI: |
autonomy generate-key ethereum -n 1 | ||
``` | ||
|
||
This is only to create a file with the right format. You need to replace the address by your own agent address and the private key by the one of this address. You do not need to change the ledger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only to create a file with the right format. You need to replace the address by your own agent address and the private key by the one of this address. You do not need to change the ledger. | |
This above command can be used to create the keys.json file with the right format. Once done that, you can replace the address by your own agent instance address and the private key by the one of this address. You do not need to change the ledger. |
|
||
This is only to create a file with the right format. You need to replace the address by your own agent address and the private key by the one of this address. You do not need to change the ledger. | ||
|
||
You need to create a `.1env` file which contains the service configuration parameters. We provide a prefilled template (`.example_agent.env`). You will need to use an [OpenAI API key](https://platform.openai.com/account/api-keys) in the configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example_agent is for running the agent no?
|
||
```bash | ||
# Source the env file | ||
source .1env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not necessary, the run_service.sh
script already does that
source .1env | ||
``` | ||
|
||
Finally, in the file `run_service.sh`, change the line `autonomy deploy build -ltm` to `autonomy deploy build -ltm -n k`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, in the file `run_service.sh`, change the line `autonomy deploy build -ltm` to `autonomy deploy build -ltm -n k`, | |
Finally, in the file `run_service.sh`, change the line `[autonomy deploy build -ltm](https://github.com/valory-xyz/mech-predict/blob/main/run_service.sh#L28)` to `autonomy deploy build -ltm -n k`, |
``` | ||
|
||
Finally, in the file `run_service.sh`, change the line `autonomy deploy build -ltm` to `autonomy deploy build -ltm -n k`, | ||
where k is replaced by the number of agents in your service. For instance for 1 agent: `autonomy deploy build -ltm -n 1`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a note saying that this should match the specified number in the config
Finally, in the file `run_service.sh`, change the line `autonomy deploy build -ltm` to `autonomy deploy build -ltm -n k`, | ||
where k is replaced by the number of agents in your service. For instance for 1 agent: `autonomy deploy build -ltm -n 1`. | ||
|
||
The rest of the common environment variables are present in the [service.yaml](https://github.com/valory-xyz/mech/blob/main/packages/valory/services/mech/service.yaml), which are customizable too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manos said that it is not the best practice to update the service yaml
No description provided.