-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added script to create metadata hash for the mech
- Loading branch information
1 parent
1964950
commit 067993c
Showing
4 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,5 @@ local_config.json | |
mech.db | ||
|
||
/.api_keys.json | ||
|
||
.metadata_hash.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"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": [ | ||
"openai-gpt-4" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from typing import Tuple | ||
|
||
import multibase | ||
import multicodec | ||
from aea.helpers.cid import to_v1 | ||
from aea_cli_ipfs.ipfs_utils import IPFSTool | ||
from utils import ( | ||
print_title, | ||
OPERATE_HOME, | ||
MechQuickstartConfig, | ||
input_with_default_value, | ||
OperateApp, | ||
) | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Push the metadata file to IPFS. | ||
""" | ||
|
||
print_title("Mech Quickstart: Metadata hash setup") | ||
print("This script will assist you in setting up the metadata hash for your mech.") | ||
print() | ||
|
||
operate = OperateApp( | ||
home=OPERATE_HOME, | ||
) | ||
operate.setup() | ||
|
||
path = OPERATE_HOME / "local_config.json" | ||
if path.exists(): | ||
mech_quickstart_config = MechQuickstartConfig.load(path) | ||
else: | ||
mech_quickstart_config = MechQuickstartConfig(path) | ||
|
||
metadata_hash_path = input_with_default_value( | ||
"Please provide the path to your metadata_hash.json file", | ||
"./.metadata_hash.json", | ||
) | ||
|
||
response = IPFSTool().client.add( | ||
metadata_hash_path, pin=True, recursive=True, wrap_with_directory=False | ||
) | ||
v1_file_hash = to_v1(response["Hash"]) | ||
cid_bytes = multibase.decode(v1_file_hash) | ||
multihash_bytes = multicodec.remove_prefix(cid_bytes) | ||
v1_file_hash_hex = "f01" + multihash_bytes.hex() | ||
|
||
mech_quickstart_config.metadata_hash = v1_file_hash_hex | ||
mech_quickstart_config.store() | ||
|
||
print() | ||
print_title("Metadata hash successfully generated and stored in config") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters