Docs 菜单
Docs 主页
/
MongoDB Atlas
/ /

开始使用 LangChain 集成

在此页面上

  • 背景
  • 先决条件
  • 设置环境
  • 使用 Atlas 作为向量存储
  • 创建 Atlas Vector Search 索引
  • 运行向量搜索查询
  • 回答有关数据的问题
  • 后续步骤

注意

本教程使用 LangChain 的 Python 库 。有关使用 JavaScript 库的教程,请参阅 开始使用 LangChain JS/TS 集成。

您可以将 Atlas Vector Search 与 LangChain 集成 构建 LLM 应用程序并实施检索增强生成 (RAG)。本教程演示如何开始将Atlas Vector Search与 LangChain 结合使用,对数据执行语义Atlas Search并构建RAG实施。 具体来说,您执行以下操作:

  1. 设置环境。

  2. 在 Atlas 上存储自定义数据。

  3. 在您的数据上创建一个 Atlas Vector Search 索引。

  4. 运行以下向量搜索查询:

    • 语义搜索。

    • 带分数的语义搜索。

    • 带元数据预过滤的语义搜索。

  5. 使用 Atlas Vector Search 来回答有关数据的问题,从而实施RAG

LangChain 是一个开源框架,可通过使用“链”来简化LLM应用程序的创建。 链是 LangChain 特有的组件,可组合用于各种 AI 使用案例,包括RAG

通过将 Atlas Vector Search 与 LangChain 集成,您可以将 Atlas 用作向量数据库,并使用 Atlas Vector Search 从数据中检索语义相似的文档来实施RAG 。要了解有关RAG的更多信息,请参阅使用 Atlas Vector Search 进行检索增强生成 (RAG)。

如要完成本教程,您必须具备以下条件:

  • 运行 MongoDB 6.0.11 版本的 Atlas 集群, 7.0.2 或更高版本(包括RC )。

  • OpenAI API 密钥。 您必须拥有一个 OpenAI 付费帐户,并有可用于 API 请求的信用。

  • 运行交互式 Python 笔记本(例如 Colab)的环境。

    注意

    如果使用 Colab,请确保笔记本会话的 IP 地址包含在 Atlas 项目的访问列表中。

您必须首先为本教程设置环境。通过保存扩展名为 .ipynb的文件来创建交互式 Python 笔记本,然后在笔记本中运行以下代码片段。

1

运行以下命令:

%pip install --upgrade --quiet langchain langchain-community langchain-core langchain-mongodb langchain-openai pymongo pypdf

然后,运行以下代码以导入所需的包:

import getpass, os, pymongo, pprint
from langchain_community.document_loaders import PyPDFLoader
from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables import RunnablePassthrough
from langchain_mongodb import MongoDBAtlasVectorSearch
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain.prompts import PromptTemplate
from langchain.text_splitter import RecursiveCharacterTextSplitter
from pymongo import MongoClient
from pymongo.operations import SearchIndexModel
2

运行以下代码并在出现提示时提供以下内容:

os.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")
ATLAS_CONNECTION_STRING = getpass.getpass("MongoDB Atlas SRV Connection String:")

注意

连接字符串应使用以下格式:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

然后,将自定义数据加载到 Atlas 并将 Atlas 实例化为向量数据库(也称为 向量存储 ) 。将以下代码片段复制并粘贴到笔记本中。

1

运行以下代码,建立与 Atlas 集群的连接。 它指定了以下内容:

  • langchain_db.test 作为要加载数据的collection的名称。

  • vector_index 作为用于查询数据的 Atlas Vector Search 索引的名称。

# Connect to your Atlas cluster
client = MongoClient(ATLAS_CONNECTION_STRING)
# Define collection and index name
db_name = "langchain_db"
collection_name = "test"
atlas_collection = client[db_name][collection_name]
vector_search_index = "vector_index"
2

在本教程中,您将使用可公开访问的 PDF 文档,标题为“ MongoDB Atlas 最佳实践 ” 作为向量存储的数据源。本文档介绍了管理 Atlas 部署的各种建议和核心概念。

要加载样本数据,请运行以下代码片段。 它执行以下操作:

  • 从指定的 URL 检索 PDF 并加载原始文本数据。

  • 使用 文本分割器 将数据拆分为较小的文档。

  • 指定数据块参数,它确定每个文档中的字符数以及两个连续文档之间应重叠的字符数。

# Load the PDF
loader = PyPDFLoader("https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP")
data = loader.load()
# Split PDF into documents
text_splitter = RecursiveCharacterTextSplitter(chunk_size=200, chunk_overlap=20)
docs = text_splitter.split_documents(data)
# Print the first document
docs[0]
Document(page_content='Mong oDB Atlas Best P racticesJanuary 20 19A MongoD B White P aper', metadata={'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 0})
3

运行以下代码,从示例文档创建名为vector_store的向量存储。 此代码段使用MongoDBAtlasVectorSearch.from_documents方法并指定以下参数:

  • 要存储在向量数据库中的示例文档。

  • OpenAI 的嵌入模型用于将文本转换为embedding字段的向量嵌入。

  • langchain_db.test 作为 Atlas 集合来存储文档。

  • vector_index 作为用于查询向量存储的索引。

# Create the vector store
vector_store = MongoDBAtlasVectorSearch.from_documents(
documents = docs,
embedding = OpenAIEmbeddings(disallowed_special=()),
collection = atlas_collection,
index_name = vector_search_index
)

提示

运行示例代码后,您可以导航到您的集群中的langchain_db.test collection,在 Atlas 用户界面中查看向量嵌入。

注意

要创建 Atlas Vector Search 索引,您必须对 Atlas 项目具有Project Data Access Admin或更高访问权限。

要在向量存储上启用向量搜索查询,请在langchain_db.test集合上创建 Atlas Vector Search 索引。

在您的笔记本中,运行以下代码以创建vectorSearch类型的索引,该索引指定对以下字段进行索引:

  • embedding 字段作为向量类型。 embedding字段包含使用 OpenAI 的text-embedding-ada-002嵌入模型创建的嵌入。 索引定义指定了1536向量维度,并使用cosine来衡量相似性。

  • page 字段作为筛选器类型,用于按 PDF 中的页码对数据进行预筛选。

1# Create your index model, then create the search index
2search_index_model = SearchIndexModel(
3 definition={
4 "fields": [
5 {
6 "type": "vector",
7 "path": "embedding",
8 "numDimensions": 1536,
9 "similarity": "cosine"
10 },
11 {
12 "type": "filter",
13 "path": "page"
14 }
15 ]
16 },
17 name="vector_index",
18 type="vectorSearch"
19)
20
21atlas_collection.create_search_index(model=search_index_model)

构建索引大约需要一分钟时间。在构建时,索引处于初始同步状态。构建完成后,您可以开始查询集合中的数据。

Atlas 构建索引后,对数据运行向量搜索查询。以下示例演示了可以对矢量化数据运行的各种查询。

以下查询使用similarity_search方法对字符串MongoDB Atlas security执行基本语义搜索。 它返回按相关性排名的文档列表。

query = "MongoDB Atlas security"
results = vector_store.similarity_search(query)
pprint.pprint(results)
[Document(page_content='To ensure a secure system right out of the b ox,\nauthentication and I P Address whitelisting are\nautomatically enabled.\nReview the security section of the MongoD B Atlas', metadata={'_id': ObjectId('65c2e8f480f26794dedad8d5'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='MongoD B Atlas team are also monitoring the underlying\ninfrastructure, ensuring that it is always in a healthy state.\nApplication L ogs And Database L ogs', metadata={'_id': ObjectId('65c2e8f480f26794dedad8a0'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 15}),
Document(page_content='MongoD B.\nMongoD B Atlas incorporates best practices to help keep\nmanaged databases healthy and optimized. T hey ensure\noperational continuity by converting comple x manual tasks', metadata={'_id': ObjectId('65c2e8f380f26794dedad883'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 13}),
Document(page_content='Atlas provides encryption of data at rest with encrypted\nstorage volumes.\nOptionally , Atlas users can configure an additional layer of\nencryption on their data at rest using the MongoD B', metadata={'_id': ObjectId('65c2e8f480f26794dedad8e3'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 18})]

以下查询使用similarity_search_with_score方法对字符串MongoDB Atlas security执行语义搜索,并指定k参数以将返回的文档数量限制为3

注意

此示例中的k参数指的是similarity_search_with_score方法选项,而不是同名的knnBeta操作符选项。

它返回三个最相关的文档以及介于01之间的相关性分数

query = "MongoDB Atlas security"
results = vector_store.similarity_search_with_score(
query = query, k = 3
)
pprint.pprint(results)
[(Document(page_content='To ensure a secure system right out of the b ox,\nauthentication and I P Address whitelisting are\nautomatically enabled.\nReview the security section of the MongoD B Atlas', metadata={'_id': ObjectId('65c2e8f480f26794dedad8d5'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
0.935082197189331),
(Document(page_content='MongoD B Atlas team are also monitoring the underlying\ninfrastructure, ensuring that it is always in a healthy state.\nApplication L ogs And Database L ogs', metadata={'_id': ObjectId('65c2e8f480f26794dedad8a0'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 15}),
0.9335962533950806),
(Document(page_content='MongoD B.\nMongoD B Atlas incorporates best practices to help keep\nmanaged databases healthy and optimized. T hey ensure\noperational continuity by converting comple x manual tasks', metadata={'_id': ObjectId('65c2e8f380f26794dedad883'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 13}),
0.9317940473556519)]

您可以使用MQL匹配表达式对数据进行预过滤,该表达式将索引字段与布尔值、数字值或字符串值进行比较。您必须将要筛选的任何元数据字段作为filter类型进行索引。要了解更多信息,请参阅如何为向量搜索的字段编制索引。

注意

在为本教程创建索引时,您已指定page字段作为筛选器。

以下查询使用similarity_search_with_score方法对字符串MongoDB Atlas security执行语义搜索。它还指定了以下内容:

  • k参数,用于将要返回的文档数量限制为3

  • 针对page字段的预筛选器,使用$eq操作符仅匹配出现在17页上的文档。

它返回17页中三个最相关的文档以及介于01之间的相关性分数

query = "MongoDB Atlas security"
results = vector_store.similarity_search_with_score(
query = query,
k = 3,
pre_filter = { "page": { "$eq": 17 } }
)
pprint.pprint(results)
[(Document(page_content='To ensure a secure system right out of the b ox,\nauthentication and I P Address whitelisting are\nautomatically enabled.\nReview the security section of the MongoD B Atlas', metadata={'_id': ObjectId('65c2e8f480f26794dedad8d5'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
0.935082197189331),
(Document(page_content='Security\nAs with all software, MongoD B administrators must\nconsider security and risk e xposure for a MongoD B\ndeployment. T here are no magic solutions for risk', metadata={'_id': ObjectId('65c2e8f480f26794dedad8d0'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
0.920635461807251),
(Document(page_content='number of diff erent methods for managing risk and\nreducing risk e xposure.\nMongoD B Atlas f eatures e xtensive capabilities to def end,\ndetect, and control access to MongoD B, off ering among', metadata={'_id': ObjectId('65c2e8f480f26794dedad8d2'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
0.9206267595291138)]

提示

另请参阅:

有关语义搜索方法的完整列表,请参阅 API 参考。

本节演示如何使用 Atlas Vector Search 和 LangChain 在您的应用程序中实现 RAG。 现在您已经使用 Atlas Vector Search 检索语义相似的文档,请运行以下代码示例来提示 LLM 根据这些文档回答问题。

此示例执行以下操作:

  • 将 Atlas Vector Search 实例化为 检索器 查询类似文档,包括可选的 参数,以便仅搜索 最相关的文档。k10

  • 定义 LangChain 提示模板 以指示 法学硕士 使用这些文档作为查询的上下文。 LangChain 将这些文档传递给{context} 输入变量,并将您的查询传递给{question} 变量。

  • 构建一条 指定以下内容:

    • 使用 Atlas Vector Search 作为检索器来搜索 LLM 使用的上下文文档。

    • 您构建的提示模板。

    • OpenAI 的聊天模型作为 LLM,用于生成情境感知响应。

  • 用有关 Atlas 安全建议的示例查询提示链。

  • 返回LLM的响应以及用作上下文的文档。生成的响应可能会有所不同。

# Instantiate Atlas Vector Search as a retriever
retriever = vector_store.as_retriever(
search_type = "similarity",
search_kwargs = { "k": 10 }
)
# Define a prompt template
template = """
Use the following pieces of context to answer the question at the end.
If you don't know the answer, just say that you don't know, don't try to make up an answer.
{context}
Question: {question}
"""
custom_rag_prompt = PromptTemplate.from_template(template)
llm = ChatOpenAI()
def format_docs(docs):
return "\n\n".join(doc.page_content for doc in docs)
# Construct a chain to answer questions on your data
rag_chain = (
{ "context": retriever | format_docs, "question": RunnablePassthrough()}
| custom_rag_prompt
| llm
| StrOutputParser()
)
# Prompt the chain
question = "How can I secure my MongoDB Atlas cluster?"
answer = rag_chain.invoke(question)
print("Question: " + question)
print("Answer: " + answer)
# Return source documents
documents = retriever.invoke(question)
print("\nSource documents:")
pprint.pprint(documents)
Question: How can I secure my MongoDB Atlas cluster?
Answer: To secure your MongoDB Atlas cluster, you can enable
authentication and IP address whitelisting, review the security section
in the MongoDB Atlas dashboard, encrypt data at rest with encrypted storage
volumes, optionally configure an additional layer of encryption on your
data, set up global clusters on Amazon Web Services, Microsoft Azure,
and Google Cloud Platform, and ensure operational continuity by choosing
appropriate instance size, storage size, and storage speed options.
Additionally, consider setting up a larger number of replica nodes for
increased protection against database downtime.
Source documents:
[Document(page_content='To ensure a secure system right out of the b ox,\nauthentication and I P Address whitelisting are\nautomatically enabled.\nReview the security section of the MongoD B Atlas', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0436'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='MongoD B Atlas team are also monitoring the underlying\ninfrastructure, ensuring that it is always in a healthy state.\nApplication L ogs And Database L ogs', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0401'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 15}),
Document(page_content='All the user needs to do in order for MongoD B Atlas to\nautomatically deploy the cluster is to select a handful of\noptions:\n•Instance size\n•Storage size (optional)\n•Storage speed (optional)', metadata={'_id': ObjectId('65fb4f046979cf7cbbfe03ef'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 14}),
Document(page_content='MongoD B.\nMongoD B Atlas incorporates best practices to help keep\nmanaged databases healthy and optimized. T hey ensure\noperational continuity by converting comple x manual tasks', metadata={'_id': ObjectId('65fb4f046979cf7cbbfe03e4'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 13}),
Document(page_content='You can set up global clusters — available on Amazon W eb\nServices, Microsoft Azure, and Google Cloud Platform —\nwith just a f ew clic ks in the MongoD B Atlas U I. MongoD B', metadata={'_id': ObjectId('65fb4f046979cf7cbbfe03bb'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 12}),
Document(page_content='Table of Contents\n1 Introduction\n2 Preparing for a MongoD B Deployment\n9 Scaling a MongoD B Atlas Cluster\n11 Continuous A vailability & Data Consistency\n12 Managing MongoD B\n16 Security', metadata={'_id': ObjectId('65fb4f026979cf7cbbfe02d6'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 1}),
Document(page_content='Atlas provides encryption of data at rest with encrypted\nstorage volumes.\nOptionally , Atlas users can configure an additional layer of\nencryption on their data at rest using the MongoD B', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0444'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 18}),
Document(page_content='Disaster Recovery\nCreated by the engineers who develop the database,\nMongoD B Atlas is the simplest way to run MongoD B,\nmaking it easy to deploy , monitor , backup, and scale\nMongoD B.', metadata={'_id': ObjectId('65fb4f046979cf7cbbfe03e3'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 13}),
Document(page_content='Security\nAs with all software, MongoD B administrators must\nconsider security and risk e xposure for a MongoD B\ndeployment. T here are no magic solutions for risk', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0431'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='A larger number of replica nodes provides increased\nprotection against database downtime in case of multiple\nmachine failures.\nMongoD B Atlas replica sets have a minimum of 3 nodes', metadata={'_id': ObjectId('65fb4f046979cf7cbbfe03ca'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 12})]

此示例执行以下操作:

  • 将 Atlas Vector Search 实例化为 检索器 查询相似文档,包括以下可选参数:

    • k 仅搜索10最相关的文档。

    • score_threshold 仅使用相关性得分高于0.75的文档。

      注意

      此参数是指 LangChain 用于规范化结果的相关性分数,而不是在 Atlas Search 查询中使用的相关性分数。要在RAG实施中使用 Atlas Search 分数,请定义一个自定义检索器,该检索器使用similarity_search_with_score方法并按 Atlas Search 分数进行过滤。

    • pre_filterpage字段中筛选仅出现在17页上的文档。

  • 定义 LangChain 提示模板 以指示 法学硕士 使用这些文档作为查询的上下文。 LangChain 将这些文档传递给{context} 输入变量,并将您的查询传递给{question} 变量。

  • 构建一条 指定以下内容:

    • 使用 Atlas Vector Search 作为检索器来搜索 LLM 使用的上下文文档。

    • 您构建的提示模板。

    • OpenAI 的聊天模型作为 LLM,用于生成情境感知响应。

  • 用有关 Atlas 安全建议的示例查询提示链。

  • 返回LLM的响应以及用作上下文的文档。生成的响应可能会有所不同。

# Instantiate Atlas Vector Search as a retriever
retriever = vector_store.as_retriever(
search_type = "similarity",
search_kwargs = {
"k": 10,
"score_threshold": 0.75,
"pre_filter": { "page": { "$eq": 17 } }
}
)
# Define a prompt template
template = """
Use the following pieces of context to answer the question at the end.
If you don't know the answer, just say that you don't know, don't try to make up an answer.
{context}
Question: {question}
"""
custom_rag_prompt = PromptTemplate.from_template(template)
llm = ChatOpenAI()
def format_docs(docs):
return "\n\n".join(doc.page_content for doc in docs)
# Construct a chain to answer questions on your data
rag_chain = (
{ "context": retriever | format_docs, "question": RunnablePassthrough()}
| custom_rag_prompt
| llm
| StrOutputParser()
)
# Prompt the chain
question = "How can I secure my MongoDB Atlas cluster?"
answer = rag_chain.invoke(question)
print("Question: " + question)
print("Answer: " + answer)
# Return source documents
documents = retriever.invoke(question)
print("\nSource documents:")
pprint.pprint(documents)
Question: How can I secure my MongoDB Atlas cluster?
Answer: To secure your MongoDB Atlas cluster, you can enable
authentication and IP Address whitelisting, define permissions
for users and applications, use VPC Peering for secure connectivity,
implement a Defense in Depth approach for securing deployments, and
consider using LDAP integration for centralized authorization
management. It is important to regularly review the security section
of MongoDB Atlas and continuously monitor and update security measures
to mitigate risk and maintain a secure deployment.
Source documents:
[Document(page_content='To ensure a secure system right out of the b ox,\nauthentication and I P Address whitelisting are\nautomatically enabled.\nReview the security section of the MongoD B Atlas', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0436'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='Security\nAs with all software, MongoD B administrators must\nconsider security and risk e xposure for a MongoD B\ndeployment. T here are no magic solutions for risk', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0431'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='number of diff erent methods for managing risk and\nreducing risk e xposure.\nMongoD B Atlas f eatures e xtensive capabilities to def end,\ndetect, and control access to MongoD B, off ering among', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0433'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='permissions for a user or application, and what data it can\naccess when querying MongoD B. MongoD B Atlas provides\nthe ability to provision users with roles specific to a', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe043b'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='connectivity without using public I P addresses, and without\nneeding to whitelist every client in your MongoD B Atlas\ngroup.\nAuthorization\nMongoD B Atlas allows administrators to define', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe043a'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='mitigation, and maintaining a secure MongoD B deployment\nis an ongoing process.\nDefense in Depth\nA Def ense in Depth approac h is recommended for\nsecuring MongoD B deployments, and it addresses a', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0432'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='optimization.\nIn addition, MongoD B Atlas provides pac kaged integration\nwith the New Relic platform. K ey metrics from MongoD B\nAtlas are accessible to the AP M for visualization, enabling', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe042e'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='their I P address (or a C IDR covering their I P address) has\nbeen added to the IP whitelist for your MongoD B Atlas\ngroup.\nVPC P eering\nVirtual P rivate Cloud (VPC) P eering allows users to create', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe0438'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='dedicated A tlas clusters using credentials that are verified\nby a centralized L DAP server . Authorization management is\nsimplified by allowing control at the L DAP group level.', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe043d'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17}),
Document(page_content='database, making it possible to realize a separation of\nduties between diff erent entities accessing and managing\nthe data.\nAtlas supports L DAP integration, allowing users to login to', metadata={'_id': ObjectId('65fb4f056979cf7cbbfe043c'), 'source': 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP', 'page': 17})]

要了解 Atlas Vector Search 的其他RAG使用案例,请参阅 LangChain 提供的以下模板来帮助您构建应用程序:

MongoDB 还提供以下开发者资源:

后退

AI 集成