mech-client 0.14.0__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mech_client/__init__.py +1 -1
- mech_client/cli.py +257 -11
- mech_client/configs/mechs.json +110 -110
- mech_client/interact.py +6 -1
- mech_client/marketplace_interact.py +161 -43
- mech_client/safe.py +73 -0
- mech_client/subgraph.py +0 -11
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/METADATA +264 -219
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/RECORD +22 -48
- scripts/deposit_native.py +48 -16
- scripts/deposit_token.py +107 -31
- scripts/nvm_subscribe.py +14 -6
- scripts/nvm_subscription/contracts/base_contract.py +9 -1
- scripts/nvm_subscription/contracts/nft_sales.py +1 -3
- scripts/nvm_subscription/contracts/subscription_provider.py +2 -4
- scripts/nvm_subscription/contracts/token.py +23 -5
- scripts/nvm_subscription/manager.py +109 -16
- scripts/utils.py +2 -2
- scripts/whitelist.py +9 -1
- mech_client/helpers/acn/README.md +0 -76
- mech_client/helpers/acn/__init__.py +0 -30
- mech_client/helpers/acn/acn.proto +0 -71
- mech_client/helpers/acn/acn_pb2.py +0 -42
- mech_client/helpers/acn/custom_types.py +0 -224
- mech_client/helpers/acn/dialogues.py +0 -126
- mech_client/helpers/acn/message.py +0 -274
- mech_client/helpers/acn/protocol.yaml +0 -24
- mech_client/helpers/acn/serialization.py +0 -149
- mech_client/helpers/acn/tests/__init__.py +0 -20
- mech_client/helpers/acn/tests/test_acn.py +0 -256
- mech_client/helpers/acn/tests/test_acn_dialogues.py +0 -53
- mech_client/helpers/acn/tests/test_acn_messages.py +0 -117
- mech_client/helpers/acn_data_share/README.md +0 -32
- mech_client/helpers/acn_data_share/__init__.py +0 -32
- mech_client/helpers/acn_data_share/acn_data_share.proto +0 -17
- mech_client/helpers/acn_data_share/acn_data_share_pb2.py +0 -29
- mech_client/helpers/acn_data_share/dialogues.py +0 -115
- mech_client/helpers/acn_data_share/message.py +0 -213
- mech_client/helpers/acn_data_share/protocol.yaml +0 -21
- mech_client/helpers/acn_data_share/serialization.py +0 -111
- mech_client/helpers/acn_data_share/tests/test_acn_data_share_dialogues.py +0 -49
- mech_client/helpers/acn_data_share/tests/test_acn_data_share_messages.py +0 -53
- mech_client/helpers/p2p_libp2p_client/README.md +0 -15
- mech_client/helpers/p2p_libp2p_client/__init__.py +0 -21
- mech_client/helpers/p2p_libp2p_client/connection.py +0 -703
- mech_client/helpers/p2p_libp2p_client/connection.yaml +0 -52
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/LICENSE +0 -0
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/WHEEL +0 -0
- {mech_client-0.14.0.dist-info → mech_client-0.15.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mech-client
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.15.0
|
|
4
4
|
Summary: Basic client to interact with a mech
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: David Minarsch
|
|
7
7
|
Author-email: david.minarsch@googlemail.com
|
|
8
|
-
Requires-Python: >=3.10,<
|
|
8
|
+
Requires-Python: >=3.10,<3.12
|
|
9
9
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Requires-Dist: asn1crypto (>=1.4.0,<1.5.0)
|
|
14
|
+
Requires-Dist: click (==8.1.8)
|
|
14
15
|
Requires-Dist: gql (>=3.4.1)
|
|
15
|
-
Requires-Dist:
|
|
16
|
-
Requires-Dist:
|
|
17
|
-
Requires-Dist: open-aea-ledger-ethereum (>=1.53.0,<2.0.0)
|
|
18
|
-
Requires-Dist: open-aea[cli] (>=1.53.0,<2.0.0)
|
|
16
|
+
Requires-Dist: olas-operate-middleware (==0.14.7)
|
|
17
|
+
Requires-Dist: safe-eth-py (>=7.18.0,<8.0.0)
|
|
19
18
|
Requires-Dist: setuptools (>=77.0.3,<78.0.0)
|
|
20
19
|
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
|
21
20
|
Requires-Dist: websocket-client (>=0.32.0,<1)
|
|
@@ -34,10 +33,14 @@ A basic client to interact with an AI Mech. [AI Mechs](https://github.com/valory
|
|
|
34
33
|
|
|
35
34
|
## Developing, running and deploying Mechs and Mech tools
|
|
36
35
|
|
|
37
|
-
The easiest way to create, run, deploy and test your own Mech and Mech tools is to follow the Mech and Mech tool docs [here](https://open-autonomy
|
|
36
|
+
The easiest way to create, run, deploy and test your own Mech and Mech tools is to follow the Mech and Mech tool docs [here](https://stack.olas.network/open-autonomy/mech-tools-dev/). The [Mech tools dev repo](https://github.com/valory-xyz/mech-tools-dev) used in those docs greatly simplifies the development flow and dev experience.
|
|
38
37
|
|
|
39
38
|
Only continue reading this README if you know what you are doing and you are specifically interested in this repo.
|
|
40
39
|
|
|
40
|
+
## Quickstart Guide
|
|
41
|
+
For a fast and straightforward setup, follow the instructions provided on the website [here](https://build.olas.network/hire).
|
|
42
|
+
This guide will walk you through the essential steps to get up and running without requiring an in-depth understanding of the system.
|
|
43
|
+
|
|
41
44
|
## Installation
|
|
42
45
|
|
|
43
46
|
Find the latest available release on [PyPi](https://pypi.org/project/mech-client/#description).
|
|
@@ -85,129 +88,88 @@ Commands:
|
|
|
85
88
|
tool-description Get the description of a specific tool.
|
|
86
89
|
tool_io_schema Get the input/output schema of a specific tool.
|
|
87
90
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
### Set up the EOA and private key
|
|
91
|
-
|
|
92
|
-
To use the Mech Client you need an EOA account and its associated private key stored in a text file `ethereum_private_key.txt`. You can set it up in two ways:
|
|
93
|
-
|
|
94
|
-
- Use any software of your choice (e.g., [Metamask](https://metamask.io/)) and copy the private key:
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
echo -n YOUR_PRIVATE_KEY > ethereum_private_key.txt
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Do not include any leading or trailing spaces, tabs or newlines, or any other character in the file `ethereum_private_key.txt`.
|
|
101
|
-
|
|
102
|
-
- Alternatively, use the Open AEA command `generate-key` (you'll need to install [Open AEA](https://pypi.org/project/open-aea/) and its [Ethereum ledger plugin](https://pypi.org/project/open-aea-ledger-ethereum/)):
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
aea generate-key ethereum
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
and display the corresponding EOA:
|
|
91
|
+
```
|
|
109
92
|
|
|
110
|
-
|
|
111
|
-
python -c "from web3 import Web3; print(Web3().eth.account.from_key(open('ethereum_private_key.txt').read()).address)"
|
|
112
|
-
```
|
|
93
|
+
## Mech Marketplace
|
|
113
94
|
|
|
114
|
-
|
|
95
|
+
Learn more about mech marketplace [here](https://olas.network/mech-marketplace)
|
|
115
96
|
|
|
116
|
-
|
|
117
|
-
> * **If the generated EOA account is for development purposes, make sure it does not contain large amounts of funds.**
|
|
118
|
-
>
|
|
119
|
-
> * **If you store the key file in a local Git repository, we recommend that you add it to `.gitignore` in order to avoid publishing it unintentionally:**
|
|
120
|
-
>
|
|
121
|
-
> ```bash
|
|
122
|
-
> echo ethereum_private_key.txt >> .gitignore
|
|
123
|
-
> ```
|
|
97
|
+
### Set up agent mode for on-chain interactions
|
|
124
98
|
|
|
125
|
-
|
|
99
|
+
There are two modes you can use the mechx for on-chain interactions. Currently `agent-mode` is only supported for gnosis and base network.
|
|
126
100
|
|
|
127
|
-
|
|
101
|
+
- _agent mode_ (Recommended): This allows to register your on-chain interactions as agent on the olas protocol and allows for A2A activity to be reflected on the client
|
|
102
|
+
- _client mode_: Simple on-chain interations using EOA
|
|
128
103
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
4. Once generated copy your API key
|
|
104
|
+
```bash
|
|
105
|
+
cp .example.env .env
|
|
106
|
+
```
|
|
133
107
|
|
|
134
|
-
|
|
108
|
+
📝 For better reliability, it is recommended to use a stable third-party RPC provider.
|
|
135
109
|
|
|
136
110
|
```bash
|
|
137
|
-
|
|
111
|
+
mechx setup-agent-mode --chain-config <chain_config>
|
|
138
112
|
```
|
|
139
113
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
#### Select the mech you are going to send requests to
|
|
114
|
+
⚠️ Note: Run `setup-agent-mode` for each chain you interact with, and ensure your `.env` file has the correct RPC endpoint.
|
|
143
115
|
|
|
144
|
-
|
|
145
|
-
Mechs are deployed on several networks. Find the list of supported networks and corresponding mech addresses [here](https://github.com/valory-xyz/mech?tab=readme-ov-file#examples-of-deployed-mechs). Additionally, you can find more available Mechs [here](https://mech.olas.network/) (click on the tab "Legacy Mech" in order to see Legacy Mech (available only on Gnosis) and "Mech Marketplace" for the ones which receive requests via the Mech Marketplace).
|
|
116
|
+
### Generate Mech requests
|
|
146
117
|
|
|
147
|
-
####
|
|
118
|
+
#### List marketplace mechs
|
|
148
119
|
|
|
149
|
-
|
|
120
|
+
To list the top marketplace mechs based on deliveries, use the `fetch-mm-mechs-info` command. You can specify the chain you want to query. Please note that only the first 20 mechs sorted by number of deliveries will be shown.
|
|
121
|
+
Currently supported chains are gnosis and base
|
|
150
122
|
|
|
151
123
|
```bash
|
|
152
|
-
mechx
|
|
124
|
+
mechx fetch-mm-mechs-info --chain-config gnosis
|
|
153
125
|
```
|
|
154
126
|
|
|
155
|
-
|
|
127
|
+
```bash
|
|
128
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
129
|
+
| AI agent Id | Mech Type | Mech Address | Total Deliveries | Metadata Link |
|
|
130
|
+
+==============+====================+============================================+====================+===============================================================================================================+
|
|
131
|
+
| 2182 | Fixed Price Native | 0xc05e7412439bd7e91730a6880e18d5d5873f632c | 41246 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
132
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
133
|
+
| 2235 | Fixed Price Native | 0xb3c6319962484602b00d5587e965946890b82101 | 10127 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
134
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
135
|
+
| 2198 | Fixed Price Native | 0x601024e27f1c67b28209e24272ced8a31fc8151f | 5714 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
136
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
137
|
+
| 1722 | Fixed Price Token | 0x13f36b1a516290b7563b1de574a02ebeb48926a1 | 399 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
138
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
139
|
+
| 2135 | Fixed Price Native | 0xbead38e4c4777341bb3fd44e8cd4d1ba1a7ad9d7 | 353 | https://gateway.autonolas.tech/ipfs/f01701220157d3b106831e2713b86af1b52af76a3ef28c52ae0853e9638180902ebee41d4 |
|
|
140
|
+
+--------------+--------------------+--------------------------------------------+--------------------+---------------------------------------------------------------------------------------------------------------+
|
|
141
|
+
```
|
|
156
142
|
|
|
157
|
-
|
|
143
|
+
You can also find more available Mechs [here](https://mech.olas.network/)
|
|
158
144
|
|
|
159
|
-
|
|
145
|
+
#### Usage
|
|
160
146
|
|
|
161
|
-
|
|
162
|
-
- `--tools <name>`: Name of the tool to process the prompt. If you are aware about the tools that are provided by an agent you can directly provide its name using this option. If not provided, it will show a list of available tools for the agent so that you can select which one you want to use:
|
|
163
|
-
|
|
164
|
-
```text
|
|
165
|
-
Select prompting tool
|
|
166
|
-
|--------------------------------------------------|
|
|
167
|
-
| ID | Tool |
|
|
168
|
-
|--------------------------------------------------|
|
|
169
|
-
| 0 | openai-text-davinci-002 |
|
|
170
|
-
| ...| ... |
|
|
171
|
-
|--------------------------------------------------|
|
|
172
|
-
Tool ID >
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
- `--chain-config <name>`: Use default chain configuration parameters (RPC, WSS, ...). [See below](#chain-configuration) for more details. Available values are
|
|
176
|
-
- `arbitrum`
|
|
177
|
-
- `base`
|
|
178
|
-
- `celo`
|
|
179
|
-
- `gnosis` (Default)
|
|
180
|
-
- `optimism`
|
|
181
|
-
- `polygon`
|
|
182
|
-
|
|
183
|
-
- `--confirm <type>`: Specify how to wait for the result of your request:
|
|
184
|
-
- `off-chain`: Wait for the result using the ACN.
|
|
185
|
-
- `on-chain`: Wait for the result using the Subgraph and the Websocket subscription (whichever arrives first).
|
|
186
|
-
- `wait-for-both` (Default): Wait for the result using both `off-chain` and `on-chain` (whichever arrives first).
|
|
147
|
+
The basic usage of the Mech Client is as follows.
|
|
187
148
|
|
|
188
|
-
|
|
149
|
+
```bash
|
|
150
|
+
mechx interact --prompts <prompt> --priority-mech <priority mech address> --tools openai-gpt-3.5-turbo --chain-config <chain_config>
|
|
151
|
+
```
|
|
189
152
|
|
|
190
|
-
|
|
153
|
+
The Mech Client can also be used to send batch requests. There are couple of different ways to achieve this:
|
|
191
154
|
|
|
192
155
|
```bash
|
|
193
|
-
mechx interact --prompts
|
|
156
|
+
mechx interact --prompts={<prompt-1>,<prompt-2>} --priority-mech <priority mech address> --tools={<tool-1>,<tool-2>} --chain-config <chain_config>
|
|
194
157
|
```
|
|
195
158
|
|
|
196
|
-
|
|
159
|
+
or <br>
|
|
197
160
|
|
|
198
161
|
```bash
|
|
199
|
-
|
|
200
|
-
Prompt uploaded: https://gateway.autonolas.tech/ipfs/f01701220af9e4e8b4bd62d76394064f493081917bcc0b9c34a4aff60f82623b717617279
|
|
201
|
-
Transaction sent: https://gnosisscan.io/tx/0x61359f9cc6a1debb07d34ce1038f6aa30d25257c17edeb2b161741805e43e8d0
|
|
202
|
-
Waiting for transaction receipt...
|
|
203
|
-
Created on-chain request with ID 100407405856633966395081711430940962809568685031934329025999216833965518452765
|
|
204
|
-
Data arrived: https://gateway.autonolas.tech/ipfs/f01701220a462120d5bb03f406fa5ef3573df77184a20ab6343d7bade76bd321654aa7251
|
|
205
|
-
Data from agent: {'requestId': 100407405856633966395081711430940962809568685031934329025999216833965518452765, 'result': "In a world of chaos and strife,\nThere's beauty in the simplest of life.\nA gentle breeze whispers through the trees,\nAnd birds sing melodies with ease.\n\nThe sun sets in a fiery hue,\nPainting the sky in shades of blue.\nStars twinkle in the darkness above,\nGuiding us with their light and love.\n\nSo take a moment to pause and see,\nThe wonders of this world so free.\nEmbrace the joy that each day brings,\nAnd let your heart soar on gentle wings.", 'prompt': 'write a short poem', 'cost_dict': {}, 'metadata': {'model': None, 'tool': 'openai-gpt-3.5-turbo'}}
|
|
162
|
+
mechx interact --prompts <prompt-1> --prompts <prompt-2> --priority-mech <priority mech address> --tools <tool-1> --tools <tool-2> --chain-config <chain_config>
|
|
206
163
|
```
|
|
207
164
|
|
|
208
|
-
|
|
165
|
+
Additionally other options are available and their usage is listed below:
|
|
166
|
+
|
|
167
|
+
`--use-prepaid <bool>`: use the prepaid method to send requests to a Mech via the Mech Marketplace. Defaults to False. <br>
|
|
168
|
+
`--use-offchain <bool>`: use the off-chain method to send requests to a Mech via the Mech Marketplace. Defaults to False.
|
|
169
|
+
|
|
170
|
+
##### Prepaid Requests
|
|
209
171
|
|
|
210
|
-
|
|
172
|
+
In order to pay for the Mech fees, you can make a deposit before sending requests. The deposit depends on the
|
|
211
173
|
payment model of the Mech. For a fixed price Mech receiving payments in native token, use the following:
|
|
212
174
|
|
|
213
175
|
```bash
|
|
@@ -227,75 +189,232 @@ mechx purchase-nvm-subscription --chain-config <chain_config>
|
|
|
227
189
|
```
|
|
228
190
|
|
|
229
191
|
⚠️ To ensure optimal performance and reliability when using `purchase-nvm-subscription`, it is advisable to use a custom RPC provider as public RPC endpoints may be rate-limited or unreliable under high usage. You can configure your custom RPC URL in your environment variables using
|
|
192
|
+
|
|
230
193
|
```bash
|
|
231
194
|
export MECHX_CHAIN_RPC=
|
|
232
195
|
```
|
|
233
196
|
|
|
234
|
-
|
|
197
|
+
##### Offchain Requests
|
|
235
198
|
|
|
236
|
-
|
|
199
|
+
To use offchain requests using `--use-offchain` flag, export the `MECHX_MECH_OFFCHAIN_URL` env variable before sending requests. For example if you want to connect to a mech running locally, you can do the following
|
|
237
200
|
|
|
238
201
|
```bash
|
|
239
|
-
|
|
202
|
+
export MECHX_MECH_OFFCHAIN_URL="http://localhost:8000/"
|
|
240
203
|
```
|
|
241
204
|
|
|
242
|
-
|
|
205
|
+
If you want to use a Valory mech for offchain requests, below is the list of mechs and their address and offchain urls.
|
|
206
|
+
|
|
207
|
+
| AI agent ID | Priority Mech Address | Offchain URL |
|
|
208
|
+
| :---------: | :----------------------------------------: | :---------------------------------------------------: |
|
|
209
|
+
| 2182 | 0xB3C6319962484602b00d5587e965946890b82101 | https://d19715222af5b940.agent.propel.autonolas.tech/ |
|
|
210
|
+
|
|
211
|
+
### List tools available for a mech
|
|
212
|
+
|
|
213
|
+
To list the tools available for a specific marketplace mech, use the `tools-for-marketplace-mech` command. You can specify an AI agent ID to get tools for a specific mech.
|
|
243
214
|
|
|
244
|
-
`--use-prepaid <bool>`: use the prepaid method to send requests to a Mech via the Mech Marketplace. Defaults to False. <br>
|
|
245
|
-
`--use-offchain <bool>`: use the off-chain method to send requests to a Mech via the Mech Marketplace. Defaults to False.
|
|
246
|
-
> To use offchain requests using `--use-offchain` flag, export the `MECHX_MECH_OFFCHAIN_URL` env variable before sending requests. For example if you want to connect to a mech running locally, you can do the following
|
|
247
215
|
```bash
|
|
248
|
-
|
|
216
|
+
mechx tools-for-marketplace-mech 1722 --chain-config gnosis
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
You will see an output like this:
|
|
221
|
+
+---------------------------------------------+-----------------------------------------------+
|
|
222
|
+
| Tool Name | Unique Identifier |
|
|
223
|
+
+=============================================+===============================================+
|
|
224
|
+
| claude-prediction-offline | 1722-claude-prediction-offline |
|
|
225
|
+
+---------------------------------------------+-----------------------------------------------+
|
|
226
|
+
| claude-prediction-online | 1722-claude-prediction-online |
|
|
227
|
+
+---------------------------------------------+-----------------------------------------------+
|
|
228
|
+
| deepmind-optimization | 1722-deepmind-optimization |
|
|
229
|
+
+---------------------------------------------+-----------------------------------------------+
|
|
249
230
|
```
|
|
250
|
-
If you want to use a Valory mech for offchain requests, below is the list of mechs and their address and offchain urls.
|
|
251
231
|
|
|
252
|
-
|
|
253
|
-
| :---: | :---: | :---: |
|
|
254
|
-
| 2182 | 0xB3C6319962484602b00d5587e965946890b82101 | https://d19715222af5b940.agent.propel.autonolas.tech/ |
|
|
232
|
+
### Get Tool Description
|
|
255
233
|
|
|
234
|
+
To get the description of a specific tool, use the ` tool-description-for-marketplace-mech` command. You need to specify the unique identifier of the tool.
|
|
256
235
|
|
|
257
|
-
|
|
236
|
+
```bash
|
|
237
|
+
mechx tool-description-for-marketplace-mech <unique_identifier> --chain-config <chain_config>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Example usage:
|
|
258
241
|
|
|
259
242
|
```bash
|
|
260
|
-
mechx
|
|
243
|
+
mechx tool-description-for-marketplace-mech 1722-openai-gpt-4 --chain-config gnosis
|
|
261
244
|
```
|
|
262
245
|
|
|
263
|
-
|
|
246
|
+
You will see an output like this:
|
|
264
247
|
|
|
265
248
|
```bash
|
|
266
|
-
|
|
249
|
+
Description for tool 1722-openai-gpt-4: Performs a request to OpenAI's GPT-4 model.
|
|
267
250
|
```
|
|
268
251
|
|
|
269
|
-
###
|
|
270
|
-
|
|
271
|
-
|
|
252
|
+
### Get Tool Input/Output Schema
|
|
253
|
+
|
|
254
|
+
To get the input/output schema of a specific tool, use the `tool-io-schema-for-marketplace-mech` command. You need to specify the unique identifier of the tool.
|
|
255
|
+
|
|
272
256
|
```bash
|
|
273
|
-
mechx
|
|
257
|
+
mechx tool-io-schema-for-marketplace-mech <unique_identifier> --chain-config <chain_config>
|
|
274
258
|
```
|
|
259
|
+
|
|
260
|
+
Example usage:
|
|
261
|
+
|
|
275
262
|
```bash
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
|
286
|
-
|
|
287
|
-
|
|
|
288
|
-
|
|
263
|
+
mechx tool-io-schema-for-marketplace-mech 1722-openai-gpt-4 --chain-config gnosis
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
You will see an output like this:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
Tool Details:
|
|
270
|
+
Tool Details:
|
|
271
|
+
+------------------------+---------------------------------------------+
|
|
272
|
+
| Tool Name | Tool Description |
|
|
273
|
+
+========================+=============================================+
|
|
274
|
+
| OpenAI Request (GPT-4) | Performs a request to OpenAI's GPT-4 model. |
|
|
275
|
+
+------------------------+---------------------------------------------+
|
|
276
|
+
Input Schema:
|
|
277
|
+
+-------------+-----------------------------------------------+
|
|
278
|
+
| Field | Value |
|
|
279
|
+
+=============+===============================================+
|
|
280
|
+
| type | text |
|
|
281
|
+
+-------------+-----------------------------------------------+
|
|
282
|
+
| description | The request to relay to OpenAI's GPT-4 model. |
|
|
283
|
+
+-------------+-----------------------------------------------+
|
|
284
|
+
Output Schema:
|
|
285
|
+
+-----------+---------+-----------------------------------+
|
|
286
|
+
| Field | Type | Description |
|
|
287
|
+
+===========+=========+===================================+
|
|
288
|
+
| requestId | integer | Unique identifier for the request |
|
|
289
|
+
+-----------+---------+-----------------------------------+
|
|
290
|
+
| result | string | Response from OpenAI |
|
|
291
|
+
+-----------+---------+-----------------------------------+
|
|
292
|
+
| prompt | string | User prompt to send to OpenAI |
|
|
293
|
+
+-----------+---------+-----------------------------------+
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Set up the EOA and private key
|
|
297
|
+
|
|
298
|
+
To use the Mech Client using client mode, you need an EOA account and its associated private key stored in a text file `ethereum_private_key.txt`. You can set it up in two ways:
|
|
299
|
+
|
|
300
|
+
- Use any software of your choice (e.g., [Metamask](https://metamask.io/)) and copy the private key:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
echo -n YOUR_PRIVATE_KEY > ethereum_private_key.txt
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Do not include any leading or trailing spaces, tabs or newlines, or any other character in the file `ethereum_private_key.txt`.
|
|
307
|
+
|
|
308
|
+
- Alternatively, use the Open AEA command `generate-key` (you'll need to install [Open AEA](https://pypi.org/project/open-aea/) and its [Ethereum ledger plugin](https://pypi.org/project/open-aea-ledger-ethereum/)):
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
aea generate-key ethereum
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
and display the corresponding EOA:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
python -c "from web3 import Web3; print(Web3().eth.account.from_key(open('ethereum_private_key.txt').read()).address)"
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
The EOA you use must have enough funds to pay for the Mech requests, or alternatively, use a Nevermined subscription.
|
|
321
|
+
|
|
322
|
+
> **:warning: Warning** <br />
|
|
323
|
+
>
|
|
324
|
+
> - **If the generated EOA account is for development purposes, make sure it does not contain large amounts of funds.**
|
|
325
|
+
>
|
|
326
|
+
> - **If you store the key file in a local Git repository, we recommend that you add it to `.gitignore` in order to avoid publishing it unintentionally:**
|
|
327
|
+
>
|
|
328
|
+
> ```bash
|
|
329
|
+
> echo ethereum_private_key.txt >> .gitignore
|
|
330
|
+
> ```
|
|
331
|
+
|
|
332
|
+
To use client-mode for cli commands, simply supply `--client-mode` flag before the cli commands.
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
mechx --client-mode <rest of the cli command>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Legacy Mechs
|
|
339
|
+
|
|
340
|
+
#### Select the mech you are going to send requests to
|
|
341
|
+
|
|
342
|
+
Legacy Mechs are deployed on several networks. Find the list of supported networks and corresponding mech addresses, you can find more available Mechs [here](https://marketplace.olas.network/gnosis/ai-agents?legacy=true) (click on the tab "Legacy Mech" in order to see Legacy Mech (available only on Gnosis) and "Mech Marketplace" for the ones which receive requests via the Mech Marketplace).
|
|
343
|
+
|
|
344
|
+
#### Legacy Mechs
|
|
345
|
+
|
|
346
|
+
The basic usage of the Mech Client is as follows:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
mechx interact --prompts <prompt> --tools <tool> --agent_id <agent_id>
|
|
289
350
|
```
|
|
290
351
|
|
|
352
|
+
where agent blueprint with `<agent_id>` will process `<prompt>` with the `<tool>` and default options. Each chain has its own set of Mech agents. You can find the agent blueprint IDs for each chain on the [Mech Hub](https://aimechs.autonolas.network/registry) or on the [Mech repository](https://github.com/valory-xyz/mech?tab=readme-ov-file#examples-of-deployed-mechs).
|
|
353
|
+
|
|
354
|
+
⚠️ Batch requests and tools are not supported for legacy mechs
|
|
355
|
+
|
|
356
|
+
Some useful options:
|
|
357
|
+
|
|
358
|
+
- `--key <private_key_path>`: Specifies the path of the private key. The default value is `./ethereum_private_key.txt`.
|
|
359
|
+
- `--tools <name>`: Name of the tool to process the prompt. If you are aware about the tools that are provided by an agent you can directly provide its name using this option. If not provided, it will show a list of available tools for the agent so that you can select which one you want to use:
|
|
360
|
+
|
|
361
|
+
```text
|
|
362
|
+
Select prompting tool
|
|
363
|
+
|--------------------------------------------------|
|
|
364
|
+
| ID | Tool |
|
|
365
|
+
|--------------------------------------------------|
|
|
366
|
+
| 0 | openai-text-davinci-002 |
|
|
367
|
+
| ...| ... |
|
|
368
|
+
|--------------------------------------------------|
|
|
369
|
+
Tool ID >
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
- `--chain-config <name>`: Use default chain configuration parameters (RPC, WSS, ...). [See below](#chain-configuration) for more details. Available values are
|
|
373
|
+
|
|
374
|
+
- `arbitrum`
|
|
375
|
+
- `base`
|
|
376
|
+
- `celo`
|
|
377
|
+
- `gnosis` (Default)
|
|
378
|
+
- `optimism`
|
|
379
|
+
- `polygon`
|
|
380
|
+
|
|
381
|
+
- `--confirm <type>`: Specify how to wait for the result of your request:
|
|
382
|
+
- `off-chain`: Wait for the result using the ACN.
|
|
383
|
+
- `on-chain`: Wait for the result using the Subgraph and the Websocket subscription (whichever arrives first).
|
|
384
|
+
- `wait-for-both` (Default): Wait for the result using both `off-chain` and `on-chain` (whichever arrives first).
|
|
385
|
+
|
|
386
|
+
##### Example
|
|
387
|
+
|
|
388
|
+
Example of a request specifying a key file and tool:
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
mechx interact --prompts "write a short poem" --agent_id 6 --key ~/ethereum_private_key.txt --tools openai-gpt-3.5-turbo --chain-config gnosis --confirm on-chain
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
You will see an output like this:
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
Chain configuration: gnosis
|
|
398
|
+
Prompt uploaded: https://gateway.autonolas.tech/ipfs/f01701220af9e4e8b4bd62d76394064f493081917bcc0b9c34a4aff60f82623b717617279
|
|
399
|
+
Transaction sent: https://gnosisscan.io/tx/0x61359f9cc6a1debb07d34ce1038f6aa30d25257c17edeb2b161741805e43e8d0
|
|
400
|
+
Waiting for transaction receipt...
|
|
401
|
+
Created on-chain request with ID 100407405856633966395081711430940962809568685031934329025999216833965518452765
|
|
402
|
+
Data arrived: https://gateway.autonolas.tech/ipfs/f01701220a462120d5bb03f406fa5ef3573df77184a20ab6343d7bade76bd321654aa7251
|
|
403
|
+
Data from agent: {'requestId': 100407405856633966395081711430940962809568685031934329025999216833965518452765, 'result': "In a world of chaos and strife,\nThere's beauty in the simplest of life.\nA gentle breeze whispers through the trees,\nAnd birds sing melodies with ease.\n\nThe sun sets in a fiery hue,\nPainting the sky in shades of blue.\nStars twinkle in the darkness above,\nGuiding us with their light and love.\n\nSo take a moment to pause and see,\nThe wonders of this world so free.\nEmbrace the joy that each day brings,\nAnd let your heart soar on gentle wings.", 'prompt': 'write a short poem', 'cost_dict': {}, 'metadata': {'model': None, 'tool': 'openai-gpt-3.5-turbo'}}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
You can use the option `--key <private_key_file_path>` in order to customize the path to the private key file.
|
|
407
|
+
|
|
291
408
|
### List tools available for legacy mechs and marketplace mechs
|
|
292
409
|
|
|
293
410
|
#### For legacy mechs
|
|
294
|
-
|
|
411
|
+
|
|
412
|
+
To list the tools available for a specific agent or for all agents, use the `tools-for-agents` command. You can specify an agent blueprint ID to get tools for a specific agent, or omit it to list tools for all agents.
|
|
295
413
|
|
|
296
414
|
```bash
|
|
297
415
|
mechx tools-for-agents
|
|
298
416
|
```
|
|
417
|
+
|
|
299
418
|
```bash
|
|
300
419
|
You will see an output like this:
|
|
301
420
|
+------------+---------------------------------------------+-----------------------------------------------+
|
|
@@ -314,10 +433,13 @@ You will see an output like this:
|
|
|
314
433
|
```bash
|
|
315
434
|
mechx tools-for-agents --agent-id "agent_id"
|
|
316
435
|
```
|
|
317
|
-
|
|
436
|
+
|
|
437
|
+
Example usage
|
|
438
|
+
|
|
318
439
|
```bash
|
|
319
440
|
mechx tools-for-agents --agent-id 6
|
|
320
441
|
```
|
|
442
|
+
|
|
321
443
|
```bash
|
|
322
444
|
You will see an output like this:
|
|
323
445
|
+---------------------------------------------+-----------------------------------------------+
|
|
@@ -331,63 +453,28 @@ You will see an output like this:
|
|
|
331
453
|
+---------------------------------------------+-----------------------------------------------+
|
|
332
454
|
```
|
|
333
455
|
|
|
334
|
-
#### For marketplace mechs
|
|
335
|
-
To list the tools available for a specific marketplace mech, use the `tools-for-marketplace-mech` command. You can specify a service ID to get tools for a specific mech.
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
mechx tools-for-marketplace-mech 1722 --chain-config gnosis
|
|
339
|
-
```
|
|
340
|
-
```bash
|
|
341
|
-
You will see an output like this:
|
|
342
|
-
+---------------------------------------------+-----------------------------------------------+
|
|
343
|
-
| Tool Name | Unique Identifier |
|
|
344
|
-
+=============================================+===============================================+
|
|
345
|
-
| claude-prediction-offline | 1722-claude-prediction-offline |
|
|
346
|
-
+---------------------------------------------+-----------------------------------------------+
|
|
347
|
-
| claude-prediction-online | 1722-claude-prediction-online |
|
|
348
|
-
+---------------------------------------------+-----------------------------------------------+
|
|
349
|
-
| deepmind-optimization | 1722-deepmind-optimization |
|
|
350
|
-
+---------------------------------------------+-----------------------------------------------+
|
|
351
|
-
```
|
|
352
|
-
|
|
353
456
|
### Get Tool Description
|
|
354
457
|
|
|
355
|
-
#### For legacy mechs
|
|
356
458
|
To get the description of a specific tool, use the `tool-description` command. You need to specify the unique identifier of the tool.
|
|
357
459
|
|
|
358
460
|
```bash
|
|
359
461
|
mechx tool-description <unique_identifier> --chain-config <chain_config>
|
|
360
462
|
```
|
|
463
|
+
|
|
361
464
|
Example usage:
|
|
362
465
|
|
|
363
466
|
```bash
|
|
364
467
|
mechx tool-description "6-claude-prediction-offline" --chain-config gnosis
|
|
365
468
|
```
|
|
366
|
-
You will see an output like this:
|
|
367
|
-
```bash
|
|
368
|
-
Description for tool 6-claude-prediction-offline: Makes a prediction using Claude
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
#### For marketplace mechs
|
|
372
|
-
To get the description of a specific tool, use the ` tool-description-for-marketplace-mech` command. You need to specify the unique identifier of the tool.
|
|
373
|
-
|
|
374
|
-
```bash
|
|
375
|
-
mechx tool-description-for-marketplace-mech <unique_identifier> --chain-config <chain_config>
|
|
376
|
-
```
|
|
377
|
-
Example usage:
|
|
378
469
|
|
|
379
|
-
```bash
|
|
380
|
-
mechx tool-description-for-marketplace-mech 1722-openai-gpt-4 --chain-config gnosis
|
|
381
|
-
```
|
|
382
470
|
You will see an output like this:
|
|
471
|
+
|
|
383
472
|
```bash
|
|
384
|
-
Description for tool
|
|
473
|
+
Description for tool 6-claude-prediction-offline: Makes a prediction using Claude
|
|
385
474
|
```
|
|
386
475
|
|
|
387
|
-
|
|
388
476
|
### Get Tool Input/Output Schema
|
|
389
477
|
|
|
390
|
-
#### For legacy mechs
|
|
391
478
|
To get the input/output schema of a specific tool, use the `tool_io_schema` command. You need to specify the unique identifier of the tool.
|
|
392
479
|
|
|
393
480
|
```bash
|
|
@@ -399,7 +486,9 @@ Example usage:
|
|
|
399
486
|
```bash
|
|
400
487
|
mechx tool-io-schema "6-prediction-offline" --chain-config gnosis
|
|
401
488
|
```
|
|
489
|
+
|
|
402
490
|
You will see an output like this:
|
|
491
|
+
|
|
403
492
|
```bash
|
|
404
493
|
Tool Details:
|
|
405
494
|
+---------------------------+-----------------------------------------------+
|
|
@@ -427,49 +516,7 @@ Output Schema:
|
|
|
427
516
|
+-----------+---------+-----------------------------------------------+
|
|
428
517
|
```
|
|
429
518
|
|
|
430
|
-
|
|
431
|
-
To get the input/output schema of a specific tool, use the `tool-io-schema-for-marketplace-mech` command. You need to specify the unique identifier of the tool.
|
|
432
|
-
|
|
433
|
-
```bash
|
|
434
|
-
mechx tool-io-schema-for-marketplace-mech <unique_identifier> --chain-config <chain_config>
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
Example usage:
|
|
438
|
-
|
|
439
|
-
```bash
|
|
440
|
-
mechx tool-io-schema-for-marketplace-mech 1722-openai-gpt-4 --chain-config gnosis
|
|
441
|
-
```
|
|
442
|
-
You will see an output like this:
|
|
443
|
-
```bash
|
|
444
|
-
Tool Details:
|
|
445
|
-
Tool Details:
|
|
446
|
-
+------------------------+---------------------------------------------+
|
|
447
|
-
| Tool Name | Tool Description |
|
|
448
|
-
+========================+=============================================+
|
|
449
|
-
| OpenAI Request (GPT-4) | Performs a request to OpenAI's GPT-4 model. |
|
|
450
|
-
+------------------------+---------------------------------------------+
|
|
451
|
-
Input Schema:
|
|
452
|
-
+-------------+-----------------------------------------------+
|
|
453
|
-
| Field | Value |
|
|
454
|
-
+=============+===============================================+
|
|
455
|
-
| type | text |
|
|
456
|
-
+-------------+-----------------------------------------------+
|
|
457
|
-
| description | The request to relay to OpenAI's GPT-4 model. |
|
|
458
|
-
+-------------+-----------------------------------------------+
|
|
459
|
-
Output Schema:
|
|
460
|
-
+-----------+---------+-----------------------------------+
|
|
461
|
-
| Field | Type | Description |
|
|
462
|
-
+===========+=========+===================================+
|
|
463
|
-
| requestId | integer | Unique identifier for the request |
|
|
464
|
-
+-----------+---------+-----------------------------------+
|
|
465
|
-
| result | string | Response from OpenAI |
|
|
466
|
-
+-----------+---------+-----------------------------------+
|
|
467
|
-
| prompt | string | User prompt to send to OpenAI |
|
|
468
|
-
+-----------+---------+-----------------------------------+
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
> **:pencil2: Note** <br />
|
|
472
|
-
> **If you encounter an "Out of gas" error when executing the Mech Client, you will need to increase the gas limit, e.g.,**
|
|
519
|
+
> **:pencil2: Note** <br /> > **If you encounter an "Out of gas" error when executing the Mech Client, you will need to increase the gas limit, e.g.,**
|
|
473
520
|
>
|
|
474
521
|
> ```bash
|
|
475
522
|
> export MECHX_GAS_LIMIT=200000
|
|
@@ -477,8 +524,6 @@ Output Schema:
|
|
|
477
524
|
|
|
478
525
|
### Chain configuration
|
|
479
526
|
|
|
480
|
-
#### For legacy Mechs
|
|
481
|
-
|
|
482
527
|
Default configurations for different chains are stored in the file [configs/mechs.json](./mech_client/configs/mechs.json). If `--chain-config` parameter is not specified, the Mech Client will choose the first configuration on the JSON.
|
|
483
528
|
|
|
484
529
|
Additionally, you can override any configuration parameter by exporting any of the following environment variables:
|
|
@@ -547,7 +592,7 @@ You can also use the Mech Client to programmatically fetch tools for agents in y
|
|
|
547
592
|
from mech_client.mech_tool_management import get_tools_for_agents, get_tool_description, get_tool_io_schema
|
|
548
593
|
|
|
549
594
|
# Fetching tools for a specific agent or all agents
|
|
550
|
-
agent_id = 6 # Specify the agent ID or set to None to fetch tools for all agents
|
|
595
|
+
agent_id = 6 # Specify the agent blueprint ID or set to None to fetch tools for all agents
|
|
551
596
|
chain_config = "gnosis" # Specify the chain configuration
|
|
552
597
|
tools = get_tools_for_agents(agent_id=agent_id, chain_config=chain_config)
|
|
553
598
|
print(f"Tools for agent {agent_id}:", tools)
|
|
@@ -613,9 +658,9 @@ No. AI Mechs are currently deployed only on mainnets.
|
|
|
613
658
|
|
|
614
659
|
<details>
|
|
615
660
|
|
|
616
|
-
<summary><b>Where can I find the agent ID?</b></summary>
|
|
661
|
+
<summary><b>Where can I find the agent blueprint ID?</b></summary>
|
|
617
662
|
|
|
618
|
-
You can find the agent IDs for each chain on the [Mech Hub](https://aimechs.autonolas.network/registry) or on the [Mech repository](https://github.com/valory-xyz/mech?tab=readme-ov-file#examples-of-deployed-mechs).
|
|
663
|
+
You can find the agent blueprint IDs for each chain on the [Mech Hub](https://aimechs.autonolas.network/registry) or on the [Mech repository](https://github.com/valory-xyz/mech?tab=readme-ov-file#examples-of-deployed-mechs).
|
|
619
664
|
|
|
620
665
|
</details>
|
|
621
666
|
|