From 1a98ecdc407ecf5f469b486ad80fbc6dbbf6b58e Mon Sep 17 00:00:00 2001 From: FilipZmijewski Date: Tue, 26 Nov 2024 11:19:27 +0100 Subject: [PATCH 1/7] Main ibm community update to main (#34) * Fixed missing tool_choice in call options of chat (#30) * Add rerank implementation to existing IBM community implementation (#25) Extend existing implementation - rename variables to camelCase - remove default values for model - Update and remove some tests - update urls in documentation, shrink outputs * Add fixes according to review (#32) * Add fixes according to review * Upload config info * Fix notebooks * Fix notebook * Add to sidebar * Show in docs * Fix doc --------- Co-authored-by: jacoblee93 From f9a232b571ee83546aef6e1cf7eef4d24141c362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=BBmijewski?= Date: Tue, 3 Dec 2024 09:28:31 +0100 Subject: [PATCH 2/7] Remove docs for depricated code --- .../docs/integrations/llms/watsonx_ai.mdx | 40 ------------------- examples/src/llms/watsonx_ai.ts | 18 --------- 2 files changed, 58 deletions(-) delete mode 100644 docs/core_docs/docs/integrations/llms/watsonx_ai.mdx delete mode 100644 examples/src/llms/watsonx_ai.ts diff --git a/docs/core_docs/docs/integrations/llms/watsonx_ai.mdx b/docs/core_docs/docs/integrations/llms/watsonx_ai.mdx deleted file mode 100644 index 090a0acb274e..000000000000 --- a/docs/core_docs/docs/integrations/llms/watsonx_ai.mdx +++ /dev/null @@ -1,40 +0,0 @@ -# WatsonX AI - -LangChain.js supports integration with IBM WatsonX AI. Checkout [WatsonX AI](https://www.ibm.com/products/watsonx-ai) for a list of available models. - -## Setup - -You will need to set the following environment variables for using the WatsonX AI API. - -1. `IBM_CLOUD_API_KEY` which can be generated via [IBM Cloud](https://cloud.ibm.com/iam/apikeys) -2. `WATSONX_PROJECT_ID` which can be found in your [project's manage tab](https://dataplatform.cloud.ibm.com/projects/?context=wx) - -Alternatively, these can be set during the WatsonxAI Class instantiation as `ibmCloudApiKey` and `projectId` respectively. -For example: - -```typescript -const model = new WatsonxAI({ - ibmCloudApiKey: "My secret IBM Cloud API Key" - projectId: "My secret WatsonX AI Project id" -}); -``` - -## Usage - -import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx"; - - - -```bash npm2yarn -npm install @langchain/community @langchain/core -``` - -import CodeBlock from "@theme/CodeBlock"; -import WatsonxAiExample from "@examples/llms/watsonx_ai.ts"; - -{WatsonxAiExample} - -## Related - -- LLM [conceptual guide](/docs/concepts/text_llms) -- LLM [how-to guides](/docs/how_to/#llms) diff --git a/examples/src/llms/watsonx_ai.ts b/examples/src/llms/watsonx_ai.ts deleted file mode 100644 index c9b700cf848b..000000000000 --- a/examples/src/llms/watsonx_ai.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { WatsonxAI } from "@langchain/community/llms/watsonx_ai"; - -// Note that modelParameters are optional -const model = new WatsonxAI({ - modelId: "meta-llama/llama-2-70b-chat", - modelParameters: { - max_new_tokens: 100, - min_new_tokens: 0, - stop_sequences: [], - repetition_penalty: 1, - }, -}); - -const res = await model.invoke( - "What would be a good company name for a company that makes colorful socks?" -); - -console.log({ res }); From f5a6cfb6d78745985977375672de2b77d4680bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=BBmijewski?= Date: Wed, 4 Dec 2024 11:47:58 +0100 Subject: [PATCH 3/7] Add redirection --- docs/core_docs/vercel.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/core_docs/vercel.json b/docs/core_docs/vercel.json index 236cab60f05d..a853d04c5419 100644 --- a/docs/core_docs/vercel.json +++ b/docs/core_docs/vercel.json @@ -80,6 +80,10 @@ { "source": "/docs/troubleshooting/errors/MULTIPLE_SUBGRAPHS(/?)", "destination": "https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/MULTIPLE_SUBGRAPHS/" + }, + { + "source": "/docs/integrations/llms/watsonx_ai(/?)", + "destination": "https://js.langchain.com/docs/integrations/llms/ibm/" } ] } \ No newline at end of file From 853de868f660483c8d8aeea1deb5abdc13c98212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=BBmijewski?= Date: Wed, 4 Dec 2024 11:52:48 +0100 Subject: [PATCH 4/7] Change url in notebook --- docs/core_docs/docs/integrations/document_compressors/ibm.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb b/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb index 9645a4e126a3..94d5a1deca07 100644 --- a/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb +++ b/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb @@ -27,7 +27,7 @@ "\n", "### Integration details\n", "\n", - "| Class | Package | [PY support](https://python.langchain.com/docs/integrations/llms/ibm_watsonx/) | Package downloads | Package latest |\n", + "| Class | Package | [PY support](https://python.langchain.com/docs/integrations/retrievers/ibm_watsonx_ranker/) | Package downloads | Package latest |\n", "| :--- | :--- | :---: | :---: | :---: |\n", "| [`WatsonxRerank`](https://api.js.langchain.com/modules/_langchain_community.document_compressors_ibm.WatsonxRerank.html) | [@langchain/community](https://www.npmjs.com/package/@langchain/community) | ✅ | ![NPM - Downloads](https://img.shields.io/npm/dm/@langchain/community?style=flat-square&label=%20&) | ![NPM - Version](https://img.shields.io/npm/v/@langchain/community?style=flat-square&label=%20&) |\n", "\n", From d4dc7af2c5e18d26cd497d8d14593365a0da2829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=BBmijewski?= Date: Wed, 8 Jan 2025 15:32:41 +0100 Subject: [PATCH 5/7] Change model --- .../docs/integrations/document_compressors/ibm.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb b/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb index 94d5a1deca07..a6416a1816de 100644 --- a/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb +++ b/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb @@ -159,7 +159,7 @@ " version: \"2024-05-31\",\n", " serviceUrl: process.env.WATSONX_AI_SERVICE_URL,\n", " projectId: process.env.WATSONX_AI_PROJECT_ID,\n", - " model: \"ibm/slate-125m-english-rtrvr\",\n", + " model: \"cross-encoder/ms-marco-minilm-l-12-v2\",\n", "});" ] }, @@ -266,7 +266,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "fad30397", "metadata": {}, "outputs": [ @@ -290,7 +290,7 @@ " version: \"2024-05-31\",\n", " serviceUrl: process.env.WATSONX_AI_SERVICE_URL,\n", " projectId: process.env.WATSONX_AI_PROJECT_ID,\n", - " model: \"ibm/slate-125m-english-rtrvr\",\n", + " model: \"cross-encoder/ms-marco-minilm-l-12-v2\",\n", "});\n", "const compressed = await reranker.rerank(result, query);\n", "console.log(compressed);" From ec89f3603449d1a209d3100f12a085c8d2e76652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=BBmijewski?= Date: Wed, 8 Jan 2025 15:36:42 +0100 Subject: [PATCH 6/7] Fix broken urls --- .../docs/integrations/document_compressors/ibm.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb b/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb index a6416a1816de..a48e8804fed3 100644 --- a/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb +++ b/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb @@ -23,13 +23,13 @@ "\n", "## Overview\n", "\n", - "This will help you getting started with the [Watsonx document compressor](/docs/concepts/#document_compressors). For detailed documentation of all Watsonx document compressor features and configurations head to the [API reference]https://api.js.langchain.com/modules/_langchain_community.document_compressors_ibm.WatsonxRerank.html).\n", + "This will help you getting started with the [Watsonx document compressor](/docs/concepts/#document_compressors). For detailed documentation of all Watsonx document compressor features and configurations head to the [API reference](https://api.js.langchain.com/modules/_langchain_community.document_compressors_ibm.html).\n", "\n", "### Integration details\n", "\n", "| Class | Package | [PY support](https://python.langchain.com/docs/integrations/retrievers/ibm_watsonx_ranker/) | Package downloads | Package latest |\n", "| :--- | :--- | :---: | :---: | :---: |\n", - "| [`WatsonxRerank`](https://api.js.langchain.com/modules/_langchain_community.document_compressors_ibm.WatsonxRerank.html) | [@langchain/community](https://www.npmjs.com/package/@langchain/community) | ✅ | ![NPM - Downloads](https://img.shields.io/npm/dm/@langchain/community?style=flat-square&label=%20&) | ![NPM - Version](https://img.shields.io/npm/v/@langchain/community?style=flat-square&label=%20&) |\n", + "| [`WatsonxRerank`](https://api.js.langchain.com/classes/_langchain_community.document_compressors_ibm.WatsonxRerank.html) | [@langchain/community](https://www.npmjs.com/package/@langchain/community) | ✅ | ![NPM - Downloads](https://img.shields.io/npm/dm/@langchain/community?style=flat-square&label=%20&) | ![NPM - Version](https://img.shields.io/npm/v/@langchain/community?style=flat-square&label=%20&) |\n", "\n", "## Setup\n", "\n", From d2fe7d0a8ca672ec918ecb42c3dc19759795fd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=BBmijewski?= Date: Wed, 8 Jan 2025 15:37:32 +0100 Subject: [PATCH 7/7] Fix broken urls --- .../docs/integrations/document_compressors/ibm.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb b/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb index a48e8804fed3..4bf4e42ac475 100644 --- a/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb +++ b/docs/core_docs/docs/integrations/document_compressors/ibm.ipynb @@ -181,7 +181,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "51a60dbe-9f2e-4e04-bb62-23968f17164a", "metadata": {}, "outputs": [ @@ -363,7 +363,7 @@ "source": [ "## API reference\n", "\n", - "For detailed documentation of all Watsonx document compressor features and configurations head to the [API reference](https://api.js.langchain.com/modules/_langchain_community.document_compressors_ibm.WatsonxRerank.html)." + "For detailed documentation of all Watsonx document compressor features and configurations head to the [API reference](https://api.js.langchain.com/modules/_langchain_community.document_compressors_ibm.html)." ] } ],