Listing Tools

To list all tools available in your project, use the list_tools method:

Python
my_tools = client.tools.list_tools()
my_tools
[Tool(tool_id="xxxxxxxx", name="Tool 1"), Tool(tool_id="xxxxxxxx", name="Tool 2")]

Retrieving a Tool

To retrieve a specific tool, use the retrieve_tool method with the tool_id:

Python
my_tool = client.tools.retrieve_tool(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")

my_tool
Tool(tool_id="xxxxxxxx", name="Tool 1")

Triggering a Tool

To trigger a tool with specific parameters, use the trigger_tool method:

Python
params = {
    "text": "Yes",
    "long_text": "This is a long text",
}

tool_output = client.tools.trigger_tool(
    tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    params=params
)

tool_output
ToolOutput(output="Result of the tool execution")

Getting Tool Parameters as JSON

To get the parameters of a tool as a JSON string, use the _get_params_as_json_string method:

Python
params_json = client.tools._get_params_as_json_string(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
params_json
{
    "text": {
        "type": "string",
        "order": 0,
        "title": "",
        "metadata": {}
    },
    "long_text": {
        "type": "string",
        "metadata": {
            "content_type": "long_text"
        },
        "order": 1
    }
}

Getting Tool Steps as JSON

To get the steps of a tool as a JSON string, use the _get_steps_as_json_string method:

Python
steps_json = client.tools._get_steps_as_json_string(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
steps_json
[
    {
        "transformation": "python_code_transformation",
        "name": "python",
        "params": {
            "code": "\nreturn {\"params\" : params, \"steps\": steps}"
        }
    }
]

Deleting a Tool

To delete a tool, use the delete_tool method with the tool_id:

Python
success = client.tools.delete_tool(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
success
True