diff --git a/src/oss/javascript/integrations/tools/ibm.mdx b/src/oss/javascript/integrations/tools/ibm.mdx index 6119151eb..bc44ded3e 100644 --- a/src/oss/javascript/integrations/tools/ibm.mdx +++ b/src/oss/javascript/integrations/tools/ibm.mdx @@ -19,7 +19,7 @@ The toolkit contains following tools: | Class | Package | [PY support](https://python.langchain.com/docs/integrations/tools/ibm_watsonx/) | Version | | :--- | :--- | :---: | :---: | -| [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&) | +| [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&) | ## Setup diff --git a/src/oss/python/integrations/chat/ibm_watsonx.mdx b/src/oss/python/integrations/chat/ibm_watsonx.mdx index f625b2c39..8a71a683a 100644 --- a/src/oss/python/integrations/chat/ibm_watsonx.mdx +++ b/src/oss/python/integrations/chat/ibm_watsonx.mdx @@ -45,7 +45,7 @@ Additionally you are able to pass additional secrets as an environment variable. import os os.environ["WATSONX_URL"] = "your service instance url" -os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster" +os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster" os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster" os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster" os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster" diff --git a/src/oss/python/integrations/llms/ibm_watsonx.mdx b/src/oss/python/integrations/llms/ibm_watsonx.mdx index fe4e20340..b71d5c719 100644 --- a/src/oss/python/integrations/llms/ibm_watsonx.mdx +++ b/src/oss/python/integrations/llms/ibm_watsonx.mdx @@ -39,7 +39,7 @@ Additionaly you are able to pass additional secrets as an environment variable. import os os.environ["WATSONX_URL"] = "your service instance url" -os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster" +os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster" os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster" os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster" os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster" diff --git a/src/oss/python/integrations/providers/ibm.mdx b/src/oss/python/integrations/providers/ibm.mdx index eddc889fb..45a7ae5f0 100644 --- a/src/oss/python/integrations/providers/ibm.mdx +++ b/src/oss/python/integrations/providers/ibm.mdx @@ -86,7 +86,7 @@ from langchain_ibm import WatsonxRerank See a [usage example](/oss/integrations/tools/ibm_watsonx). ```python -from langchain_ibm import WatsonxToolkit +from langchain_ibm.agent_toolkits.utility import WatsonxToolkit ``` ## DB2 diff --git a/src/oss/python/integrations/retrievers/ibm_watsonx_ranker.mdx b/src/oss/python/integrations/retrievers/ibm_watsonx_ranker.mdx index 32c6e01ce..1c77b2505 100644 --- a/src/oss/python/integrations/retrievers/ibm_watsonx_ranker.mdx +++ b/src/oss/python/integrations/retrievers/ibm_watsonx_ranker.mdx @@ -39,7 +39,7 @@ Additionally you are able to pass additional secrets as an environment variable. import os os.environ["WATSONX_URL"] = "your service instance url" -os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster" +os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster" os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster" os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster" os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster" diff --git a/src/oss/python/integrations/text_embedding/ibm_watsonx.mdx b/src/oss/python/integrations/text_embedding/ibm_watsonx.mdx index 07f496d6e..fb787a750 100644 --- a/src/oss/python/integrations/text_embedding/ibm_watsonx.mdx +++ b/src/oss/python/integrations/text_embedding/ibm_watsonx.mdx @@ -37,7 +37,7 @@ Additionaly you are able to pass additional secrets as an environment variable. import os os.environ["WATSONX_URL"] = "your service instance url" -os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster" +os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster" os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster" os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster" os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster" diff --git a/src/oss/python/integrations/tools/ibm_watsonx.mdx b/src/oss/python/integrations/tools/ibm_watsonx.mdx index 2f705cca6..21b32dee0 100644 --- a/src/oss/python/integrations/tools/ibm_watsonx.mdx +++ b/src/oss/python/integrations/tools/ibm_watsonx.mdx @@ -12,7 +12,7 @@ This example shows how to use `watsonx.ai` Toolkit using `LangChain`. | Class | Package | Serializable | [JS support](https://js.langchain.com/docs/integrations/toolkits/ibm/) | Downloads | Version | | :--- | :--- | :---: | :---: | :---: | :---: | -| [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) | +| [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) | ## Setup @@ -39,7 +39,10 @@ Additionaly you are able to pass additional secrets as an environment variable. import os os.environ["WATSONX_URL"] = "your service instance url" -os.environ["WATSONX_TOKEN"] = "your token for accessing the service instance" +os.environ["WATSONX_TOKEN"] = "your token for accessing the CLOUD or CPD cluster" +os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster" +os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster" +os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster" ``` ### Installation @@ -55,13 +58,15 @@ The LangChain IBM integration lives in the `langchain-ibm` package: Initialize the `WatsonxToolkit` class. ```python -from langchain_ibm import WatsonxToolkit +from langchain_ibm.agent_toolkits.utility import WatsonxToolkit watsonx_toolkit = WatsonxToolkit( url="https://us-south.ml.cloud.ibm.com", ) ``` +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). + 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. ```python @@ -84,6 +89,10 @@ It is possible to get all available tools as a list of `WatsonxTool` objects. watsonx_toolkit.get_tools() ``` + + The list of available tools may vary depending on whether it is IBM watsonx.ai for IBM Cloud or IBM watsonx.ai software. + + ```output [WatsonxTool(name='GoogleSearch', description='Search for online trends, news, current events, real-time information, or research topics.', args_schema=, 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=), WatsonxTool(name='WebCrawler', description='Useful for when you need to summarize a webpage. Do not use for Web search.', args_schema=, 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=), @@ -105,7 +114,7 @@ google_search = watsonx_toolkit.get_tool(tool_name="GoogleSearch") ### Invoke the tool with a simple input ```python -search_result = google_search.invoke(input="IBM") +search_result = google_search.invoke({"q": "IBM"}) search_result ``` @@ -149,7 +158,7 @@ import json config = {"maxResults": 3} google_search.set_tool_config(config) -search_result = google_search.invoke(input="IBM") +search_result = google_search.invoke({"q": "IBM"}) output = json.loads(search_result.get("output")) ```