聊天模型
聊天模型 是一类语言模型,它们使用一系列 消息 作为输入,并返回消息作为输出(而不是使用纯文本)。这些模型通常是较新的模型。
Pick your chat model:
- Groq
- OpenAI
- Anthropic
- Google Gemini
- FireworksAI
- MistralAI
- VertexAI
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/groq
yarn add @langchain/groq
pnpm add @langchain/groq
Add environment variables
GROQ_API_KEY=your-api-key
Instantiate the model
import { ChatGroq } from "@langchain/groq";
const model = new ChatGroq({
model: "llama-3.3-70b-versatile",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/openai
yarn add @langchain/openai
pnpm add @langchain/openai
Add environment variables
OPENAI_API_KEY=your-api-key
Instantiate the model
import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({ model: "gpt-4o-mini" });
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/anthropic
yarn add @langchain/anthropic
pnpm add @langchain/anthropic
Add environment variables
ANTHROPIC_API_KEY=your-api-key
Instantiate the model
import { ChatAnthropic } from "@langchain/anthropic";
const model = new ChatAnthropic({
model: "claude-3-5-sonnet-20240620",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/google-genai
yarn add @langchain/google-genai
pnpm add @langchain/google-genai
Add environment variables
GOOGLE_API_KEY=your-api-key
Instantiate the model
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
const model = new ChatGoogleGenerativeAI({
model: "gemini-2.0-flash",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/community
yarn add @langchain/community
pnpm add @langchain/community
Add environment variables
FIREWORKS_API_KEY=your-api-key
Instantiate the model
import { ChatFireworks } from "@langchain/community/chat_models/fireworks";
const model = new ChatFireworks({
model: "accounts/fireworks/models/llama-v3p1-70b-instruct",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/mistralai
yarn add @langchain/mistralai
pnpm add @langchain/mistralai
Add environment variables
MISTRAL_API_KEY=your-api-key
Instantiate the model
import { ChatMistralAI } from "@langchain/mistralai";
const model = new ChatMistralAI({
model: "mistral-large-latest",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/google-vertexai
yarn add @langchain/google-vertexai
pnpm add @langchain/google-vertexai
Add environment variables
GOOGLE_APPLICATION_CREDENTIALS=credentials.json
Instantiate the model
import { ChatVertexAI } from "@langchain/google-vertexai";
const model = new ChatVertexAI({
model: "gemini-1.5-flash",
temperature: 0
});
await model.invoke("Hello, world!")
推荐提供商
| 模型 | 流式传输 | JSON 模式 | 工具调用 | withStructuredOutput() | 多模态 |
|---|---|---|---|---|---|
| BedrockChat | ✅ | ❌ | 🟡 (仅 Bedrock Anthropic) | 🟡 (仅 Bedrock Anthropic) | 🟡 (仅 Bedrock Anthropic) |
| ChatBedrockConverse | ✅ | ❌ | ✅ | ✅ | ✅ |
| ChatAnthropic | ✅ | ❌ | ✅ | ✅ | ✅ |
| ChatCloudflareWorkersAI | ✅ | ❌ | ❌ | ❌ | ❌ |
| ChatCohere | ✅ | ❌ | ✅ | ✅ | ✅ |
| ChatFireworks | ✅ | ✅ | ✅ | ✅ | ✅ |
| ChatGoogleGenerativeAI | ✅ | ❌ | ✅ | ✅ | ✅ |
| ChatVertexAI | ✅ | ❌ | ✅ | ✅ | ✅ |
| ChatGroq | ✅ | ✅ | ✅ | ✅ | ✅ |
| ChatMistralAI | ✅ | ✅ | ✅ | ✅ | ✅ |
| ChatOllama | ✅ | ✅ | ✅ | ✅ | ✅ |
| ChatOpenAI | ✅ | ✅ | ✅ | ✅ | ✅ |
| ChatTogetherAI | ✅ | ✅ | ✅ | ✅ | ✅ |
| ChatXAI | ✅ | ✅ | ✅ | ✅ | ❌ |
所有聊天模型
| Name | Description |
|---|---|
| 阿里通义 | LangChain.js 支持阿里巴巴的 qwen 系列模型。 |
| Anthropic | Anthropic |
| Arcjet Redact | Arcjet |
| Azure OpenAI | Azure OpenAI 是一项 Microsoft Azure 服务,它提供了来自 OpenAI |
| 百度千帆 | 安装准备 |
| Amazon Bedrock | Amazon Bedrock |
| Amazon Bedrock Converse | [Amazon Bedrock |
| Cerebras | Cerebras |
| Cloudflare Workers AI | Workers AI 允许你在 |
| Cohere | Cohere |
| Deep Infra | LangChain 通过 ChatDeepInfra 封装器支持 Deep Infra 托管的聊天模型。首先,你需要安装 @langcha... |
| DeepSeek | 这将帮助你开始使用 DeepSeek 聊天模型。关于 ChatDeepSeek 所有功能和配置的详细文档,请前往 API 参考。 |
| DeepSeek | 这将帮助你开始使用 DeepSeek 聊天模型。关于 ChatDeepSeek 所有功能和配置的详细文档,请前往 API 参考。 |
| 模拟LLM | LangChain提供了一个用于测试的模拟LLM聊天模型。这允许你模拟LLM的调用,并模拟LLM以某种方式响应时会发生的情况。 |
| Fireworks | Fireworks AI |
| Friendli | Friendli 通过可扩展、高效的部署选项提升 AI 应用性能并优化成本节省,专为高需求的 AI 工作负载量身打造。 |
| Google GenAI | Google AI 提供了多种聊天模型,包括强大的 |
| Google Vertex AI | Google Vertex 是一项服务,提供了 |
| Groq | Groq 是一家公司,提供由 LPU™ AI 推理技术驱动的快速 |
| IBM watsonx.ai | 这将帮助您开始使用 IBM watsonx.ai |
| Llama CPP | 仅适用于 Node.js。 |
| Minimax | Minimax 是一家中国初创公司,为企业和个人提供自然语言处理模型。 |
| MistralAI | Mistral AI |
| 月之暗面 | LangChain.js 支持月之暗面(Moonshot AI)系列模型。 |
| Novita AI | 提供一个经济实惠、可靠且简单的推理平台,用于运行顶级 LLM 模型。 |
| Ollama | Ollama 允许您在本地运行开源的大语言模型,例如 |
| OpenAI | OpenAI 是一家人工智能 (AI) |
| 困惑度 | 本指南将帮助您入门 Perplexity 的聊天模型。关于 ChatPerplexity 所有功能和配置的详细文档,请参阅 API 参考。 |
| 困惑度 | 本指南将帮助您入门 Perplexity 的聊天模型。关于 ChatPerplexity 所有功能和配置的详细文档,请参阅 API 参考。 |
| PremAI | 安装配置 |
| 腾讯混元 | LangChain.js 支持腾讯混元系列模型。 |
| Together | Together AI 提供了一个 |
| WebLLM | 仅适用于网页环境。 |
| xAI | xAI 是一家开发大型语言模型 (LLMs) |
| YandexGPT | LangChain.js 支持调用 YandexGPT 聊天模型。 |
| ZhipuAI | LangChain.js 支持 Zhipu AI 系列模型。 |