WatsonxToolkit is a wrapper for IBM watsonx.ai Toolkit.This example shows how to use
watsonx.ai
Toolkit using LangChain
.
Overview
Integration details
Class | Package | Serializable | JS support | Downloads | Version |
---|---|---|---|---|---|
WatsonxToolkit | langchain-ibm | ❌ | ✅ |
Setup
To access IBM watsonx.ai toolkit you’ll need to create an IBM watsonx.ai account, get an API key, and install thelangchain-ibm
integration package.
Credentials
This cell defines the WML credentials required to work with watsonx Toolkit. Action: Provide the IBM Cloud user API key. For details, see documentation.Installation
The LangChain IBM integration lives in thelangchain-ibm
package:
Instantiation
Initialize theWatsonxToolkit
class.
APIClient
object into the WatsonxToolkit
class.
Tools
Get all tools
It is possible to get all available tools as a list ofWatsonxTool
objects.
The list of available tools may vary depending on whether it is IBM watsonx.ai for IBM Cloud or IBM watsonx.ai software.
Get a tool
You can also get a specificWatsonxTool
by name.
Invocation
Invoke the tool with a simple input
Invoke the tool with a configuration
To check if a tool has a config schema and view its properties you can look at the tool’stool_config_schema
.
In this example, the tool has a config schema that contains maxResults
parameter to set maximum number of results to be returned.
tool_config
parameters, you need to use set_tool_config()
method and pass correct dict
according to above tool_config_schema
.
Invoke the tool with an input schema
We need to get another tool (with an input schema) for the example purpose.tool_input_schema
.
In this example, the tool has an input schema that contains one required and one optional parameter.
invoke()
, you need to create an invoke_input
dictionary with required parameter as a key with its value.
Invoke the tool with a ToolCall
We can also invoke the tool with a ToolCall, in which case a ToolMessage will be returned:Use within an agent
API reference
For detailed documentation of allWatsonxToolkit
features and configurations head to the API reference.