mech-client 0.2.16__py3-none-any.whl → 0.2.17__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 +50 -11
- mech_client/mech_tool_management.py +47 -23
- {mech_client-0.2.16.dist-info → mech_client-0.2.17.dist-info}/METADATA +11 -5
- {mech_client-0.2.16.dist-info → mech_client-0.2.17.dist-info}/RECORD +8 -8
- {mech_client-0.2.16.dist-info → mech_client-0.2.17.dist-info}/LICENSE +0 -0
- {mech_client-0.2.16.dist-info → mech_client-0.2.17.dist-info}/WHEEL +0 -0
- {mech_client-0.2.16.dist-info → mech_client-0.2.17.dist-info}/entry_points.txt +0 -0
mech_client/__init__.py
CHANGED
mech_client/cli.py
CHANGED
|
@@ -167,17 +167,39 @@ def tools_for_agents(agent_id: Optional[int], chain_config: str) -> None:
|
|
|
167
167
|
result = get_tools_for_agents(agent_id, chain_config)
|
|
168
168
|
|
|
169
169
|
if agent_id is not None:
|
|
170
|
-
headers = ["Tool Name", "Unique Identifier"]
|
|
170
|
+
headers = ["Tool Name", "Unique Identifier", "Mech Marketplace Support"]
|
|
171
171
|
data: List[Tuple[str, ...]] = [
|
|
172
|
-
(
|
|
172
|
+
(
|
|
173
|
+
str(tool["tool_name"]),
|
|
174
|
+
str(tool["unique_identifier"]),
|
|
175
|
+
"✓" if bool(tool["is_marketplace_supported"]) else "✗",
|
|
176
|
+
)
|
|
173
177
|
for tool in result["tools"]
|
|
174
178
|
]
|
|
175
179
|
else:
|
|
176
|
-
headers = [
|
|
180
|
+
headers = [
|
|
181
|
+
"Agent ID",
|
|
182
|
+
"Tool Name",
|
|
183
|
+
"Unique Identifier",
|
|
184
|
+
"Mech Marketplace Support",
|
|
185
|
+
]
|
|
186
|
+
|
|
177
187
|
data = [
|
|
178
|
-
(
|
|
179
|
-
|
|
180
|
-
|
|
188
|
+
(
|
|
189
|
+
str(agent_id),
|
|
190
|
+
tool["tool_name"],
|
|
191
|
+
tool["unique_identifier"],
|
|
192
|
+
(
|
|
193
|
+
"✓"
|
|
194
|
+
if bool(
|
|
195
|
+
tool["is_marketplace_supported"],
|
|
196
|
+
)
|
|
197
|
+
else "✗"
|
|
198
|
+
),
|
|
199
|
+
)
|
|
200
|
+
for agent_id, _ in result["agent_tools_map"].items()
|
|
201
|
+
for tool in result["all_tools_with_identifiers"]
|
|
202
|
+
if tool["unique_identifier"].startswith(f"{agent_id}-")
|
|
181
203
|
]
|
|
182
204
|
|
|
183
205
|
click.echo(tabulate(data, headers=headers, tablefmt="grid"))
|
|
@@ -209,18 +231,35 @@ def tool_description(tool_id: str, chain_config: str) -> None:
|
|
|
209
231
|
@click.argument("tool_id")
|
|
210
232
|
@click.option("--chain-config", default="gnosis", help="Chain configuration to use.")
|
|
211
233
|
def tool_io_schema(tool_id: str, chain_config: str) -> None:
|
|
212
|
-
"""Fetch and display the input/output schema for a specific tool."""
|
|
234
|
+
"""Fetch and display the tool's name and description along with the input/output schema for a specific tool."""
|
|
213
235
|
try:
|
|
214
|
-
|
|
236
|
+
result = get_tool_io_schema(tool_id, chain_config)
|
|
237
|
+
|
|
238
|
+
name = result["name"]
|
|
239
|
+
description = result["description"]
|
|
215
240
|
# Prepare data for tabulation
|
|
216
|
-
input_schema = [(key,
|
|
241
|
+
input_schema = [(key, result["input"][key]) for key in result["input"]]
|
|
217
242
|
|
|
218
243
|
# Handling nested output schema
|
|
219
244
|
output_schema = []
|
|
220
|
-
if "properties" in
|
|
221
|
-
for key, value in
|
|
245
|
+
if "properties" in result["output"]["schema"]:
|
|
246
|
+
for key, value in result["output"]["schema"]["properties"].items():
|
|
222
247
|
output_schema.append((key, value["type"], value.get("description", "")))
|
|
223
248
|
|
|
249
|
+
# Display tool details in tabulated format
|
|
250
|
+
click.echo("Tool Details:")
|
|
251
|
+
click.echo(
|
|
252
|
+
tabulate(
|
|
253
|
+
[
|
|
254
|
+
[
|
|
255
|
+
name,
|
|
256
|
+
description,
|
|
257
|
+
]
|
|
258
|
+
],
|
|
259
|
+
headers=["Tool Name", "Tool Description"],
|
|
260
|
+
tablefmt="grid",
|
|
261
|
+
)
|
|
262
|
+
)
|
|
224
263
|
# Display schemas in tabulated format
|
|
225
264
|
click.echo("Input Schema:")
|
|
226
265
|
click.echo(tabulate(input_schema, headers=["Field", "Value"], tablefmt="grid"))
|
|
@@ -35,13 +35,14 @@ def get_total_supply(chain_config: str = "gnosis") -> int:
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def get_agent_tools(
|
|
38
|
-
agent_id: int, chain_config: str = "gnosis"
|
|
38
|
+
agent_id: int, chain_config: str = "gnosis", include_metadata: bool = False
|
|
39
39
|
) -> Optional[Union[List[str], Tuple[List[str], Dict[str, Any]]]]:
|
|
40
40
|
"""
|
|
41
41
|
Fetch tools for a given agent ID.
|
|
42
42
|
|
|
43
43
|
:param agent_id: The ID of the agent.
|
|
44
44
|
:param chain_config: The chain configuration to use (default is "gnosis").
|
|
45
|
+
:param include_metadata: To include tools metadata or not (default is False)
|
|
45
46
|
:return: A list of tools if successful, or a tuple of (list of tools, metadata) if metadata is included, or None if an error occurs.
|
|
46
47
|
"""
|
|
47
48
|
try:
|
|
@@ -58,6 +59,7 @@ def get_agent_tools(
|
|
|
58
59
|
ledger_api=ledger_api,
|
|
59
60
|
agent_registry_contract=mech_config.agent_registry_contract,
|
|
60
61
|
contract_abi_url=mech_config.contract_abi_url,
|
|
62
|
+
include_metadata=include_metadata,
|
|
61
63
|
)
|
|
62
64
|
except (requests.exceptions.RequestException, json.JSONDecodeError, KeyError) as e:
|
|
63
65
|
print(f"An error occurred while fetching tools for agent {agent_id}: {e}")
|
|
@@ -78,31 +80,51 @@ def get_tools_for_agents(
|
|
|
78
80
|
total_supply = get_total_supply(chain_config)
|
|
79
81
|
|
|
80
82
|
if agent_id is not None:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
result = get_agent_tools(agent_id, chain_config, True)
|
|
84
|
+
|
|
85
|
+
if result is not None:
|
|
86
|
+
(tools, tool_metadata) = result
|
|
87
|
+
|
|
88
|
+
if isinstance(tools, list) and isinstance(tool_metadata, dict):
|
|
89
|
+
tools_with_ids = [
|
|
90
|
+
{
|
|
91
|
+
"tool_name": tool,
|
|
92
|
+
"unique_identifier": f"{agent_id}-{tool}",
|
|
93
|
+
"is_marketplace_supported": (
|
|
94
|
+
tool_metadata.get(tool, {}).get(
|
|
95
|
+
"isMechMarketplaceSupported", None
|
|
96
|
+
)
|
|
97
|
+
),
|
|
98
|
+
}
|
|
99
|
+
for tool in tools
|
|
100
|
+
]
|
|
101
|
+
else:
|
|
102
|
+
tools_with_ids = []
|
|
103
|
+
return {"agent_id": agent_id, "tools": tools_with_ids}
|
|
90
104
|
|
|
91
105
|
all_tools_with_ids = []
|
|
92
106
|
agent_tools_map = {}
|
|
93
107
|
|
|
94
108
|
for current_agent_id in range(1, total_supply + 1):
|
|
95
|
-
|
|
96
|
-
if
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
result = get_agent_tools(current_agent_id, chain_config, True)
|
|
110
|
+
if result is not None:
|
|
111
|
+
(tools, tool_metadata) = result
|
|
112
|
+
|
|
113
|
+
if isinstance(tools, list) and isinstance(tool_metadata, dict):
|
|
114
|
+
tools_with_ids = [
|
|
115
|
+
{
|
|
116
|
+
"tool_name": tool,
|
|
117
|
+
"unique_identifier": f"{current_agent_id}-{tool}",
|
|
118
|
+
"is_marketplace_supported": (
|
|
119
|
+
tool_metadata.get(tool, {}).get(
|
|
120
|
+
"isMechMarketplaceSupported", None
|
|
121
|
+
)
|
|
122
|
+
),
|
|
123
|
+
}
|
|
124
|
+
for tool in tools
|
|
125
|
+
]
|
|
126
|
+
agent_tools_map[current_agent_id] = tools
|
|
127
|
+
all_tools_with_ids.extend(tools_with_ids)
|
|
106
128
|
|
|
107
129
|
return {
|
|
108
130
|
"all_tools_with_identifiers": all_tools_with_ids,
|
|
@@ -148,11 +170,11 @@ def get_tool_io_schema(
|
|
|
148
170
|
unique_identifier: str, chain_config: str = "gnosis"
|
|
149
171
|
) -> Dict[str, Any]:
|
|
150
172
|
"""
|
|
151
|
-
Fetch the input and output schema of a specific tool based on a unique identifier.
|
|
173
|
+
Fetch the input and output schema along with tool name and description of a specific tool based on a unique identifier.
|
|
152
174
|
|
|
153
175
|
:param unique_identifier: The unique identifier for the tool.
|
|
154
176
|
:param chain_config: The chain configuration to use.
|
|
155
|
-
:return: Dictionary containing input and output schemas.
|
|
177
|
+
:return: Dictionary containing name, description, input and output schemas.
|
|
156
178
|
"""
|
|
157
179
|
parts = unique_identifier.split("-")
|
|
158
180
|
agent_id = int(parts[0])
|
|
@@ -174,6 +196,8 @@ def get_tool_io_schema(
|
|
|
174
196
|
tool_info = tool_metadata.get(tool_name, {})
|
|
175
197
|
if isinstance(tool_info, dict):
|
|
176
198
|
return {
|
|
199
|
+
"name": tool_info.get("name", {}),
|
|
200
|
+
"description": tool_info.get("description", {}),
|
|
177
201
|
"input": tool_info.get("input", {}),
|
|
178
202
|
"output": tool_info.get("output", {}),
|
|
179
203
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mech-client
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.17
|
|
4
4
|
Summary: Basic client to interact with a mech
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: David Minarsch
|
|
@@ -226,12 +226,12 @@ You will see an output like this:
|
|
|
226
226
|
To get the description of a specific tool, use the `tool-description` command. You need to specify the unique identifier of the tool.
|
|
227
227
|
|
|
228
228
|
```bash
|
|
229
|
-
mechx tool-description
|
|
229
|
+
mechx tool-description <unique_identifier> --chain-config <chain_config>
|
|
230
230
|
```
|
|
231
231
|
Example usage:
|
|
232
232
|
|
|
233
233
|
```bash
|
|
234
|
-
mechx tool-description
|
|
234
|
+
mechx tool-description "6-claude-prediction-offline" --chain-config gnosis
|
|
235
235
|
```
|
|
236
236
|
You will see an output like this:
|
|
237
237
|
```bash
|
|
@@ -244,16 +244,22 @@ Description for tool 6-claude-prediction-offline: Makes a prediction using Claud
|
|
|
244
244
|
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.
|
|
245
245
|
|
|
246
246
|
```bash
|
|
247
|
-
mechx tool-io-schema
|
|
247
|
+
mechx tool-io-schema <unique_identifier> --chain-config <chain_config>
|
|
248
248
|
```
|
|
249
249
|
|
|
250
250
|
Example usage:
|
|
251
251
|
|
|
252
252
|
```bash
|
|
253
|
-
mechx tool-io-schema
|
|
253
|
+
mechx tool-io-schema "6-prediction-offline" --chain-config gnosis
|
|
254
254
|
```
|
|
255
255
|
You will see an output like this:
|
|
256
256
|
```bash
|
|
257
|
+
Tool Details:
|
|
258
|
+
+---------------------------+-----------------------------------------------+
|
|
259
|
+
| Tool Name | Tool Description |
|
|
260
|
+
+===========================+===============================================+
|
|
261
|
+
| OpenAI Prediction Offline | Makes a prediction using OpenAI GPT-3.5 Turbo |
|
|
262
|
+
+---------------------------+-----------------------------------------------+
|
|
257
263
|
Input Schema:
|
|
258
264
|
+-------------+----------------------------------+
|
|
259
265
|
| Field | Value |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
mech_client/__init__.py,sha256=
|
|
1
|
+
mech_client/__init__.py,sha256=1i5v_YJZX04Olc98bp1Cl57tALIfGyEhL9dX_Vkmd70,43
|
|
2
2
|
mech_client/acn.py,sha256=Rj_jLPvJ5loDQfGbu3a_O24cJC4SwIErLceSz_zVYS8,5356
|
|
3
|
-
mech_client/cli.py,sha256=
|
|
3
|
+
mech_client/cli.py,sha256=cJ3QAP29QsbsyITVZbCVxZ7378ql2VPaEjar9Iotj0U,9555
|
|
4
4
|
mech_client/configs/mechs.json,sha256=IABnne1lWi62l84Hzqh3XrP659uPKme2k32yAI0HBrg,4488
|
|
5
5
|
mech_client/helpers/__init__.py,sha256=f13zpwGDaKQUjML-5Iq66rRfzg8IS5UNK5I8gBr7w54,1028
|
|
6
6
|
mech_client/helpers/acn/README.md,sha256=WMXR2Lk0IpWjr3vpZ8cxcTHk4gwsx4wC06UPkwj9dbQ,1641
|
|
@@ -31,14 +31,14 @@ mech_client/helpers/p2p_libp2p_client/__init__.py,sha256=-GOP3D_JnmXTDomrMLCbnRk
|
|
|
31
31
|
mech_client/helpers/p2p_libp2p_client/connection.py,sha256=pvfHtI-NhgDbay1wLNit6m8InH4c0p00c3hQo0I2jwQ,27887
|
|
32
32
|
mech_client/helpers/p2p_libp2p_client/connection.yaml,sha256=giYV5FwwugD7ha9IqFHJtvs-Oz1jC5og9rpkstrTqoc,1763
|
|
33
33
|
mech_client/interact.py,sha256=DOlUQBrfJKdDlfPnQ10tC8uAFTjlC3FGHOkPI2E_BYg,20846
|
|
34
|
-
mech_client/mech_tool_management.py,sha256=
|
|
34
|
+
mech_client/mech_tool_management.py,sha256=XWQDcFStTK66-3ZzOwKtMo5c66KDjvbeDsIXHIP4SuU,7810
|
|
35
35
|
mech_client/prompt_to_ipfs.py,sha256=XqSIBko15MEkpWOQNT97fRI6jNxMF5EDBDEPOJFdhyk,2533
|
|
36
36
|
mech_client/push_to_ipfs.py,sha256=IfvgaPU79N_ZmCPF9d7sPCYz2uduZH0KjT_HQ2LHXoQ,2059
|
|
37
37
|
mech_client/subgraph.py,sha256=4vY6QFyUVs15gS0SvanJbvAxb3aie07IuxQnfMMnStc,4931
|
|
38
38
|
mech_client/to_png.py,sha256=pjUcFJ63MJj_r73eqnfqCWMtlpsrj6H4ZmgvIEmRcFw,2581
|
|
39
39
|
mech_client/wss.py,sha256=hRInQjjsyOrs8dmgBb2VpJvpNt6Tx0aEiY3OhOPQvIs,6600
|
|
40
|
-
mech_client-0.2.
|
|
41
|
-
mech_client-0.2.
|
|
42
|
-
mech_client-0.2.
|
|
43
|
-
mech_client-0.2.
|
|
44
|
-
mech_client-0.2.
|
|
40
|
+
mech_client-0.2.17.dist-info/LICENSE,sha256=mdBDB-mWKV5Cz4ejBzBiKqan6Z8zVLAh9xwM64O2FW4,11339
|
|
41
|
+
mech_client-0.2.17.dist-info/METADATA,sha256=DvJxvDI_5aM_8-kVHyk6BEbg_sbowSatqqUOji50jK0,17682
|
|
42
|
+
mech_client-0.2.17.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
|
43
|
+
mech_client-0.2.17.dist-info/entry_points.txt,sha256=SbRMRsayzD8XfNXhgwPuXEqQsdZ5Bw9XDPnUuaDExyY,45
|
|
44
|
+
mech_client-0.2.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|