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

Adds integration package installation instructions #3650

Merged
merged 3 commits into from
Dec 14, 2023
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
100 changes: 65 additions & 35 deletions docs/core_docs/docs/get_started/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -108,45 +104,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

Expand Down
4 changes: 4 additions & 0 deletions docs/core_docs/docs/integrations/chat/google_generativeai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
10 changes: 10 additions & 0 deletions docs/core_docs/docs/integrations/chat/mistral.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions docs/core_docs/docs/integrations/platforms/google.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
14 changes: 14 additions & 0 deletions docs/core_docs/docs/integrations/text_embedding/mistralai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down