diff --git a/README.md b/README.md index 92327f3..17d00f1 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,12 @@ mechx tool-io-schema "6-prediction-offline" --chain-config gnosis ``` You will see an output like this: ```bash +Tool Details: ++---------------------------+-----------------------------------------------+ +| Tool Name | Tool Description | ++===========================+===============================================+ +| OpenAI Prediction Offline | Makes a prediction using OpenAI GPT-3.5 Turbo | ++---------------------------+-----------------------------------------------+ Input Schema: +-------------+----------------------------------+ | Field | Value | diff --git a/mech_client/cli.py b/mech_client/cli.py index 3ee8f4c..0419fd7 100644 --- a/mech_client/cli.py +++ b/mech_client/cli.py @@ -231,18 +231,35 @@ def tool_description(tool_id: str, chain_config: str) -> None: @click.argument("tool_id") @click.option("--chain-config", default="gnosis", help="Chain configuration to use.") def tool_io_schema(tool_id: str, chain_config: str) -> None: - """Fetch and display the input/output schema for a specific tool.""" + """Fetch and display the tool's name and description along with the input/output schema for a specific tool.""" try: - io_schema = get_tool_io_schema(tool_id, chain_config) + result = get_tool_io_schema(tool_id, chain_config) + + name = result["name"] + description = result["description"] # Prepare data for tabulation - input_schema = [(key, io_schema["input"][key]) for key in io_schema["input"]] + input_schema = [(key, result["input"][key]) for key in result["input"]] # Handling nested output schema output_schema = [] - if "properties" in io_schema["output"]["schema"]: - for key, value in io_schema["output"]["schema"]["properties"].items(): + if "properties" in result["output"]["schema"]: + for key, value in result["output"]["schema"]["properties"].items(): output_schema.append((key, value["type"], value.get("description", ""))) + # Display tool details in tabulated format + click.echo("Tool Details:") + click.echo( + tabulate( + [ + [ + name, + description, + ] + ], + headers=["Tool Name", "Tool Description"], + tablefmt="grid", + ) + ) # Display schemas in tabulated format click.echo("Input Schema:") click.echo(tabulate(input_schema, headers=["Field", "Value"], tablefmt="grid")) diff --git a/mech_client/mech_tool_management.py b/mech_client/mech_tool_management.py index 849efaa..d8c2d86 100644 --- a/mech_client/mech_tool_management.py +++ b/mech_client/mech_tool_management.py @@ -170,11 +170,11 @@ def get_tool_io_schema( unique_identifier: str, chain_config: str = "gnosis" ) -> Dict[str, Any]: """ - Fetch the input and output schema of a specific tool based on a unique identifier. + Fetch the input and output schema along with tool name and description of a specific tool based on a unique identifier. :param unique_identifier: The unique identifier for the tool. :param chain_config: The chain configuration to use. - :return: Dictionary containing input and output schemas. + :return: Dictionary containing name, description, input and output schemas. """ parts = unique_identifier.split("-") agent_id = int(parts[0]) @@ -196,6 +196,8 @@ def get_tool_io_schema( tool_info = tool_metadata.get(tool_name, {}) if isinstance(tool_info, dict): return { + "name": tool_info.get("name", {}), + "description": tool_info.get("description", {}), "input": tool_info.get("input", {}), "output": tool_info.get("output", {}), }