WatsonxToolkit#

class langchain_ibm.toolkit.WatsonxToolkit[source]#

Bases: BaseToolkit

IBM watsonx.ai Toolkit.

Setup

To use, you should have langchain_ibm python package installed, and the environment variable WATSONX_APIKEY set with your API key, or pass it as a named parameter to the constructor.

pip install -U langchain-ibm
export WATSONX_APIKEY="your-api-key"

Example

from langchain_ibm import WatsonxToolkit

watsonx_toolkit = WatsonxToolkit(
    url="https://us-south.ml.cloud.ibm.com",
    apikey="*****",
    project_id="*****",
)
tools = watsonx_toolkit.get_tools()

google_search = watsonx_toolkit.get_tool("GoogleSearch")

config = {
    "maxResults": 3,
}
input = {
    "input": "Search IBM",
    "config": config,
}
search_result = google_search.invoke(input=input)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

param apikey: SecretStr | None [Optional]#

API key to the watsonx.ai Runtime.

param project_id: str | None = None#

ID of the watsonx.ai Studio project.

param space_id: str | None = None#

ID of the watsonx.ai Studio space.

param token: SecretStr | None [Optional]#

Token to the watsonx.ai Runtime.

param url: SecretStr [Optional]#

URL to the watsonx.ai Runtime.

param verify: str | bool | None = None#

You can pass one of following as verify: * the path to a CA_BUNDLE file * the path of directory with certificates of trusted CAs * True - default path to truststore will be taken * False - no verification will be made

param watsonx_client: APIClient | None = None#
get_tool(tool_name: str) WatsonxTool[source]#

Get the tool with a given name.

Parameters:

tool_name (str)

Return type:

WatsonxTool

get_tools() list[WatsonxTool][source]#

Get the tools in the toolkit.

Return type:

list[WatsonxTool]