From 5f85aa572d49d44cccd594ecbf92faf18c431306 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Wed, 13 Dec 2023 22:37:07 -0800 Subject: [PATCH 1/3] Adds integration package installation instructions --- .../docs/get_started/installation.mdx | 96 +++++++++++++------ .../integrations/chat/google_generativeai.mdx | 4 + .../docs/integrations/platforms/google.mdx | 4 + .../text_embedding/google_generativeai.mdx | 4 + 4 files changed, 77 insertions(+), 31 deletions(-) diff --git a/docs/core_docs/docs/get_started/installation.mdx b/docs/core_docs/docs/get_started/installation.mdx index 33fea1b32930..467e740dc701 100644 --- a/docs/core_docs/docs/get_started/installation.mdx +++ b/docs/core_docs/docs/get_started/installation.mdx @@ -108,45 +108,79 @@ LangChain can be used in the browser. In our CI we test bundling LangChain with import { OpenAI } from "langchain/llms/openai"; ``` -## Updating from <0.0.52 +## Installing integration packages -If you are updating from a version of LangChain prior to 0.0.52, you will need to update your imports to use the new path structure. +LangChain supports packages that contain specific module integrations with third-party providers. +They can be as specific as [`@langchain/google-genai`](/docs/integrations/platforms/google#chatgooglegenerativeai), which contains integrations just for Google AI Studio models, +or as broad as [`@langchain/community`](https://www.npmjs.com/package/@langchain/community), which contains broader variety of community contributed integrations. -For example, if you were previously doing +These packages, as well as the main LangChain package, all depend on [`@langchain/core`](https://www.npmjs.com/package/@langchain/core), which contains the base abstractions +that these integration packages extend. -```typescript -import { OpenAI } from "langchain/llms"; +To ensure that all integrations and their types interact with each other properly, it is important that they all use the same version of `@langchain/core`. +The best way to guarantee this is to add a `"resolutions"` or `"overrides"` field like the following in your project's `package.json`. The name will depend on your package manager: + +If you are using `yarn`: + +```json title="yarn package.json" +{ + "name": "your-project", + "version": "0.0.0", + "private": true, + "engines": { + "node": ">=18" + }, + "dependencies": { + "@langchain/google-genai": "^0.0.2", + "langchain": "0.0.207" + }, + "resolutions": { + "@langchain/core": "0.1.1" + } +} ``` -you will now need to do +Or for `npm`: -```typescript -import { OpenAI } from "langchain/llms/openai"; +```json title="npm package.json" +{ + "name": "your-project", + "version": "0.0.0", + "private": true, + "engines": { + "node": ">=18" + }, + "dependencies": { + "@langchain/google-genai": "^0.0.2", + "langchain": "0.0.207" + }, + "overrides": { + "@langchain/core": "0.1.1" + } +} ``` -This applies to all imports from the following 6 modules, which have been split into submodules for each integration. The combined modules are deprecated, do not work outside of Node.js, and will be removed in a future version. - -- If you were using `langchain/llms`, see [LLMs](/docs/modules/model_io/models/llms) for updated import paths. -- If you were using `langchain/chat_models`, see [Chat Models](/docs/modules/model_io/models/chat) for updated import paths. -- If you were using `langchain/embeddings`, see [Embeddings](/docs/modules/data_connection/text_embedding) for updated import paths. -- If you were using `langchain/vectorstores`, see [Vector Stores](/docs/modules/data_connection/vectorstores) for updated import paths. -- If you were using `langchain/document_loaders`, see [Document Loaders](/docs/modules/data_connection/document_loaders) for updated import paths. -- If you were using `langchain/retrievers`, see [Retrievers](/docs/modules/data_connection/retrievers) for updated import paths. - -Other modules are not affected by this change, and you can continue to import them from the same path. - -Additionally, there are some breaking changes that were needed to support new environments: - -- `import { Calculator } from "langchain/tools";` now moved to - - `import { Calculator } from "langchain/tools/calculator";` -- `import { loadLLM } from "langchain/llms";` now moved to - - `import { loadLLM } from "langchain/llms/load";` -- `import { loadAgent } from "langchain/agents";` now moved to - - `import { loadAgent } from "langchain/agents/load";` -- `import { loadPrompt } from "langchain/prompts";` now moved to - - `import { loadPrompt } from "langchain/prompts/load";` -- `import { loadChain } from "langchain/chains";` now moved to - - `import { loadChain } from "langchain/chains/load";` +Or for `pnpm`: + +```json title="pnpm package.json" +{ + "name": "your-project", + "version": "0.0.0", + "private": true, + "engines": { + "node": ">=18" + }, + "dependencies": { + "@langchain/google-genai": "^0.0.2", + "langchain": "0.0.207" + }, + "pnpm": { + "overrides": { + "@langchain/core": "0.1.1" + } + } +} +``` ## Unsupported: Node.js 16 diff --git a/docs/core_docs/docs/integrations/chat/google_generativeai.mdx b/docs/core_docs/docs/integrations/chat/google_generativeai.mdx index 9c17d51ad9f8..a22e2c78da2e 100644 --- a/docs/core_docs/docs/integrations/chat/google_generativeai.mdx +++ b/docs/core_docs/docs/integrations/chat/google_generativeai.mdx @@ -14,6 +14,10 @@ Get an API key here: https://ai.google.dev/tutorials/setup You'll first need to install the `@langchain/google-genai` package: +:::note +See this section for instructions on [installing integration packages](/docs/get_started/installation#installing-integration-packages). +::: + ```bash npm2yarn npm install @langchain/google-genai ``` diff --git a/docs/core_docs/docs/integrations/platforms/google.mdx b/docs/core_docs/docs/integrations/platforms/google.mdx index 21f78af48185..350d1bbe8e52 100644 --- a/docs/core_docs/docs/integrations/platforms/google.mdx +++ b/docs/core_docs/docs/integrations/platforms/google.mdx @@ -8,6 +8,10 @@ Functionality related to [Google Cloud Platform](https://cloud.google.com/) Access Gemini models such as `gemini-pro` and `gemini-pro-vision` through the [`ChatGoogleGenerativeAI`](/docs/integrations/chat/google_generativeai) class. +:::note +See this section for instructions on [installing integration packages](/docs/get_started/installation#installing-integration-packages). +::: + ```bash npm2yarn npm install @langchain/google-genai ``` diff --git a/docs/core_docs/docs/integrations/text_embedding/google_generativeai.mdx b/docs/core_docs/docs/integrations/text_embedding/google_generativeai.mdx index b37fcfd9b777..d09d1a0b2e0e 100644 --- a/docs/core_docs/docs/integrations/text_embedding/google_generativeai.mdx +++ b/docs/core_docs/docs/integrations/text_embedding/google_generativeai.mdx @@ -9,6 +9,10 @@ Get an API key here: https://ai.google.dev/tutorials/setup You'll need to install the `@langchain/google-genai` package: +:::note +See this section for instructions on [installing integration packages](/docs/get_started/installation#installing-integration-packages). +::: + ```bash npm2yarn npm install @langchain/google-genai ``` From 2c06ad719401a0cc303cb2d6922637a109f100ef Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Wed, 13 Dec 2023 22:40:31 -0800 Subject: [PATCH 2/3] Update Mistral docs --- docs/core_docs/docs/integrations/chat/mistral.mdx | 10 ++++++++++ .../docs/integrations/text_embedding/mistralai.mdx | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/core_docs/docs/integrations/chat/mistral.mdx b/docs/core_docs/docs/integrations/chat/mistral.mdx index 07d8b67d4119..7d701628fc1b 100644 --- a/docs/core_docs/docs/integrations/chat/mistral.mdx +++ b/docs/core_docs/docs/integrations/chat/mistral.mdx @@ -22,6 +22,16 @@ Mistral's API offers access to two of their models: `mistral7b` and `mixtral8x7b In order to use the Mistral API you'll need an API key. You can sign up for a Mistral account and create an API key [here](https://console.mistral.ai/). +You'll first need to install the [`@langchain/mistralai`](https://www.npmjs.com/package/@langchain/mistralai) package: + +:::note +See this section for instructions on [installing integration packages](/docs/get_started/installation#installing-integration-packages). +::: + +```bash npm2yarn +npm install @langchain/mistralai +``` + ## Usage When sending chat messages to mistral, there are a few requirements to follow: diff --git a/docs/core_docs/docs/integrations/text_embedding/mistralai.mdx b/docs/core_docs/docs/integrations/text_embedding/mistralai.mdx index 622a648d3401..4419342e0716 100644 --- a/docs/core_docs/docs/integrations/text_embedding/mistralai.mdx +++ b/docs/core_docs/docs/integrations/text_embedding/mistralai.mdx @@ -6,6 +6,20 @@ sidebar_label: Mistral AI The `MistralAIEmbeddings` class uses the Mistral AI API to generate embeddings for a given text. +## Setup + +In order to use the Mistral API you'll need an API key. You can sign up for a Mistral account and create an API key [here](https://console.mistral.ai/). + +You'll first need to install the [`@langchain/mistralai`](https://www.npmjs.com/package/@langchain/mistralai) package: + +:::note +See this section for instructions on [installing integration packages](/docs/get_started/installation#installing-integration-packages). +::: + +```bash npm2yarn +npm install @langchain/mistralai +``` + ## Usage import CodeBlock from "@theme/CodeBlock"; From 0fd1a6da65ca99888df1fa9ccf13c28c6163ce31 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Wed, 13 Dec 2023 22:52:38 -0800 Subject: [PATCH 3/3] Remove old warning --- docs/core_docs/docs/get_started/installation.mdx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/core_docs/docs/get_started/installation.mdx b/docs/core_docs/docs/get_started/installation.mdx index 467e740dc701..62059071a076 100644 --- a/docs/core_docs/docs/get_started/installation.mdx +++ b/docs/core_docs/docs/get_started/installation.mdx @@ -4,10 +4,6 @@ sidebar_position: 1 # Installation -:::info -Updating from <0.0.52? See [this section](#updating-from-0052) for instructions. -::: - ## Supported Environments LangChain is written in TypeScript and can be used in: