Toolkit¶
- class ibm_watsonx_ai.foundation_models.utils.Toolkit(api_client)[source]¶
Bases:
WMLResource
Toolkit for utility agent tools.
- Parameters:
api_client (APIClient) – initialized APIClient object
Example:
from ibm_watsonx_ai import APIClient, Credentials from ibm_watsonx_ai.foundation_models.utils import Toolkit credentials = Credentials( url = "<url>", api_key = IAM_API_KEY ) api_client = APIClient(credentials) toolkit = Toolkit(api_client=api_client)
Tool¶
- class ibm_watsonx_ai.foundation_models.utils.Tool(api_client, name, description, agent_description=None, input_schema=None, config_schema=None)[source]¶
Bases:
WMLResource
Instantiate the utility agent tool.
- Parameters:
api_client (APIClient) – initialized APIClient object
name (str) – name of the tool
description (str) – description of what the tool is used for
agent_description (str, optional) – the precise instruction to agent LLMs and should be treated as part of the system prompt, if not provided, description can be used in its place
input_schema (dict, optional) – schema of the input that is provided when running the tool if applicable
config_schema (dict, optional) – schema of the config that is provided when running the tool if applicable
- run(input, config=None)[source]¶
Run a utility agent tool given input.
- Parameters:
input – input to be used when running tool
config (dict, optional) – configuration options that can be passed for some tools, must match the config schema for the tool
- Returns:
the output from running the tool
- Return type:
dict
Example for the tool without input schema:
toolkit = Toolkit(api_client=api_client) google_search = toolkit.get_tool(tool_name='GoogleSearch') result = google_search.run(input="Search IBM")
Example for the tool with input schema:
toolkit = Toolkit(api_client=api_client) weather_tool = toolkit.get_tool(tool_name='Weather') tool_input = {"name": "New York"} result = weather_tool.run(input=tool_input)