Skip to main content

AWS

Amazon AWS 平台相关的 LangChain 集成。

第一方 AWS 集成可在 langchain_aws 包中获取。

pip install langchain-aws

此外,还有一些社区集成可在 langchain_community 包中获取,并带有 boto3 可选依赖。

pip install langchain-community boto3

聊天模型

Bedrock Chat

Amazon Bedrock 是一项完全托管的服务,提供来自 AI21 LabsAnthropicCohereMetaStability AIAmazon 等领先 AI 公司的一系列高性能基础模型 (FMs),通过单一 API 访问,并提供构建具有安全性、隐私性和负责任的 AI 的生成 AI 应用所需的广泛功能。使用 Amazon Bedrock,您可以轻松地根据您的用例实验和评估顶级 FMs,使用微调和 Retrieval Augmented Generation (RAG) 等技术私密定制它们,并构建执行任务的代理,这些任务使用您的企业系统和数据源。由于 Amazon Bedrock 是无服务器的,您无需管理任何基础设施,并且可以安全地将生成 AI 功能集成并部署到您已经熟悉的 AWS 服务中的应用程序中。

查看 使用示例.

from langchain_aws import ChatBedrock

LLMs

基础层

查看使用示例

from langchain_aws import BedrockLLM

Amazon API Gateway

Amazon API Gateway 是一个完全托管的服务,使开发人员能够轻松创建、发布、维护、监控和保护任何规模的 API。API 作为应用程序访问后端服务中的数据、业务逻辑或功能的“前门”。使用 API Gateway,您可以创建 RESTful API 和 WebSocket API,从而支持实时双向通信应用程序。API Gateway 支持容器化和无服务器工作负载,以及 Web 应用程序。

API Gateway 处理接受和处理数十万并发 API 调用的所有任务,包括流量管理、CORS 支持、授权和访问控制、限流、监控和 API 版本管理。API Gateway 没有最低费用或启动成本。您只需为收到的 API 调用和传输的数据量付费,并且通过 API Gateway 分层定价模型,您可以随着 API 使用量的增加而降低成本。

查看 使用示例

from langchain_community.llms import AmazonAPIGateway

SageMaker 终端

Amazon SageMaker 是一个可以构建、训练和部署机器学习(ML)模型的系统,提供完全托管的基础设施、工具和工作流程。

我们使用 SageMaker 来托管我们的模型并将其作为 SageMaker 终端 公开。

查看 使用示例

from langchain_aws import SagemakerEndpoint

嵌入模型

Bedrock

查看 用法示例.

from langchain_community.embeddings import BedrockEmbeddings

SageMaker 终端节点

查看 使用示例.

from langchain_community.embeddings import SagemakerEndpointEmbeddings
from langchain_community.llms.sagemaker_endpoint import ContentHandlerBase

文档加载器

AWS S3 目录和文件

亚马逊简单存储服务 (Amazon S3) 是一种对象存储服务。 AWS S3 目录 AWS S3 桶

查看 S3DirectoryLoader 的使用示例

查看 S3FileLoader 的使用示例

from langchain_community.document_loaders import S3DirectoryLoader, S3FileLoader

Amazon Textract

Amazon Textract 是一种机器学习 (ML) 服务,能够自动从扫描文档中提取文本、手写内容和数据。

请参阅 使用示例.

from langchain_community.document_loaders import AmazonTextractPDFLoader

Amazon Athena

Amazon Athena 是一个无服务器的交互式分析服务,基于开源框架构建,支持开放表和文件格式。

请参见使用示例

from langchain_community.document_loaders.athena import AthenaLoader

AWS Glue

The AWS Glue Data Catalog 是一个集中式元数据 存储库,允许您管理、访问和共享关于您存储在 AWS 中的数据的元数据。它充当您数据资产的元数据存储, 使各种 AWS 服务和您的应用程序能够高效地查询和连接所需的数据。

请参阅 使用示例.

from langchain_community.document_loaders.glue_catalog import GlueCatalogLoader

向量存储

Amazon OpenSearch Service

Amazon OpenSearch Service 执行 交互式日志分析、实时应用监控、网站搜索等功能。OpenSearch 是 一个开源的、分布式的搜索和分析套件,源自 ElasticsearchAmazon OpenSearch Service 提供 最新版本的 OpenSearch,支持多个版本的 Elasticsearch,以及 由 OpenSearch DashboardsKibana 提供的可视化能力。

我们需要安装几个 Python 库。

pip install boto3 requests requests-aws4auth

查看 使用示例

from langchain_community.vectorstores import OpenSearchVectorSearch

Amazon DocumentDB 向量搜索

Amazon DocumentDB (与 MongoDB 兼容) 使在云中设置、操作和扩展与 MongoDB 兼容的数据库变得简单。 使用 Amazon DocumentDB,您可以运行相同的应用程序代码,并使用与 MongoDB 一样的驱动程序和工具。 Amazon DocumentDB 的向量搜索将基于 JSON 的文档数据库的灵活性和丰富查询能力与向量搜索的强大功能结合在一起。

安装与设置

请参阅 详细配置说明

我们需要安装 pymongo python 包。

pip install pymongo

在 AWS 上部署 DocumentDB

Amazon DocumentDB (与 MongoDB 兼容) 是一个快速、可靠且完全托管的数据库服务。 Amazon DocumentDB 使在云中设置、操作和扩展与 MongoDB 兼容的数据库变得简单。

AWS 提供计算、数据库、存储、分析和其他功能的服务。有关所有 AWS 服务的概述,请参阅 使用 Amazon Web Services 的云计算

请参见 使用示例

from langchain.vectorstores import DocumentDBVectorSearch

Amazon MemoryDB

Amazon MemoryDB 是一个持久化的内存数据库服务,提供超快的性能。MemoryDB 兼容 Redis OSS,一个流行的开源数据存储,使您能够使用相同灵活且友好的 Redis OSS API 和命令快速构建应用程序,这些 API 和命令是您今天已经使用的。

InMemoryVectorStore 类提供了一个向量存储,以连接 Amazon MemoryDB。

from langchain_aws.vectorstores.inmemorydb import InMemoryVectorStore

vds = InMemoryVectorStore.from_documents(
chunks,
embeddings,
redis_url="rediss://cluster_endpoint:6379/ssl=True ssl_cert_reqs=none",
vector_schema=vector_schema,
index_name=INDEX_NAME,
)

请参见 用法示例.

检索器

Amazon Kendra

Amazon Kendra 是由 Amazon Web Services (AWS) 提供的智能搜索服务。它利用先进的自然语言处理 (NLP) 和机器学习算法,使得在组织内的各种数据源之间实现强大的搜索能力。 Kendra 旨在帮助用户快速准确地找到所需的信息,从而提高生产力和决策能力。

使用 Kendra,我们可以搜索各种内容类型,包括文档、常见问题解答、知识库、手册和网站。它支持多种语言,能够理解复杂查询、同义词和上下文含义,以提供高度相关的搜索结果。

我们需要安装 langchain-aws 库。

pip install langchain-aws

查看 使用示例

from langchain_aws import AmazonKendraRetriever

Amazon Bedrock (知识库)

Amazon Bedrock 的知识库 是一个 Amazon Web Services (AWS) 提供的服务,允许您快速构建 RAG 应用程序,通过使用您的 私有数据来定制基础模型的响应。

我们需要安装 langchain-aws 库。

pip install langchain-aws

请参见 使用示例

from langchain_aws import AmazonKnowledgeBasesRetriever

工具

AWS Lambda

Amazon AWS Lambda 是由 Amazon Web Services (AWS) 提供的无服务器计算服务。它帮助开发人员构建和运行应用程序及服务,而无需配置或管理服务器。这种无服务器架构使您能够专注于编写和部署代码,同时 AWS 自动处理扩展、修补和管理运行应用程序所需的基础设施。

我们需要安装 boto3 python 库。

pip install boto3

查看 使用示例

内存

AWS DynamoDB

AWS DynamoDB 是一个完全托管的 NoSQL 数据库服务,提供快速且可预测的性能,并具备无缝扩展能力。

我们需要配置 AWS CLI

我们需要安装 boto3 库。

pip install boto3

查看 使用示例

from langchain.memory import DynamoDBChatMessageHistory

图表

Amazon Neptune与Cypher

查看使用示例

from langchain_community.graphs import NeptuneGraph
from langchain_community.graphs import NeptuneAnalyticsGraph
from langchain.chains import NeptuneOpenCypherQAChain

Amazon Neptune 与 SPARQL

查看 使用示例

from langchain_community.graphs import NeptuneRdfGraph
from langchain.chains.graph_qa.neptune_sparql import NeptuneSparqlQAChain

回调函数

SageMaker 跟踪

Amazon SageMaker 是一个完全托管的服务,用于快速和轻松地构建、训练和部署机器学习(ML)模型。

Amazon SageMaker ExperimentsAmazon SageMaker 的一项功能,允许您组织、跟踪、比较和评估 ML 实验和模型版本。

我们需要安装几个 Python 库。

pip install google-search-results sagemaker

请参阅 用例示例

from langchain.callbacks import SageMakerCallbackHandler

链接

Amazon Comprehend Moderation Chain

Amazon Comprehend 是一种自然语言处理(NLP)服务,利用机器学习发掘文本中的有价值的见解和联系。

我们需要安装 boto3nltk 库。

pip install boto3 nltk

查看 用法示例

from langchain_experimental.comprehend_moderation import AmazonComprehendModerationChain

此页面是否有帮助?


您还可以留下详细的反馈 在 GitHub 上