Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(community): For IBM implementation rename variables, remove defaults, fix tests and minor docs fixes #7129

Merged
merged 8 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 7 additions & 96 deletions docs/core_docs/docs/integrations/chat/ibm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
"source": [
"# IBM watsonx.ai\n",
"\n",
"This will help you getting started with IBM watsonx.ai [chat models](/docs/concepts/chat_models). For detailed documentation of all `IBM watsonx.ai` features and configurations head to the [IBM watsonx.ai](https://api.js.langchain.com/classes/_langchain_community.chat_models_ibm.html).\n",
"This will help you getting started with IBM watsonx.ai [chat models](/docs/concepts/chat_models). For detailed documentation of all `IBM watsonx.ai` features and configurations head to the [IBM watsonx.ai](https://api.js.langchain.com/modules/_langchain_community.chat_models_ibm.html).\n",
"\n",
"## Overview\n",
"### Integration details\n",
"\n",
"| Class | Package | Local | Serializable | [PY support](https://python.langchain.com/docs/integrations/chat/ibm_watsonx/) | Package downloads | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",
"| [`ChatWatsonx`](https://api.js.langchain.com/classes/_langchain_community.chat_models_ibm.html) | [@langchain/community](https://api.js.langchain.com/modules/langchain_community_llms_ibm.html) | ❌ | ✅ | ✅ | ![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",
"| [`ChatWatsonx`](https://api.js.langchain.com/classes/_langchain_community.chat_models_ibm.ChatWatsonx.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",
"### Model features\n",
"\n",
Expand Down Expand Up @@ -138,7 +139,7 @@
"<IntegrationInstallTooltip></IntegrationInstallTooltip>\n",
"\n",
"<Npm2Yarn>\n",
" __package_name__ @langchain/core\n",
" @langchain/community @langchain/core\n",
"</Npm2Yarn>\n",
"\n",
"```"
Expand Down Expand Up @@ -340,7 +341,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 1,
"id": "cd21e356",
"metadata": {},
"outputs": [
Expand All @@ -357,97 +358,7 @@
" only\n",
" natural\n",
" satellite\n",
" and\n",
" the\n",
" fifth\n",
" largest\n",
" satellite\n",
" in\n",
" the\n",
" Solar\n",
" System\n",
".\n",
" It\n",
" or\n",
"bits\n",
" Earth\n",
" every\n",
" \n",
"2\n",
"7\n",
".\n",
"3\n",
" days\n",
" and\n",
" rot\n",
"ates\n",
" on\n",
" its\n",
" axis\n",
" in\n",
" the\n",
" same\n",
" amount\n",
" of\n",
" time\n",
",\n",
" which\n",
" is\n",
" why\n",
" we\n",
" always\n",
" see\n",
" the\n",
" same\n",
" side\n",
" of\n",
" it\n",
".\n",
" The\n",
" Moon\n",
"'\n",
"s\n",
" phases\n",
" change\n",
" as\n",
" it\n",
" or\n",
"bits\n",
" Earth\n",
",\n",
" going\n",
" through\n",
" cycles\n",
" of\n",
" new\n",
",\n",
" c\n",
"res\n",
"cent\n",
",\n",
" half\n",
",\n",
" g\n",
"ib\n",
"b\n",
"ous\n",
",\n",
" and\n",
" full\n",
" phases\n",
".\n",
" Its\n",
" gravity\n",
" influences\n",
" Earth\n",
"'\n",
"s\n",
" t\n",
"ides\n",
" and\n",
" stabil\n",
"izes\n",
" our\n"
" and\n"
]
}
],
Expand Down Expand Up @@ -589,4 +500,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
16 changes: 8 additions & 8 deletions docs/core_docs/docs/integrations/llms/ibm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"# IBM watsonx.ai\n",
"\n",
"\n",
"This will help you get started with IBM [text completion models (LLMs)](/docs/concepts/text_llms) using LangChain. For detailed documentation on `IBM watsonx.ai` features and configuration options, please refer to the [IBM watsonx.ai](https://api.js.langchain.com/classes/_langchain_community.llms_ibm.html).\n",
"This will help you get started with IBM [text completion models (LLMs)](/docs/concepts/text_llms) using LangChain. For detailed documentation on `IBM watsonx.ai` features and configuration options, please refer to the [IBM watsonx.ai](https://api.js.langchain.com/modules/_langchain_community.llms_ibm.html).\n",
"\n",
"## Overview\n",
"### Integration details\n",
"\n",
"\n",
"| Class | Package | Local | Serializable | [PY support](https://python.langchain.com/docs/integrations/llms/ibm_watsonx/) | Package downloads | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",
"| [`IBM watsonx.ai`](https://api.js.langchain.com/modules/_langchain_community.llms_ibm.html) | [@langchain/community](https://api.js.langchain.com/modules/langchain_community_llms_ibm.html) | ❌ | ✅ | ✅ | ![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",
"| [`WatsonxLLM`](https://api.js.langchain.com/classes/_langchain_community.llms_ibm.WatsonxLLM.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",
Expand Down Expand Up @@ -161,11 +161,11 @@
"\n",
"const props = {\n",
" decoding_method: \"sample\",\n",
" max_new_tokens: 100,\n",
" min_new_tokens: 1,\n",
" maxNewTokens: 100,\n",
" minNewTokens: 1,\n",
" temperature: 0.5,\n",
" top_k: 50,\n",
" top_p: 1,\n",
" topK: 50,\n",
" topP: 1,\n",
"};\n",
"const instance = new WatsonxLLM({\n",
" version: \"YYYY-MM-DD\",\n",
Expand Down Expand Up @@ -298,7 +298,7 @@
"source": [
"const result2 = await instance.invoke(\"Print hello world.\", {\n",
" parameters: {\n",
" max_new_tokens: 20,\n",
" maxNewTokens: 100,\n",
" },\n",
"});\n",
"console.log(result2);"
Expand Down Expand Up @@ -358,4 +358,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
93 changes: 23 additions & 70 deletions docs/core_docs/docs/integrations/text_embedding/ibm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"# IBM watsonx.ai\n",
"\n",
"\n",
"This will help you get started with IBM watsonx.ai [embedding models](/docs/concepts/embedding_models) using LangChain. For detailed documentation on `IBM watsonx.ai` features and configuration options, please refer to the [API reference](https://api.js.langchain.com/classes/_langchain_community.embeddings_ibm.html).\n",
"This will help you get started with IBM watsonx.ai [embedding models](/docs/concepts/embedding_models) using LangChain. For detailed documentation on `IBM watsonx.ai` features and configuration options, please refer to the [API reference](https://api.js.langchain.com/modules/_langchain_community.embeddings_ibm.html).\n",
"\n",
"## Overview\n",
"### Integration details\n",
"\n",
"\n",
"| Class | Package | Local | [Py support](https://python.langchain.com/docs/integrations/text_embedding/ibm_watsonx/) | Package downloads | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: | :---: |\n",
"| [`IBM watsonx.ai`](https://api.js.langchain.com/classes/_langchain_community.embeddings_ibm.WatsonxEmbeddings.html) | [@langchain/community](https://api.js.langchain.com/modules/langchain_community_llms_ibm.html)| ❌ | ✅ | ![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",
"| [`WatsonxEmbeddings`](https://api.js.langchain.com/classes/_langchain_community.embeddings_ibm.WatsonxEmbeddings.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",
Expand Down Expand Up @@ -163,7 +163,6 @@
" serviceUrl: process.env.API_URL,\n",
" projectId: \"<PROJECT_ID>\",\n",
" spaceId: \"<SPACE_ID>\",\n",
" idOrName: \"<DEPLOYMENT_ID>\",\n",
" model: \"<MODEL_ID>\",\n",
"});"
]
Expand All @@ -175,7 +174,7 @@
"source": [
"Note:\n",
"\n",
"- You must provide `spaceId`, `projectId` or `idOrName`(deployment id) in order to proceed.\n",
"- You must provide `spaceId` or `projectId` in order to proceed.\n",
"- Depending on the region of your provisioned service instance, use correct serviceUrl."
]
},
Expand Down Expand Up @@ -243,7 +242,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 1,
"id": "0d2befcd",
"metadata": {},
"outputs": [
Expand All @@ -252,33 +251,18 @@
"output_type": "stream",
"text": [
"[\n",
" -0.017436018, -0.01469498, -0.015685871, -0.013543149, -0.0011519607,\n",
" -0.008123747, 0.015286108, -0.023845721, -0.02454774, 0.07235078,\n",
" -0.032333843, -0.0035843418, -0.015389036, 0.0455373, -0.021119863,\n",
" -0.022039745, 0.021746712, -0.017774817, -0.008232582, -0.036727764,\n",
" -0.015734928, 0.03606811, -0.005108186, -0.036052454, 0.024462992,\n",
" 0.02359307, 0.03273164, 0.009195497, -0.0077208397, -0.0127943,\n",
" -0.023869334, -0.029473905, -0.0080457395, -0.0021337876, 0.04949132,\n",
" 0.013950589, -0.010046689, 0.021029025, -0.031725302, 0.004251065,\n",
" -0.034171984, -0.03696642, -0.014253629, -0.017757406, -0.007531065,\n",
" 0.07187789, 0.009661725, 0.041889492, -0.04660478, 0.028036641,\n",
" 0.059334517, -0.04561291, 0.056029715, -0.00676024, 0.026493236,\n",
" 0.0116374, 0.050126843, -0.018036349, -0.013711887, 0.042252757,\n",
" -0.04453391, 0.04705777, -0.00044598224, -0.030227259, 0.029286578,\n",
" 0.0252211, 0.011694125, -0.031404093, 0.02951232, 0.08812359,\n",
" 0.023539362, -0.011082862, 0.008024676, 0.00084492035, -0.007984158,\n",
" -0.0005008702, -0.025189219, 0.021000557, -0.0065513053, 0.036524914,\n",
" 0.0015150858, -0.0042383806, 0.049065087, 0.000941666, 0.04447001,\n",
" 0.012942205, -0.078316726, -0.03004237, -0.025807172, -0.03446275,\n",
" -0.00932942, -0.044925686, 0.03190307, 0.010136769, -0.048854534,\n",
" 0.025738232, -0.017840309, 0.023738133, 0.014214792, 0.030452395\n",
" -0.017436018, -0.01469498,\n",
" -0.015685871, -0.013543149,\n",
" -0.0011519607, -0.008123747,\n",
" 0.015286108, -0.023845721,\n",
" -0.02454774, 0.07235078\n",
"]\n"
]
}
],
"source": [
" const singleVector = await embeddings.embedQuery(text);\n",
" singleVector.slice(0, 100);"
" singleVector.slice(0, 10);"
]
},
{
Expand All @@ -302,48 +286,18 @@
"output_type": "stream",
"text": [
"[\n",
" -0.017436024, -0.014695002, -0.01568589, -0.013543164, -0.001151976,\n",
" -0.008123703, 0.015286064, -0.023845702, -0.024547677, 0.07235076,\n",
" -0.032333862, -0.0035843418, -0.015389038, 0.045537304, -0.021119865,\n",
" -0.02203975, 0.021746716, -0.01777481, -0.008232588, -0.03672781,\n",
" -0.015734889, 0.036068108, -0.0051082, -0.036052432, 0.024462998,\n",
" 0.023593083, 0.03273162, 0.009195521, -0.007720828, -0.012794304,\n",
" -0.023869323, -0.029473891, -0.008045726, -0.002133793, 0.049491342,\n",
" 0.013950573, -0.010046691, 0.02102898, -0.03172528, 0.0042510596,\n",
" -0.034171965, -0.036966413, -0.014253668, -0.017757434, -0.007531062,\n",
" 0.07187787, 0.009661732, 0.041889492, -0.04660476, 0.028036654,\n",
" 0.059334517, -0.045612894, 0.056029722, -0.00676024, 0.026493296,\n",
" 0.0116374055, 0.050126873, -0.018036384, -0.013711868, 0.0422528,\n",
" -0.044533912, 0.047057763, -0.00044596897, -0.030227251, 0.029286569,\n",
" 0.025221113, 0.011694138, -0.03140413, 0.029512335, 0.08812357,\n",
" 0.023539348, -0.011082865, 0.008024677, 0.00084490055, -0.007984145,\n",
" -0.0005008745, -0.025189226, 0.021000564, -0.0065513197, 0.036524955,\n",
" 0.0015150585, -0.0042383634, 0.049065102, 0.000941638, 0.044469994,\n",
" 0.012942193, -0.078316696, -0.0300424, -0.025807157, -0.0344627,\n",
" -0.009329439, -0.04492573, 0.031903077, 0.010136808, -0.048854522,\n",
" 0.025738247, -0.01784033, 0.023738142, 0.014214801, 0.030452369\n",
" -0.017436024, -0.014695002,\n",
" -0.01568589, -0.013543164,\n",
" -0.001151976, -0.008123703,\n",
" 0.015286064, -0.023845702,\n",
" -0.024547677, 0.07235076\n",
"]\n",
"[\n",
" 0.03278884, -0.017893745, -0.0027520044, 0.016506646, 0.028271576,\n",
" -0.01284331, 0.014344065, -0.007968607, -0.03899479, 0.039327156,\n",
" -0.047726233, 0.009559004, -0.05302522, 0.011498492, -0.0055542476,\n",
" -0.0020940166, -0.029262392, -0.025919685, 0.024261741, -0.0010863725,\n",
" 0.0074619935, 0.014191284, -0.009054746, -0.038633537, 0.039744128,\n",
" 0.012625762, 0.030490868, 0.013526139, -0.024638629, -0.011268263,\n",
" -0.012759613, -0.04693565, -0.013087251, -0.01971696, 0.0125782555,\n",
" 0.024156926, -0.011638484, 0.017364893, -0.0405832, -0.0032466082,\n",
" -0.01611277, -0.022583133, 0.019492855, -0.03664484, -0.022627067,\n",
" 0.011026938, -0.014631298, 0.043255687, -0.029447634, 0.017212389,\n",
" 0.029366229, -0.041978795, 0.005347565, -0.0106230285, -0.008334342,\n",
" -0.008841154, 0.045096103, 0.03996879, -0.002039457, -0.0051824683,\n",
" -0.019464444, 0.092018366, -0.009283633, -0.020052811, 0.0043408144,\n",
" -0.029403884, 0.02587689, -0.027253918, 0.0159064, 0.0421537,\n",
" 0.05078811, -0.012380686, -0.018032575, 0.01711449, 0.03636163,\n",
" -0.014590949, -0.015076142, 0.00018201554, 0.002490666, 0.044776678,\n",
" 0.05301749, -0.007891316, 0.028668318, -0.0016632816, 0.04487743,\n",
" -0.032529455, -0.040372133, -0.020566158, -0.011109745, -0.01724949,\n",
" -0.0047519016, -0.041635286, 0.0068111843, 0.039498538, -0.02491227,\n",
" 0.016853934, -0.017926402, -0.006154979, 0.025893573, 0.015262395\n",
" 0.03278884, -0.017893745,\n",
" -0.0027520044, 0.016506646,\n",
" 0.028271576, -0.01284331,\n",
" 0.014344065, -0.007968607,\n",
" -0.03899479, 0.039327156\n",
"]\n"
]
}
Expand All @@ -355,9 +309,8 @@
"\n",
" const vectors = await embeddings.embedDocuments([text, text2]);\n",
" \n",
" console.log(vectors[0].slice(0, 100));\n",
" console.log(vectors[1].slice(0, 100));\n",
" "
" console.log(vectors[0].slice(0, 10));\n",
" console.log(vectors[1].slice(0, 10));\n"
]
},
{
Expand Down Expand Up @@ -386,4 +339,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Loading
Loading