Skip to content

Feat: Support [email protected] #49

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

Merged
merged 8 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions configs/config_mech.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "Mech",
"hash": "bafybeig544gw6i7ahlwj6d64djlwfltjuznz3p66kmwk4m6bzqtn2bjfbq",
"name": "Mech Predict",
"hash": "bafybeihncvb4u3bg46ctpvdrmnqw4vknqyj7jrqpykjx6snxznvluaijuq",
"description": "The mech executes AI tasks requested on-chain and delivers the results to the requester.",
"image": "https://gateway.autonolas.tech/ipfs/bafybeidzpenez565d7vp7jexfrwisa2wijzx6vwcffli57buznyyqkrceq",
"service_version": "v0.1.0",
"service_version": "v0.3.2",
"home_chain": "gnosis",
"configurations": {
"gnosis": {
Expand Down Expand Up @@ -39,10 +39,10 @@
"provision_type": "computed"
},
"MECH_MARKETPLACE_ADDRESS": {
"name": "Mech marketplace address",
"description": "",
"value": "0x4554fE75c1f5576c1d7F765B2A036c199Adae329",
"provision_type": "fixed"
"name": "Mech Marketplace address",
"description": "The contract address of the mech marketplace, where your mech should be created. Supported addresses: 0x735FAAb1c4Ec41128c367AFb5c3baC73509f70bB or 0xad380C51cd5297FbAE43494dD5D407A2a3260b58",
"value": "0x735FAAb1c4Ec41128c367AFb5c3baC73509f70bB",
"provision_type": "user"
},
"API_KEYS": {
"name": "API keys",
Expand All @@ -58,9 +58,9 @@
},
"METADATA_HASH": {
"name": "Metadata hash",
"description": "",
"description": "The IPFS hash of the Mech metadata JSON",
"value": "f01701220caa53607238e340da63b296acab232c18a48e954f0af6ff2b835b2d93f1962f0",
"provision_type": "fixed"
"provision_type": "user"
},
"MECH_TO_CONFIG": {
"name": "Mech to config",
Expand All @@ -75,13 +75,19 @@
"provision_type": "computed"
},
"TOOLS_TO_PACKAGE_HASH": {
"name": "Tools to package hash",
"name": "Tools to package mapping",
"description": "Tools to package hash tracks services for each tool packages.",
"value": "{\"openai-gpt-3.5-turbo-instruct\":\"bafybeigz5brshryms5awq5zscxsxibjymdofm55dw5o6ud7gtwmodm3vmq\",\"openai-gpt-3.5-turbo\":\"bafybeigz5brshryms5awq5zscxsxibjymdofm55dw5o6ud7gtwmodm3vmq\",\"openai-gpt-4\":\"bafybeigz5brshryms5awq5zscxsxibjymdofm55dw5o6ud7gtwmodm3vmq\"}",
"provision_type": "fixed"
"provision_type": "user"
},
"ETHEREUM_LEDGER_RPC_0": {
"name": "Ethereum ledger RPC 0",
"description": "",
"value": "",
"provision_type": "computed"
},
"GNOSIS_RPC_0": {
"name": "Gnosis RPC 0",
"GNOSIS_LEDGER_RPC_0": {
"name": "Gnosis ledger RPC 0",
"description": "",
"value": "",
"provision_type": "computed"
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include = []

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
olas-operate-middleware = "0.2.5"
olas-operate-middleware = "0.2.6"
tqdm = "^4.67.1"

[tool.poetry.group.dev.dependencies]
Expand Down
10 changes: 10 additions & 0 deletions scripts/mech/.api_keys.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"openai": [
"YOUR_#1_KEY_HERE",
"YOUR_#2_KEY_HERE"
],
"google_api_key": [
"YOUR_#1_KEY_HERE",
"YOUR_#2_KEY_HERE"
]
}
3 changes: 3 additions & 0 deletions scripts/mech/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.api_keys.json
.metadata_hash.json
.tools_to_packages_hash.json
47 changes: 47 additions & 0 deletions scripts/mech/.metadata_hash.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "Autonolas Mech Quickstart",
"description": "The mech executes AI tasks requested on-chain and delivers the results to the requester.",
"inputFormat": "ipfs-v0.1",
"outputFormat": "ipfs-v0.1",
"image": "https://gateway.autonolas.tech/ipfs/bafybeidzpenez565d7vp7jexfrwisa2wijzx6vwcffli57buznyyqkrceq",
"tools": [
"claude-prediction-online"
],
"toolMetadata": {
"claude-prediction-online": {
"name": "Claude Prediction Online",
"description": "Makes a prediction using Claude",
"input": {
"type": "text",
"description": "The text to make a prediction on"
},
"output": {
"type": "object",
"description": "A JSON object containing the prediction and confidence",
"schema": {
"type": "object",
"properties": {
"requestId": {
"type": "integer",
"description": "Unique identifier for the request"
},
"result": {
"type": "string",
"description": "Result information in JSON format as a string",
"example": "{\n \"p_yes\": 0.6,\n \"p_no\": 0.4,\n \"confidence\": 0.8,\n \"info_utility\": 0.6\n}"
},
"prompt": {
"type": "string",
"description": "The prompt used to make the prediction."
}
},
"required": [
"requestId",
"result",
"prompt"
]
}
}
}
}
}
22 changes: 22 additions & 0 deletions scripts/mech/.tools_to_packages_hash.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"openai-gpt-3.5-turbo-instruct": "bafybeihahysrfznr3642ssrqfatr4my5ectfh3okh7kacdo23igccjewni",
"openai-gpt-3.5-turbo": "bafybeihahysrfznr3642ssrqfatr4my5ectfh3okh7kacdo23igccjewni",
"openai-gpt-4": "bafybeihahysrfznr3642ssrqfatr4my5ectfh3okh7kacdo23igccjewni",
"stabilityai-stable-diffusion-v1-5": "bafybeibaalr745aqajcaijykactx2nmg3jviefvnvpuk5kkxlt2yeedc2q",
"stabilityai-stable-diffusion-xl-beta-v2-2-2": "bafybeibaalr745aqajcaijykactx2nmg3jviefvnvpuk5kkxlt2yeedc2q",
"stabilityai-stable-diffusion-512-v2-1": "bafybeibaalr745aqajcaijykactx2nmg3jviefvnvpuk5kkxlt2yeedc2q",
"stabilityai-stable-diffusion-768-v2-1": "bafybeibaalr745aqajcaijykactx2nmg3jviefvnvpuk5kkxlt2yeedc2q",
"transfer-native": "bafybeideuyqn4uslp4ccanzd5tjladzotyi6tiwfxbouecw5ufzgyi4ryy",
"prediction-offline": "bafybeig7yntvhhfufaadhd43zr4loivpit43kwfgban72w43xz4u3tansi",
"prediction-online": "bafybeig7yntvhhfufaadhd43zr4loivpit43kwfgban72w43xz4u3tansi",
"prediction-online-summarized-info": "bafybeig7yntvhhfufaadhd43zr4loivpit43kwfgban72w43xz4u3tansi",
"prediction-online-sme": "bafybeiautzxe3faq53ceogfjtfbml5373wvqpsk77c4k3hjivloblivuxy",
"prediction-offline-sme": "bafybeiautzxe3faq53ceogfjtfbml5373wvqpsk77c4k3hjivloblivuxy",
"claude-prediction-online": "bafybeifp6tn3ovhuz4oipy67ijfdm4y7t2o7en3xuggn6kh5wbwokxmczu",
"claude-prediction-offline": "bafybeifp6tn3ovhuz4oipy67ijfdm4y7t2o7en3xuggn6kh5wbwokxmczu",
"deepmind-optimization-strong": "bafybeievl777e2425q7zy6qkt26luu2i6xzp4q6pquykntx2yzivy3iwum",
"deepmind-optimization": "bafybeievl777e2425q7zy6qkt26luu2i6xzp4q6pquykntx2yzivy3iwum",
"prediction-sentence-embedding-conservative": "bafybeihsyxhchqgtdwsd53z4a2lswt6ri4fre2yg2bpjo36kwboilsp7ai",
"prediction-sentence-embedding-bold": "bafybeihsyxhchqgtdwsd53z4a2lswt6ri4fre2yg2bpjo36kwboilsp7ai",
"prediction-online-sum-url-content": "bafybeial5a56vsowqu4suynnmv5pkt5iebkxtmpgrae57qzi7s6tg4vq6e"
}
101 changes: 101 additions & 0 deletions scripts/mech/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# How to configure your Mech and run using this Quickstart?

There are three additional configurations to do for Mechs:

## `API_KEYS`
This will be asked when you run the quickstart script. It should be a JSON object.
1. Copy over the sample from .api_keys.json.example.

```sh
cp scripts/mech/.api_keys.json.example scripts/mech/.api_keys.json
```

2. Setup key value pairs for every AI tool your mech uses
- The name of the tool will be the key used in the file
- The value will be an array of valid API keys the tool can use

3. Minimize the JSON file into a single line

```sh
poetry run python -m scripts.mech.minimize_json
```

4. Enter this JSON **in one line** when asked in the quickstart as `API_KEYS`

## `METADATA_HASH`
This is the IPFS hash of the metadata file of this Mech
1. Copy over the sample from .metadata_hash.json.example. The example file is valid for a single tool.

```sh
cp scripts/mech/.metadata_hash.json.example scripts/mech/.metadata_hash.json
```

2. Define your top level key value pairs
| Name | Value Type | Description |
| :--- | :---: | :--- |
| name | str | Name of your mech |
| description | str | Description of your mech |
| inputFormat | str | Can leave it default |
| outputFormat | str | Can leave it default |
| image | str | Link to the imagerepresenting your mech |
| tools | List | List of AI tools your mech supports |
| toolMetadata | Dict | Provides more info on specific tools |

> [!IMPORTANT] \
> Each tool mentioned in `tools` should have a corresponding `key` in the `toolsMetadata`.

3. Define your key value pairs for each specific tools.

| Name | Value Type | Description |
| :----------- | :--------: | :-------------------------------------- |
| name | str | Name of the AI tool |
| description | str | Description of the AI tool |
| input | Dict | Contains the input schema of the tool |
| output | Dict | Contains the output schema of the tool |

4. Define your key value pairs for the output schema

| Name | Value Type | Description |
| :--------- | :--------: | :----------------------------------------------------------- |
| type | str | Mentions the type of the schema |
| properties | Dict | Contains the required output data |
| required | List | Contains the list of fields required in the `properties` key |

> [!IMPORTANT] \
> Each field mentioned in `required` should have a corresponding `key` in the `properties`.

5. Define your key value pairs for the properties field

| Name | Value Type | Description |
| :-------- | :--------: | :------------------------------------------------------------ |
| requestId | Dict | Contains the request id and its description |
| result | Dict | Contains the result and its description with an example |
| prompt | Dict | Contains the prompt used for the request and its description |

6. Use the following script to push the metadata file to IPFS and get its hash

```sh
poetry run python -m scripts.mech.setup_metadata_hash
```

7. Enter this hash when asked in the quickstart as `METADATA_HASH`

## `TOOLS_TO_PACKAGE_HASH`
This is the IPFS hash of the tools file of this Mech. This file contains a JSON object that maps AI tools to their IPFS hashes.
1. Copy over the sample from .tools_to_packages_hash.json.example.

```sh
cp scripts/mech/.tools_to_packages_hash.json.example scripts/mech/.tools_to_packages_hash.json
```

2. Setup key value pairs for every AI tool your mech uses
- The name of the tool will be the key used in the file
- The value will be the IPFS hash of the tool's package

3. Minimize the JSON file into a single line

```sh
poetry run python -m scripts.mech.minimize_json
```

4. Enter this JSON **in one line** when asked in the quickstart as `TOOLS_TO_PACKAGE_HASH`
29 changes: 29 additions & 0 deletions scripts/mech/minimize_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import json
from operate.quickstart.utils import print_title

from scripts.utils import input_with_default_value


def minimize_json():
"""
Minimize the JSON file.
"""

print_title("Mech Quickstart: Minimize JSON")

json_path = input_with_default_value(
"Please provide the path to your JSON file",
"scripts/mech/.api_keys.json",
)

with open(json_path, "r") as f:
data = json.load(f)

with open(json_path, "w") as f:
json.dump(data, f)

print_title(f"JSON successfully minimized at {json_path}")


if __name__ == "__main__":
minimize_json()
Loading