Skip to content

Commit 581e2d0

Browse files
authored
oss: IBM integration fixes (#492)
Fixes langchain-ai/langchain#32746
1 parent 66e2b9e commit 581e2d0

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

src/oss/javascript/integrations/tools/ibm.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The toolkit contains following tools:
1919

2020
| Class | Package | [PY support](https://python.langchain.com/docs/integrations/tools/ibm_watsonx/) | Version |
2121
| :--- | :--- | :---: | :---: |
22-
| [WatsonxToolkit](https://api.js.langchain.com/classes/_langchain_community.agents_toolkits_ibm.WatsonxToolkit.html) | [`@langchain/community`](https://www.npmjs.com/package/@langchain/community) || ![NPM - Version](https://img.shields.io/npm/v/@langchain/community?style=flat-square&label=%20&) |
22+
| [WatsonxToolkit](https://python.langchain.com/api_reference/ibm/agent_toolkits/langchain_ibm.agent_toolkits.utility.toolkit.WatsonxToolkit.html) | [`@langchain/community`](https://www.npmjs.com/package/@langchain/community) || ![NPM - Version](https://img.shields.io/npm/v/@langchain/community?style=flat-square&label=%20&) |
2323

2424
## Setup
2525

src/oss/python/integrations/chat/ibm_watsonx.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Additionally you are able to pass additional secrets as an environment variable.
4545
import os
4646

4747
os.environ["WATSONX_URL"] = "your service instance url"
48-
os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster"
48+
os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster"
4949
os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster"
5050
os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster"
5151
os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster"

src/oss/python/integrations/llms/ibm_watsonx.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Additionaly you are able to pass additional secrets as an environment variable.
3939
import os
4040

4141
os.environ["WATSONX_URL"] = "your service instance url"
42-
os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster"
42+
os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster"
4343
os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster"
4444
os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster"
4545
os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster"

src/oss/python/integrations/providers/ibm.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ from langchain_ibm import WatsonxRerank
8686
See a [usage example](/oss/integrations/tools/ibm_watsonx).
8787

8888
```python
89-
from langchain_ibm import WatsonxToolkit
89+
from langchain_ibm.agent_toolkits.utility import WatsonxToolkit
9090
```
9191

9292
## DB2

src/oss/python/integrations/retrievers/ibm_watsonx_ranker.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Additionally you are able to pass additional secrets as an environment variable.
3939
import os
4040

4141
os.environ["WATSONX_URL"] = "your service instance url"
42-
os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster"
42+
os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster"
4343
os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster"
4444
os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster"
4545
os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster"

src/oss/python/integrations/text_embedding/ibm_watsonx.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Additionaly you are able to pass additional secrets as an environment variable.
3737
import os
3838

3939
os.environ["WATSONX_URL"] = "your service instance url"
40-
os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster"
40+
os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster"
4141
os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster"
4242
os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster"
4343
os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster"

src/oss/python/integrations/tools/ibm_watsonx.mdx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This example shows how to use `watsonx.ai` Toolkit using `LangChain`.
1212

1313
| Class | Package | Serializable | [JS support](https://js.langchain.com/docs/integrations/toolkits/ibm/) | Downloads | Version |
1414
| :--- | :--- | :---: | :---: | :---: | :---: |
15-
| [WatsonxToolkit](https://python.langchain.com/api_reference/ibm/toolkit/langchain_ibm.toolkit.WatsonxToolkit.html) | [langchain-ibm](https://python.langchain.com/api_reference/ibm/index.html) ||| ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-ibm?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-ibm?style=flat-square&label=%20) |
15+
| [WatsonxToolkit](https://python.langchain.com/api_reference/ibm/agent_toolkits/langchain_ibm.agent_toolkits.utility.toolkit.WatsonxToolkit.html) | [langchain-ibm](https://python.langchain.com/api_reference/ibm/index.html) ||| ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-ibm?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-ibm?style=flat-square&label=%20) |
1616

1717
## Setup
1818

@@ -39,7 +39,10 @@ Additionaly you are able to pass additional secrets as an environment variable.
3939
import os
4040

4141
os.environ["WATSONX_URL"] = "your service instance url"
42-
os.environ["WATSONX_TOKEN"] = "your token for accessing the service instance"
42+
os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster"
43+
os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster"
44+
os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster"
45+
os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster"
4346
```
4447

4548
### Installation
@@ -55,13 +58,15 @@ The LangChain IBM integration lives in the `langchain-ibm` package:
5558
Initialize the `WatsonxToolkit` class.
5659

5760
```python
58-
from langchain_ibm import WatsonxToolkit
61+
from langchain_ibm.agent_toolkits.utility import WatsonxToolkit
5962

6063
watsonx_toolkit = WatsonxToolkit(
6164
url="https://us-south.ml.cloud.ibm.com",
6265
)
6366
```
6467

68+
Alternatively, you can use Cloud Pak for Data credentials. For details, see [watsonx.ai software setup](https://ibm.github.io/watsonx-ai-python-sdk/setup_cpd.html).
69+
6570
For certain requirements, there is an option to pass the IBM's [`APIClient`](https://ibm.github.io/watsonx-ai-python-sdk/base.html#apiclient) object into the `WatsonxToolkit` class.
6671

6772
```python
@@ -84,6 +89,10 @@ It is possible to get all available tools as a list of `WatsonxTool` objects.
8489
watsonx_toolkit.get_tools()
8590
```
8691

92+
<Note>
93+
The list of available tools may vary depending on whether it is IBM watsonx.ai for IBM Cloud or IBM watsonx.ai software.
94+
</Note>
95+
8796
```output
8897
[WatsonxTool(name='GoogleSearch', description='Search for online trends, news, current events, real-time information, or research topics.', args_schema=<class 'langchain_ibm.toolkit.ToolArgsSchema'>, agent_description='Search for online trends, news, current events, real-time information, or research topics.', tool_config_schema={'title': 'config schema for GoogleSearch tool', 'type': 'object', 'properties': {'maxResults': {'title': 'Max number of results to return', 'type': 'integer', 'minimum': 1, 'maximum': 20}}}, watsonx_client=<ibm_watsonx_ai.client.APIClient object at 0x127e0f490>),
8998
WatsonxTool(name='WebCrawler', description='Useful for when you need to summarize a webpage. Do not use for Web search.', args_schema=<class 'langchain_ibm.toolkit.ToolArgsSchema'>, agent_description='Useful for when you need to summarize a webpage. Do not use for Web search.', tool_input_schema={'type': 'object', 'properties': {'url': {'title': 'url', 'description': 'URL for the webpage to be scraped', 'type': 'string', 'pattern': '^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$'}}, 'required': ['url']}, watsonx_client=<ibm_watsonx_ai.client.APIClient object at 0x127e0f490>),
@@ -105,7 +114,7 @@ google_search = watsonx_toolkit.get_tool(tool_name="GoogleSearch")
105114
### Invoke the tool with a simple input
106115

107116
```python
108-
search_result = google_search.invoke(input="IBM")
117+
search_result = google_search.invoke({"q": "IBM"})
109118
search_result
110119
```
111120

@@ -149,7 +158,7 @@ import json
149158
config = {"maxResults": 3}
150159
google_search.set_tool_config(config)
151160

152-
search_result = google_search.invoke(input="IBM")
161+
search_result = google_search.invoke({"q": "IBM"})
153162
output = json.loads(search_result.get("output"))
154163
```
155164

0 commit comments

Comments
 (0)