-
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
Changes from all commits
2d2a303
da3711e
381d23c
b752b5c
0dd9a3d
39f8cea
a57a210
1740998
5fdb340
f8efc98
c94c68a
0bb40b9
c868abc
3d356a8
922027d
4d75f62
c38c550
1dba444
e8835fc
8f26631
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,50 +20,31 @@ In order to send a request, the workflow is the following: | |
|
||
The detailed instructions to send a request to a Mech can be found below. | ||
|
||
/!\ Only the Mechs with fixed pricing are currently stable. | ||
/!\ Only the Mechs with fixed pricing are currently usable. | ||
|
||
### Setup | ||
|
||
**Requirements**: [Python](https://www.python.org/) >= 3.10, [Poetry](https://github.com/python-poetry/poetry) == 1.8.4 | ||
|
||
**1.** Install the [Mech client](https://github.com/valory-xyz/mech-client): | ||
|
||
- *(Option 1)* Using [Poetry](https://github.com/python-poetry/poetry): | ||
**1.** Install mech-client: | ||
|
||
``` | ||
poetry new my_project | ||
poetry my_project | ||
cd my_project | ||
poetry shell | ||
poetry add mech-client | ||
poetry install | ||
poetry shell | ||
``` | ||
|
||
- *(Option 2)* On local python installation: | ||
**2.** Setting up an EOA account: | ||
|
||
``` | ||
pip install mech-client | ||
``` | ||
**a.** Install browser extension of Metamask and open it; | ||
|
||
**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); | ||
|
||
**3.** Create an API key for the network you want to use. For instance, follow the steps described [here](https://docs.gnosisscan.io/getting-started/viewing-api-usage-statistics#creating-an-api-key) for Gnosis. Then use the following: | ||
|
||
|
@@ -100,18 +81,22 @@ Alternatively, for Gnosis network, you can find the list of Mech Marketplace Mec | |
|
||
You will then see the list of available Mech Marketplace Mechs. | ||
|
||
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. | ||
|
||
Comment on lines
+84
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Adamantios Do you suggest that we write a list of metadata hashes in this doc ? (because this is all off-chain) |
||
### 1. 2. In terminal | ||
|
||
**1.** Send a request: | ||
|
||
- Use the command mechx in terminal, which is structured as follows: | ||
|
||
``` | ||
mechx interact <prompt> --chain-config <chain-config> --use-offchain <bool> | ||
mechx interact <prompt> --chain-config <chain-config> --use-offchain <bool> --tool <tool> --priority-mech <mech_address> | ||
``` | ||
|
||
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. Change `<tool>` to the name of the tool you want to use. Finally, change `<mech_address>` to the address of the Mech you want to send a request to. | ||
|
||
- If prompted, add funds to EOA account created above in order to be able to make a deposit on-chain and account for the mech fees. Specifically, add: | ||
- Native network token, e.g. xDAI for Gnosis, if the Mech uses native fixed price | ||
|
@@ -122,15 +107,7 @@ It will be indicated how much is needed. You can also find | |
the price per request (resp. the maximal price per Mechs with Nevermined subscription) as follows. | ||
Enter the address of the Mech in the scan of the network. Click on "Contract", then "Read contract" and find and click on "maxDeliveryRate" in the list which appears below. Divide the displayed number by 10^8 in order to obtain the price per request. | ||
|
||
- It is possible (and optional) to specify which tool should be used by the mech. The command line is then: | ||
|
||
``` | ||
mechx interact <prompt> --tool <tool> --chain-config <chain-config> | ||
``` | ||
|
||
In this case, replace `<tool>` by the name of the tool. | ||
|
||
- If prompted to make a an on-chain deposit to pay for Mech fees, use the following: | ||
- If prompted to make an on-chain deposit to pay for Mech fees, use the following: | ||
|
||
``` | ||
python ./scripts/deposit_payment_model.py | ||
|
@@ -149,6 +126,14 @@ 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: | ||
|
||
```bash | ||
printf "%x\n" <request_id> | ||
``` | ||
|
||
where `<request_id>` is replaced by the id of your request. 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. | ||
|
||
- Remark: If an "Out of gas" error is encountered, an increase of the gas limit, can solve the problem, using the following line: | ||
|
||
``` | ||
|
@@ -178,7 +163,7 @@ The variables **PROMPT_TEXT**, **CHAIN_CONFIG** and **TOOL_NAME** can be changed | |
|
||
**1.** Create a wallet (for instance with [Metamask](https://metamask.io/)) and connect it to the web interface by clicking on the button “Connect wallet” on the webpage. This wallet must be provided with xDAI in order to pay the Mechs for the requests. | ||
|
||
**2.** Go to the webpage [here](https://aimechs.autonolas.network/mech/0x77af31De935740567Cf4fF1986D04B2c964A786a). In the url, replace the address with the one of the Mech you intend to send a request to. | ||
**2.** Go to the webpage [here](https://mech.olas.network/gnosis/mechs). Click on the address of the Mech you want to send a request to. | ||
|
||
**4.** Click on "New Request". The following pop-up will appear: | ||
 | ||
|
@@ -281,7 +266,7 @@ The variables **PROMPT_TEXT**, **AGENT_ID** and **TOOL_NAME** can be changed. Th | |
|
||
**1.** Create a wallet (for instance with [Metamask](https://metamask.io/)) and connect it to the web interface by clicking on the button “Connect wallet” on the webpage. This wallet must be provided with xDAI in order to pay the Mechs for the requests. | ||
|
||
**2.** Go to the webpage [here](https://aimechs.autonolas.network/mech/0x77af31De935740567Cf4fF1986D04B2c964A786a). In the url, replace the address with the one of the Mech you intend to send a request to. | ||
**2.** Go to the webpage [here](https://mech.olas.network/gnosis/mechs?legacy=true). Click on the address of the Mech you want to send a request to. | ||
|
||
**4.** Click on "New Request". The following pop-up will appear: | ||
 | ||
|
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?
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.
@Adamantios Only the part which creates the key file with autonomy generate-key ethereum -n 1 is removed (since it is not really needed ?)