mech-client 0.2.16__tar.gz → 0.2.18__tar.gz

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.
Files changed (44) hide show
  1. {mech_client-0.2.16 → mech_client-0.2.18}/PKG-INFO +11 -5
  2. {mech_client-0.2.16 → mech_client-0.2.18}/README.md +10 -4
  3. mech_client-0.2.18/mech_client/__init__.py +3 -0
  4. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/cli.py +50 -11
  5. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/interact.py +1 -0
  6. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/mech_tool_management.py +47 -23
  7. {mech_client-0.2.16 → mech_client-0.2.18}/pyproject.toml +1 -1
  8. mech_client-0.2.16/mech_client/__init__.py +0 -3
  9. {mech_client-0.2.16 → mech_client-0.2.18}/LICENSE +0 -0
  10. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/acn.py +0 -0
  11. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/configs/mechs.json +0 -0
  12. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/__init__.py +0 -0
  13. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/README.md +0 -0
  14. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/__init__.py +0 -0
  15. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/acn.proto +0 -0
  16. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/acn_pb2.py +0 -0
  17. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/custom_types.py +0 -0
  18. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/dialogues.py +0 -0
  19. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/message.py +0 -0
  20. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/protocol.yaml +0 -0
  21. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/serialization.py +0 -0
  22. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/tests/__init__.py +0 -0
  23. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/tests/test_acn.py +0 -0
  24. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/tests/test_acn_dialogues.py +0 -0
  25. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn/tests/test_acn_messages.py +0 -0
  26. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/README.md +0 -0
  27. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/__init__.py +0 -0
  28. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/acn_data_share.proto +0 -0
  29. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/acn_data_share_pb2.py +0 -0
  30. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/dialogues.py +0 -0
  31. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/message.py +0 -0
  32. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/protocol.yaml +0 -0
  33. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/serialization.py +0 -0
  34. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/tests/test_acn_data_share_dialogues.py +0 -0
  35. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/acn_data_share/tests/test_acn_data_share_messages.py +0 -0
  36. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/p2p_libp2p_client/README.md +0 -0
  37. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/p2p_libp2p_client/__init__.py +0 -0
  38. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/p2p_libp2p_client/connection.py +0 -0
  39. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/helpers/p2p_libp2p_client/connection.yaml +0 -0
  40. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/prompt_to_ipfs.py +0 -0
  41. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/push_to_ipfs.py +0 -0
  42. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/subgraph.py +0 -0
  43. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/to_png.py +0 -0
  44. {mech_client-0.2.16 → mech_client-0.2.18}/mech_client/wss.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mech-client
3
- Version: 0.2.16
3
+ Version: 0.2.18
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 --unique-identifier <unique_identifier> --chain-config <chain_config>
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 --unique-identifier "6-claude-prediction-offline" --chain-config gnosis
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 --unique-identifier <unique_identifier> --chain-config <chain_config>
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 --unique-identifier "6-prediction-offline" --chain-config gnosis
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 |
@@ -204,12 +204,12 @@ You will see an output like this:
204
204
  To get the description of a specific tool, use the `tool-description` command. You need to specify the unique identifier of the tool.
205
205
 
206
206
  ```bash
207
- mechx tool-description --unique-identifier <unique_identifier> --chain-config <chain_config>
207
+ mechx tool-description <unique_identifier> --chain-config <chain_config>
208
208
  ```
209
209
  Example usage:
210
210
 
211
211
  ```bash
212
- mechx tool-description --unique-identifier "6-claude-prediction-offline" --chain-config gnosis
212
+ mechx tool-description "6-claude-prediction-offline" --chain-config gnosis
213
213
  ```
214
214
  You will see an output like this:
215
215
  ```bash
@@ -222,16 +222,22 @@ Description for tool 6-claude-prediction-offline: Makes a prediction using Claud
222
222
  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.
223
223
 
224
224
  ```bash
225
- mechx tool-io-schema --unique-identifier <unique_identifier> --chain-config <chain_config>
225
+ mechx tool-io-schema <unique_identifier> --chain-config <chain_config>
226
226
  ```
227
227
 
228
228
  Example usage:
229
229
 
230
230
  ```bash
231
- mechx tool-io-schema --unique-identifier "6-prediction-offline" --chain-config gnosis
231
+ mechx tool-io-schema "6-prediction-offline" --chain-config gnosis
232
232
  ```
233
233
  You will see an output like this:
234
234
  ```bash
235
+ Tool Details:
236
+ +---------------------------+-----------------------------------------------+
237
+ | Tool Name | Tool Description |
238
+ +===========================+===============================================+
239
+ | OpenAI Prediction Offline | Makes a prediction using OpenAI GPT-3.5 Turbo |
240
+ +---------------------------+-----------------------------------------------+
235
241
  Input Schema:
236
242
  +-------------+----------------------------------+
237
243
  | Field | Value |
@@ -0,0 +1,3 @@
1
+ """Mech client."""
2
+
3
+ __version__ = "0.2.18"
@@ -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
- (str(tool["tool_name"]), str(tool["unique_identifier"]))
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 = ["Agent ID", "Tool Name", "Unique Identifier"]
180
+ headers = [
181
+ "Agent ID",
182
+ "Tool Name",
183
+ "Unique Identifier",
184
+ "Mech Marketplace Support",
185
+ ]
186
+
177
187
  data = [
178
- (str(agent_id), str(tool_name), f"{agent_id}-{tool_name}")
179
- for agent_id, tools in result["agent_tools_map"].items()
180
- for tool_name in tools
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
- io_schema = get_tool_io_schema(tool_id, chain_config)
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, io_schema["input"][key]) for key in io_schema["input"]]
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 io_schema["output"]["schema"]:
221
- for key, value in io_schema["output"]["schema"]["properties"].items():
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"))
@@ -455,6 +455,7 @@ def wait_for_data_url( # pylint: disable=too-many-arguments
455
455
  :rtype: Any
456
456
  """
457
457
  loop = asyncio.new_event_loop()
458
+ asyncio.set_event_loop(loop)
458
459
  tasks = []
459
460
 
460
461
  if confirmation_type in (
@@ -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
- tools = get_agent_tools(agent_id, chain_config)
82
- if isinstance(tools, list):
83
- tools_with_ids = [
84
- {"tool_name": tool, "unique_identifier": f"{agent_id}-{tool}"}
85
- for tool in tools
86
- ]
87
- else:
88
- tools_with_ids = []
89
- return {"agent_id": agent_id, "tools": tools_with_ids}
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
- tools = get_agent_tools(current_agent_id, chain_config)
96
- if isinstance(tools, list):
97
- tools_with_ids = [
98
- {
99
- "tool_name": tool,
100
- "unique_identifier": f"{current_agent_id}-{tool}",
101
- }
102
- for tool in tools
103
- ]
104
- agent_tools_map[current_agent_id] = tools
105
- all_tools_with_ids.extend(tools_with_ids)
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
  [tool.poetry]
2
2
  name = "mech-client"
3
- version = "0.2.16"
3
+ version = "0.2.18"
4
4
  description = "Basic client to interact with a mech"
5
5
  authors = ["David Minarsch <david.minarsch@googlemail.com>"]
6
6
  readme = "README.md"
@@ -1,3 +0,0 @@
1
- """Mech client."""
2
-
3
- __version__ = "0.2.16"
File without changes