Skip to main content

Microsoft

所有与 Microsoft Azure 和其他 Microsoft 产品相关的功能。

¥All functionality related to Microsoft Azure and other Microsoft products.

聊天模型

¥Chat Models

Azure OpenAI

请参阅 使用示例

¥See a usage example

tip

我们正在统一所有软件包的模型参数。我们现在建议使用 model 代替 modelName,并使用 apiKey 作为 API 密钥。

¥We're unifying model params across all packages. We now suggest using model instead of modelName, and apiKey for API keys.

import { AzureChatOpenAI } from "@langchain/openai";

const model = new AzureChatOpenAI({
temperature: 0.9,
azureOpenAIApiKey: "<your_key>", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiInstanceName: "<your_instance_name>", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: "<your_deployment_name>", // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
azureOpenAIApiVersion: "<api_version>", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
});

API Reference:

LLM

Azure OpenAI

Microsoft Azure,通常简称为 Azure,是由 Microsoft 运营的云计算平台,通过全球数据中心提供应用和服务的访问、管理和开发。它提供了一系列功能,包括软件即服务 (SaaS)、平台即服务 (PaaS) 和基础设施即服务 (IaaS)。Microsoft Azure 支持多种编程语言、工具和框架,包括 Microsoft 特定软件和系统以及第三方软件和系统。

¥Microsoft Azure, often referred to as Azure is a cloud computing platform run by Microsoft, which offers access, management, and development of applications and services through global data centers. It provides a range of capabilities, including software as a service (SaaS), platform as a service (PaaS), and infrastructure as a service (IaaS). Microsoft Azure supports many programming languages, tools, and frameworks, including Microsoft-specific and third-party software and systems.

Azure OpenAI 是一项云服务,可帮助你使用来自 OpenAI、Meta 及其他机构的多种预构建和精选模型快速开发生成式 AI 体验。

¥Azure OpenAI is a cloud service to help you quickly develop generative AI experiences with a diverse set of prebuilt and curated models from OpenAI, Meta and beyond.

LangChain.js 支持使用 OpenAI SDK 中新的 Azure 集成与 Azure OpenAI 集成。

¥LangChain.js supports integration with Azure OpenAI using the new Azure integration in the OpenAI SDK.

你可以在 此页面 上了解有关 Azure OpenAI 及其与 OpenAI API 的区别的更多信息。如果你没有 Azure 账户,可以使用 创建免费账户 开始使用。

¥You can learn more about Azure OpenAI and its difference with the OpenAI API on this page. If you don't have an Azure account, you can create a free account to get started.

你需要部署一个 Azure OpenAI 实例。你可以按照 此指南 在 Azure 门户上部署一个版本。

¥You'll need to have an Azure OpenAI instance deployed. You can deploy a version on Azure Portal following this guide.

实例运行后,请确保你拥有实例名称和密钥。你可以在 Azure 门户中实例的 "密钥和端点" 部分下找到密钥。

¥Once you have your instance running, make sure you have the name of your instance and key. You can find the key in the Azure Portal, under the "Keys and Endpoint" section of your instance.

如果你使用的是 Node.js,你可以定义以下环境变量来使用该服务:

¥If you're using Node.js, you can define the following environment variables to use the service:

AZURE_OPENAI_API_INSTANCE_NAME=<YOUR_INSTANCE_NAME>
AZURE_OPENAI_API_DEPLOYMENT_NAME=<YOUR_DEPLOYMENT_NAME>
AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME=<YOUR_EMBEDDINGS_DEPLOYMENT_NAME>
AZURE_OPENAI_API_KEY=<YOUR_KEY>
AZURE_OPENAI_API_VERSION="2024-02-01"
info

你可以在 Azure OpenAI 文档 中找到受支持的 API 版本列表。

¥You can find the list of supported API versions in the Azure OpenAI documentation.

npm install @langchain/openai @langchain/core

请参阅 使用示例

¥See a usage example.

tip

我们正在统一所有软件包的模型参数。我们现在建议使用 model 代替 modelName,并使用 apiKey 作为 API 密钥。

¥We're unifying model params across all packages. We now suggest using model instead of modelName, and apiKey for API keys.

import { AzureOpenAI } from "@langchain/openai";

const model = new AzureOpenAI({
azureOpenAIApiKey: "<your_key>", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiInstanceName: "<your_instance_name>", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: "<your_deployment_name>", // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
azureOpenAIApiVersion: "<api_version>", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
});

API Reference:

文本嵌入模型

¥Text Embedding Models

Azure OpenAI

请参阅 使用示例

¥See a usage example

tip

我们正在统一所有软件包的模型参数。我们现在建议使用 model 代替 modelName,并使用 apiKey 作为 API 密钥。

¥We're unifying model params across all packages. We now suggest using model instead of modelName, and apiKey for API keys.

import { AzureOpenAIEmbeddings } from "@langchain/openai";

const model = new AzureOpenAIEmbeddings({
azureOpenAIApiKey: "<your_key>", // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiInstanceName: "<your_instance_name>", // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiEmbeddingsDeploymentName: "<your_embeddings_deployment_name>", // In Node.js defaults to process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME
azureOpenAIApiVersion: "<api_version>", // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
});

API Reference:

向量存储

¥Vector stores

¥Azure AI Search

Azure AI 搜索(以前称为 Azure 搜索和 Azure 认知搜索)是一个分布式 RESTful 搜索引擎,针对 Azure 上生产规模工作负载的速度和相关性进行了优化。它还支持使用 k-最近邻 (kNN) 算法和 语义搜索 算法进行向量搜索。

¥Azure AI Search (formerly known as Azure Search and Azure Cognitive Search) is a distributed, RESTful search engine optimized for speed and relevance on production-scale workloads on Azure. It supports also vector search using the k-nearest neighbor (kNN) algorithm and also semantic search.

npm install -S @langchain/community @langchain/core @azure/search-documents

请参阅 使用示例

¥See a usage example.

import { AzureAISearchVectorStore } from "@langchain/community/vectorstores/azure_aisearch";

Azure Cosmos DB for NoSQL

Azure Cosmos DB for NoSQL 支持使用灵活的模式查询项目,并原生支持 JSON。现在提供向量索引和搜索功能。此功能旨在处理高维向量,从而实现在任何规模下高效准确的向量搜索。现在你可以将向量与数据一起直接存储在文档中。数据库中的每个文档不仅可以包含传统的无模式数据,还可以包含高维向量作为文档的其他属性。

¥Azure Cosmos DB for NoSQL provides support for querying items with flexible schemas and native support for JSON. It now offers vector indexing and search. This feature is designed to handle high-dimensional vectors, enabling efficient and accurate vector search at any scale. You can now store vectors directly in the documents alongside your data. Each document in your database can contain not only traditional schema-free data, but also high-dimensional vectors as other properties of the documents.

npm install @langchain/azure-cosmosdb @langchain/core

请参阅 使用示例

¥See a usage example.

import { AzureCosmosDBNoSQLVectorStore } from "@langchain/azure-cosmosdb";

Azure Cosmos DB for MongoDB vCore

Azure Cosmos DB for MongoDB vCore 可以轻松创建完全原生支持 MongoDB 的数据库。你可以将应用指向 MongoDB vCore 账户连接字符串的 API,从而运用你的 MongoDB 经验并继续使用你喜欢的 MongoDB 驱动程序、SDK 和工具。在 Azure Cosmos DB 中为 MongoDB vCore 使用向量搜索,将你的 AI 应用与存储在 Azure Cosmos DB 中的数据无缝集成。

¥Azure Cosmos DB for MongoDB vCore makes it easy to create a database with full native MongoDB support. You can apply your MongoDB experience and continue to use your favorite MongoDB drivers, SDKs, and tools by pointing your application to the API for MongoDB vCore account’s connection string. Use vector search in Azure Cosmos DB for MongoDB vCore to seamlessly integrate your AI-based applications with your data that’s stored in Azure Cosmos DB.

npm install @langchain/azure-cosmosdb @langchain/core

请参阅 使用示例

¥See a usage example.

import { AzureCosmosDBMongoDBVectorStore } from "@langchain/azure-cosmosdb";

语义缓存

¥Semantic Cache

Azure Cosmos DB NoSQL 语义缓存

¥Azure Cosmos DB NoSQL Semantic Cache

Azure Cosmos DB 支持语义缓存功能,用于 NoSQL 集成,使用户能够根据用户输入与先前缓存结果之间的语义相似性检索缓存的响应。它利用了 AzureCosmosDBNoSQLVectorStore,后者存储了缓存提示的向量嵌入。这些嵌入支持基于相似度的搜索,允许系统检索相关的缓存结果。

¥The Semantic Cache feature is supported with Azure Cosmos DB for NoSQL integration, enabling users to retrieve cached responses based on semantic similarity between the user input and previously cached results. It leverages AzureCosmosDBNoSQLVectorStore, which stores vector embeddings of cached prompts. These embeddings enable similarity-based searches, allowing the system to retrieve relevant cached results.

npm install @langchain/azure-cosmosdb @langchain/core

请参阅 使用示例

¥See a usage example.

import { AzureCosmosDBNoSQLSemanticCache } from "@langchain/azure-cosmosdb";

聊天消息历史记录

¥Chat Message History

Azure Cosmos DB NoSQL 聊天消息历史记录

¥Azure Cosmos DB NoSQL Chat Message History

AzureCosmosDBNoSQLChatMessageHistory 使用 Cosmos DB 存储聊天消息历史记录。为了在聊天会话中实现更长期的持久化,你可以将支持聊天内存类(如 BufferMemory)的默认内存 chatHistory 替换为 Upstash 实例。

¥The AzureCosmosDBNoSQLChatMessageHistory uses Cosmos DB to store chat message history. For longer-term persistence across chat sessions, you can swap out the default in-memory chatHistory that backs chat memory classes like BufferMemory.

npm install @langchain/azure-cosmosdb @langchain/core

请参阅 使用示例

¥See usage example.

import { AzureCosmosDBNoSQLChatMessageHistory } from "@langchain/azure-cosmosdb";

Azure Cosmos DB MongoDB vCore 聊天消息历史记录

¥Azure Cosmos DB MongoDB vCore Chat Message History

AzureCosmosDBMongoChatMessageHistory 使用 Cosmos DB Mongo vCore 存储聊天消息历史记录。为了在聊天会话中实现更长期的持久化,你可以将支持聊天内存类(如 BufferMemory)的默认内存 chatHistory 替换为 Upstash 实例。

¥The AzureCosmosDBMongoChatMessageHistory uses Cosmos DB Mongo vCore to store chat message history. For longer-term persistence across chat sessions, you can swap out the default in-memory chatHistory that backs chat memory classes like BufferMemory.

npm install @langchain/azure-cosmosdb @langchain/core

请参阅 使用示例

¥See a usage example.

import { AzureCosmosDBMongoChatMessageHistory } from "@langchain/azure-cosmosdb";

文档加载器

¥Document loaders

Azure Blob 存储

¥Azure Blob Storage

Azure Blob 存储 是微软的云端对象存储解决方案。Blob 存储针对存储海量非结构化数据进行了优化。非结构化数据是不遵循特定数据模型或定义的数据,例如文本或二进制数据。

¥Azure Blob Storage is Microsoft's object storage solution for the cloud. Blob Storage is optimized for storing massive amounts of unstructured data. Unstructured data is data that doesn't adhere to a particular data model or definition, such as text or binary data.

Azure Files 在云端提供完全托管的文件共享,可通过行业标准的服务器消息块 (SMB) 协议、网络文件系统 (NFS) 协议和 Azure Files REST API 访问。Azure Files 基于 Azure Blob Storage

¥Azure Files offers fully managed file shares in the cloud that are accessible via the industry standard Server Message Block (SMB) protocol, Network File System (NFS) protocol, and Azure Files REST API. Azure Files are based on the Azure Blob Storage.

Azure Blob Storage 的设计用途:

¥Azure Blob Storage is designed for:

  • 直接向浏览器提供图片或文档。

    ¥Serving images or documents directly to a browser.

  • 存储文件以供分布式访问。

    ¥Storing files for distributed access.

  • 流媒体视频和音频。

    ¥Streaming video and audio.

  • 写入日志文件。

    ¥Writing to log files.

  • 存储数据以供备份和还原、灾难恢复和归档。

    ¥Storing data for backup and restore, disaster recovery, and archiving.

  • 存储数据以供本地或 Azure 托管服务进行分析。

    ¥Storing data for analysis by an on-premises or Azure-hosted service.

npm install @langchain/community @langchain/core @azure/storage-blob

请参阅 Azure Blob 存储使用示例

¥See a usage example for the Azure Blob Storage.

import { AzureBlobStorageContainerLoader } from "@langchain/community/document_loaders/web/azure_blob_storage_container";

请参阅 Azure 文件使用示例

¥See a usage example for the Azure Files.

import { AzureBlobStorageFileLoader } from "@langchain/community/document_loaders/web/azure_blob_storage_file";

工具

¥Tools

Azure 容器应用动态会话

¥Azure Container Apps Dynamic Sessions

Azure 容器应用动态会话 提供对安全沙盒环境的快速访问,非常适合运行需要与其他工作负载严格隔离的代码或应用。

¥Azure Container Apps dynamic sessions provide fast access to secure sandboxed environments that are ideal for running code or applications that require strong isolation from other workloads.

npm install @langchain/azure-dynamic-sessions @langchain/core

请参阅 使用示例

¥See a usage example.

import { SessionsPythonREPLTool } from "@langchain/azure-dynamic-sessions";