From 221c96e7b4ca17677020cb14a09f4e644a93de97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=9Awita=C5=82a?= <151041464+Mateusz-Switala@users.noreply.github.com> Date: Thu, 11 Sep 2025 04:14:43 +0200 Subject: [PATCH] docs: fix import path in `WatsonxToolkit` after releasing langchain-ibm 0.3.17 (#32746) Thank you for contributing to LangChain! Follow these steps to mark your pull request as ready for review. **If any of these steps are not completed, your PR will not be considered for review.** - [x] **PR title**: Follows the format: {TYPE}({SCOPE}): {DESCRIPTION} - Examples: - feat(core): add multi-tenant support - fix(cli): resolve flag parsing error - docs(openai): update API usage examples - Allowed `{TYPE}` values: - feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert, release - Allowed `{SCOPE}` values (optional): - core, cli, langchain, standard-tests, docs, anthropic, chroma, deepseek, exa, fireworks, groq, huggingface, mistralai, nomic, ollama, openai, perplexity, prompty, qdrant, xai - Note: the `{DESCRIPTION}` must not start with an uppercase letter. - Once you've written the title, please delete this checklist item; do not include it in the PR. - [x] **PR message**: - **Description:** Fixing the import path for `WatsonxToolkit` in examples after releasing `lnagchain-ibm==0.3.17` - [ ] **Add tests and docs**: If you're adding a new integration, you must include: 1. A test for the integration, preferably unit tests that do not rely on network access, 2. An example notebook showing its use. It lives in `docs/docs/integrations` directory. - [ ] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. **We will not consider a PR unless these three are passing in CI.** See [contribution guidelines](https://python.langchain.com/docs/contributing/) for more. Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to `pyproject.toml` files (even optional ones) unless they are **required** for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. --- docs/docs/integrations/providers/ibm.mdx | 2 +- .../docs/integrations/tools/ibm_watsonx.ipynb | 53 +++++++++++++++---- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/docs/docs/integrations/providers/ibm.mdx b/docs/docs/integrations/providers/ibm.mdx index a0ef1e76f72..ec1fc388746 100644 --- a/docs/docs/integrations/providers/ibm.mdx +++ b/docs/docs/integrations/providers/ibm.mdx @@ -77,7 +77,7 @@ from langchain_ibm import WatsonxRerank See a [usage example](/docs/integrations/tools/ibm_watsonx). ```python -from langchain_ibm import WatsonxToolkit +from langchain_ibm.agent_toolkits.utility import WatsonxToolkit ``` ## DB2 diff --git a/docs/docs/integrations/tools/ibm_watsonx.ipynb b/docs/docs/integrations/tools/ibm_watsonx.ipynb index 50f8963cda3..c0c4a3b119a 100644 --- a/docs/docs/integrations/tools/ibm_watsonx.ipynb +++ b/docs/docs/integrations/tools/ibm_watsonx.ipynb @@ -30,7 +30,7 @@ "\n", "| Class | Package | Serializable | [JS support](https://js.langchain.com/docs/integrations/toolkits/ibm/) | Package downloads | Package latest |\n", "| :--- | :--- | :---: | :---: | :---: | :---: |\n", - "| [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) |" ] }, { @@ -78,7 +78,9 @@ "import os\n", "\n", "os.environ[\"WATSONX_URL\"] = \"your service instance url\"\n", - "os.environ[\"WATSONX_TOKEN\"] = \"your token for accessing the service instance\"" + "os.environ[\"WATSONX_TOKEN\"] = \"your token for accessing the CLOUD or CPD cluster\"\n", + "os.environ[\"WATSONX_PASSWORD\"] = \"your password for accessing the CPD cluster\"\n", + "os.environ[\"WATSONX_USERNAME\"] = \"your username for accessing the CPD cluster\"" ] }, { @@ -116,17 +118,38 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "from langchain_ibm import WatsonxToolkit\n", + "from langchain_ibm.agent_toolkits.utility import WatsonxToolkit\n", "\n", "watsonx_toolkit = WatsonxToolkit(\n", " url=\"https://us-south.ml.cloud.ibm.com\",\n", ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "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). " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "watsonx_toolkit = WatsonxToolkit(\n", + " url=\"PASTE YOUR URL HERE\",\n", + " username=\"PASTE YOUR USERNAME HERE\",\n", + " password=\"PASTE YOUR PASSWORD HERE\",\n", + " version=\"5.2\",\n", + ")" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -153,7 +176,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Tools\n" + "## Tools" ] }, { @@ -187,6 +210,14 @@ "watsonx_toolkit.get_tools()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "> **NOTE** \n", + "> The list of available tools may vary depending on whether it is IBM watsonx.ai for IBM Cloud or IBM watsonx.ai software." + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -220,7 +251,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -235,7 +266,7 @@ } ], "source": [ - "search_result = google_search.invoke(input=\"IBM\")\n", + "search_result = google_search.invoke({\"q\": \"IBM\"})\n", "search_result" ] }, @@ -308,7 +339,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -317,7 +348,7 @@ "config = {\"maxResults\": 3}\n", "google_search.set_tool_config(config)\n", "\n", - "search_result = google_search.invoke(input=\"IBM\")\n", + "search_result = google_search.invoke({\"q\": \"IBM\"})\n", "output = json.loads(search_result.get(\"output\"))" ] }, @@ -578,13 +609,13 @@ "source": [ "## API reference\n", "\n", - "For detailed documentation of all `WatsonxToolkit` features and configurations head to the [API reference](https://python.langchain.com/api_reference/ibm/toolkit/langchain_ibm.toolkit.WatsonxToolkit.html)." + "For detailed documentation of all `WatsonxToolkit` features and configurations head to the [API reference](https://python.langchain.com/api_reference/ibm/agent_toolkits/langchain_ibm.agent_toolkits.utility.toolkit.WatsonxToolkit.html)." ] } ], "metadata": { "kernelspec": { - "display_name": "langchain_env", + "display_name": "langchain_ibm_repo_env", "language": "python", "name": "python3" },