Skip to content

Commit 86430e5

Browse files
committed
update notebooks for search in community
1 parent 26ec3f0 commit 86430e5

36 files changed

+138
-138
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MongoDB Documentation Notebooks
22

33
This repository contains Jupyter Notebooks that follow
4-
tutorials and code examples in MongoDB's official [Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/). You can run, download, and modify these notebooks as you learn how to use MongoDB Atlas Vector Search for your use case.
4+
tutorials and code examples in MongoDB's official [MongoDB Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/). You can run, download, and modify these notebooks as you learn how to use MongoDB Vector Search for your use case.
55

66
## Overview
77

@@ -22,7 +22,7 @@ The following table summarizes the contents of the notebooks in each directory:
2222

2323
## Other Resources
2424

25-
- [MongoDB Official Documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/)
25+
- [MongoDB Vector Search Documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/)
2626
- [Generative AI Use Cases Repository](https://github.com/mongodb-developer/GenAI-Showcase/tree/main)
2727

2828
## License

ai-integrations/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# AI Integrations
22

3-
This folder contains Jupyter Notebooks that demonstrate how to integrate various AI frameworks with MongoDB. These notebooks show you how to implement RAG and other features for your AI-powered and agentic applications by leveraging MongoDB Atlas as both a vector database and document database.
3+
This folder contains Jupyter Notebooks that demonstrate how to integrate various AI frameworks with MongoDB. These notebooks show you how to implement RAG and other features for your AI-powered and agentic applications by leveraging MongoDB as both a vector database and document database.
44

55
| Notebook | Description |
66
|----------|-------------|
7-
| [langchain](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain.ipynb) | Implement basic RAG with LangChain and MongoDB Atlas Vector Search |
7+
| [langchain](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain.ipynb) | Implement basic RAG with LangChain and MongoDB Vector Search |
88
| [langchain-memory-semantic-cache](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-memory-semantic-cache.ipynb) | Implement RAG with memory with LangChain and MongoDB |
99
| [langchain-hybrid-search](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-hybrid-search.ipynb) | Combine vector search with full-text search using LangChain and MongoDB |
1010
| [langchain-parent-document-retrieval](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-parent-document-retrieval.ipynb) | Perform parent-document retrieval with LangChain and MongoDB |
@@ -13,6 +13,6 @@ This folder contains Jupyter Notebooks that demonstrate how to integrate various
1313
| [langchain-graphrag](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-graphrag.ipynb) | Implement graph-based RAG with LangChain and MongoDB |
1414
| [langchain-natural-language](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-natural-language.ipynb) | Perform natural language querying with LangChain and MongoDB |
1515
| [langgraph](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langgraph.ipynb) | Build an AI agent with LangGraph and MongoDB |
16-
| [llamaindex](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/llamaindex.ipynb) | Implement basic RAG with LlamaIndex and MongoDB Atlas |
17-
| [haystack](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/haystack.ipynb) | Implement basic RAG with Haystack and MongoDB Atlas |
18-
| [semantic-kernel](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/semantic-kernel.ipynb) | Implement basic RAG with Microsoft Semantic Kernel and MongoDB Atlas |
16+
| [llamaindex](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/llamaindex.ipynb) | Implement basic RAG with LlamaIndex and MongoDB |
17+
| [haystack](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/haystack.ipynb) | Implement basic RAG with Haystack and MongoDB |
18+
| [semantic-kernel](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/semantic-kernel.ipynb) | Implement basic RAG with Microsoft Semantic Kernel and MongoDB |

ai-integrations/haystack.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Atlas Vector Search - Haystack Integration"
7+
"# MongoDB Vector Search - Haystack Integration"
88
]
99
},
1010
{

ai-integrations/langchain-graphrag.ipynb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"\n",
1010
"This notebook is a companion to the [GraphRAG with MongoDB and LangChain](https://www.mongodb.com/docs/atlas/ai-integrations/langchain/graph-rag/) tutorial. Refer to the page for set-up instructions and detailed explanations.\n",
1111
"\n",
12-
"This notebook demonstrates a GraphRAG implementation using MongoDB Atlas and LangChain. Compared to vector-based RAG, which structures your data as vector embeddings, GraphRAG structures data as a knowledge graph with entities and their relationships. This enables relationship-aware retrieval and multi-hop reasoning.\n",
12+
"This notebook demonstrates a GraphRAG implementation using MongoDB and LangChain. Compared to vector-based RAG, which structures your data as vector embeddings, GraphRAG structures data as a knowledge graph with entities and their relationships. This enables relationship-aware retrieval and multi-hop reasoning.\n",
1313
"\n",
1414
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-graphrag.ipynb\">\n",
1515
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
@@ -37,7 +37,7 @@
3737
"\n",
3838
"Before you begin, make sure you have the following:\n",
3939
"\n",
40-
"- An Atlas cluster up and running (you'll need the [connection string](https://www.mongodb.com/docs/guides/atlas/connection-string/))\n",
40+
"- A MongoDB cluster up and running (you'll need the [connection string](https://www.mongodb.com/docs/manual/reference/connection-string/))\n",
4141
"- An API key to access an LLM (This tutorial uses a model from OpenAI, but you can use any model [supported by LangChain](https://python.langchain.com/docs/integrations/chat/))"
4242
]
4343
},
@@ -51,17 +51,17 @@
5151
"import os\n",
5252
"\n",
5353
"os.environ[\"OPENAI_API_KEY\"] = \"<api-key>\"\n",
54-
"ATLAS_CONNECTION_STRING = \"<connection-string>\"\n",
55-
"ATLAS_DB_NAME = \"langchain_db\" # MongoDB database to store the knowledge graph\n",
56-
"ATLAS_COLLECTION = \"wikipedia\" # MongoDB collection to store the knowledge graph"
54+
"MONGODB_URI = \"<connection-string>\"\n",
55+
"DB_NAME = \"langchain_db\" # MongoDB database to store the knowledge graph\n",
56+
"COLLECTION = \"wikipedia\" # MongoDB collection to store the knowledge graph"
5757
]
5858
},
5959
{
6060
"cell_type": "markdown",
6161
"id": "0adf66a8",
6262
"metadata": {},
6363
"source": [
64-
"## Use MongoDB Atlas as a knowledge graph\n",
64+
"## Use MongoDB as a knowledge graph\n",
6565
"\n",
6666
"Use the `MongoDBGraphStore` component to store your data as a knowledge graph. This component allows you to implement GraphRAG by storing entities (nodes) and their relationships (edges) in a MongoDB collection. It stores each entity as a document with relationship fields that reference other documents in your collection."
6767
]
@@ -111,9 +111,9 @@
111111
"from langchain_mongodb.graphrag.graph import MongoDBGraphStore\n",
112112
"\n",
113113
"graph_store = MongoDBGraphStore(\n",
114-
" connection_string = ATLAS_CONNECTION_STRING,\n",
115-
" database_name = ATLAS_DB_NAME,\n",
116-
" collection_name = ATLAS_COLLECTION,\n",
114+
" connection_string = MONGODB_URI,\n",
115+
" database_name = DB_NAME,\n",
116+
" collection_name = COLLECTION,\n",
117117
" entity_extraction_model = chat_model\n",
118118
")"
119119
]
@@ -125,7 +125,7 @@
125125
"metadata": {},
126126
"outputs": [],
127127
"source": [
128-
"# Extract entities and create knowledge graph in Atlas\n",
128+
"# Extract entities and create knowledge graph in MongoDB\n",
129129
"# This might take a few minutes; you can ignore any warnings\n",
130130
"graph_store.add_documents(wikipedia_docs)"
131131
]
@@ -222,9 +222,9 @@
222222
"from IPython.display import HTML, display\n",
223223
"from pymongo import MongoClient\n",
224224
"\n",
225-
"client = MongoClient(ATLAS_CONNECTION_STRING)\n",
225+
"client = MongoClient(MONGODB_URI)\n",
226226
"\n",
227-
"collection = client[ATLAS_DB_NAME][ATLAS_COLLECTION]\n",
227+
"collection = client[DB_NAME][COLLECTION]\n",
228228
"html = visualize_graph(collection)\n",
229229
"\n",
230230
"display(HTML(html))"

ai-integrations/langchain-hybrid-search.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"\n",
4242
"os.environ[\"OPENAI_API_KEY\"] = \"<api-key>\"\n",
4343
"os.environ[\"VOYAGE_API_KEY\"] = \"<voyage-api-key>\"\n",
44-
"ATLAS_CONNECTION_STRING = \"<connection-string>\""
44+
"MONGODB_URI = \"<connection-string>\""
4545
]
4646
},
4747
{
@@ -55,7 +55,7 @@
5555
"\n",
5656
"# Create the vector store\n",
5757
"vector_store = MongoDBAtlasVectorSearch.from_connection_string(\n",
58-
" connection_string = ATLAS_CONNECTION_STRING,\n",
58+
" connection_string = MONGODB_URI,\n",
5959
" embedding = VoyageAIEmbeddings(model = \"voyage-3-large\", output_dimension = 2048),\n",
6060
" namespace = \"sample_mflix.embedded_movies\",\n",
6161
" text_key = \"plot\",\n",
@@ -87,7 +87,7 @@
8787
"from pymongo import MongoClient\n",
8888
"\n",
8989
"# Connect to your cluster\n",
90-
"client = MongoClient(ATLAS_CONNECTION_STRING)\n",
90+
"client = MongoClient(MONGODB_URI)\n",
9191
"\n",
9292
"# Use helper method to create the search index\n",
9393
"create_fulltext_search_index(\n",

ai-integrations/langchain-local-rag.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
"from langchain_core.runnables import RunnablePassthrough\n",
168168
"import pprint\n",
169169
"\n",
170-
"# Instantiate Atlas Vector Search as a retriever\n",
170+
"# Instantiate MongoDB Vector Search as a retriever\n",
171171
"retriever = vector_store.as_retriever()\n",
172172
"\n",
173173
"# Define prompt template\n",

ai-integrations/langchain-natural-language.ipynb

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"id": "f9696293",
66
"metadata": {},
77
"source": [
8-
"# Query Atlas with Natural Language Using LangChain and LangGraph"
8+
"# Query MongoDB with Natural Language Using LangChain and LangGraph"
99
]
1010
},
1111
{
1212
"cell_type": "markdown",
1313
"id": "e696dea0",
1414
"metadata": {},
1515
"source": [
16-
"This notebook is a companion to the [Query Atlas with Natural Language Using LangChain and LangGraph](https://www.mongodb.com/docs/atlas/ai-integrations/langchain/natural-language-to-mql/) tutorial. Refer to the page for set-up instructions and detailed explanations.\n",
16+
"This notebook is a companion to the [Query MongoDB with Natural Language Using LangChain and LangGraph](https://www.mongodb.com/docs//ai-integrations/langchain/natural-language-to-mql/) tutorial. Refer to the page for set-up instructions and detailed explanations.\n",
1717
"\n",
18-
"This notebook demonstrates how to query an Atlas cluster with a natural language prompt using an AI agent built with the [LangChain MongoDB Toolkit](https://langchain-mongodb.readthedocs.io/en/latest/langchain_mongodb/agent_toolkit/langchain_mongodb.agent_toolkit.toolkit.MongoDBDatabaseToolkit.html#langchain_mongodb.agent_toolkit.toolkit.MongoDBDatabaseToolkit) and the [LangGraph ReAct Agent Framework](https://langchain-ai.github.io/langgraph/agents/agents/).\n",
18+
"This notebook demonstrates how to query a MongoDB cluster with a natural language prompt using an AI agent built with the [LangChain MongoDB Toolkit](https://langchain-mongodb.readthedocs.io/en/latest/langchain_mongodb/agent_toolkit/langchain_mongodb.agent_toolkit.toolkit.MongoDBDatabaseToolkit.html#langchain_mongodb.agent_toolkit.toolkit.MongoDBDatabaseToolkit) and the [LangGraph ReAct Agent Framework](https://langchain-ai.github.io/langgraph/agents/agents/).\n",
1919
"\n",
2020
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-natural-language.ipynb\">\n",
2121
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
@@ -45,7 +45,7 @@
4545
"\n",
4646
"Before you begin, make sure you have the following:\n",
4747
"\n",
48-
"- An Atlas cluster up and running (you'll need the [connection string](https://www.mongodb.com/docs/guides/atlas/connection-string/))\n",
48+
"- A MongoDB cluster up and running (you'll need the [connection string](https://www.mongodb.com/docs/manual/reference/connection-string/))\n",
4949
"- An API key to access an LLM (This tutorial uses a model from OpenAI, but you can use any model [supported by LangChain](https://python.langchain.com/docs/integrations/chat/))"
5050
]
5151
},
@@ -57,8 +57,8 @@
5757
"outputs": [],
5858
"source": [
5959
"os.environ[\"OPENAI_API_KEY\"] = '<api-key>'\n",
60-
"ATLAS_CONNECTION_STRING = '<atlas-connection-string>'\n",
61-
"ATLAS_DB_NAME = 'sample_restaurants'\n",
60+
"MONGODB_URI = '<connection-string>'\n",
61+
"DB_NAME = 'sample_restaurants'\n",
6262
"NATURAL_LANGUAGE_QUERY = 'Find all restaurants that serve hamburgers.'"
6363
]
6464
},
@@ -107,8 +107,8 @@
107107
" self.llm = ChatOpenAI(model=\"gpt-4o-mini\", timeout=60)\n",
108108
" self.system_message = MONGODB_AGENT_SYSTEM_PROMPT.format(top_k=5)\n",
109109
" self.db_wrapper = MongoDBDatabase.from_connection_string(\n",
110-
" ATLAS_CONNECTION_STRING, \n",
111-
" database=ATLAS_DB_NAME)\n",
110+
" MONGODB_URI, \n",
111+
" database=DB_NAME)\n",
112112
" self.toolkit = MongoDBDatabaseToolkit(db=self.db_wrapper, llm=self.llm)\n",
113113
" self.agent = create_react_agent(\n",
114114
" self.llm, \n",
@@ -158,25 +158,25 @@
158158
]
159159
}
160160
],
161-
"metadata": {
162-
"kernelspec": {
163-
"display_name": "Python 3",
164-
"language": "python",
165-
"name": "python3"
166-
},
167-
"language_info": {
168-
"codemirror_mode": {
169-
"name": "ipython",
170-
"version": 3
171-
},
172-
"file_extension": ".py",
173-
"mimetype": "text/x-python",
174-
"name": "python",
175-
"nbconvert_exporter": "python",
176-
"pygments_lexer": "ipython3",
177-
"version": "3.10.12"
178-
}
161+
"metadata": {
162+
"kernelspec": {
163+
"display_name": "Python 3",
164+
"language": "python",
165+
"name": "python3"
179166
},
180-
"nbformat": 4,
181-
"nbformat_minor": 2
182-
}
167+
"language_info": {
168+
"codemirror_mode": {
169+
"name": "ipython",
170+
"version": 3
171+
},
172+
"file_extension": ".py",
173+
"mimetype": "text/x-python",
174+
"name": "python",
175+
"nbconvert_exporter": "python",
176+
"pygments_lexer": "ipython3",
177+
"version": "3.10.12"
178+
}
179+
},
180+
"nbformat": 4,
181+
"nbformat_minor": 2
182+
}

ai-integrations/langchain-parent-document-retrieval.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"\n",
4242
"os.environ[\"VOYAGE_API_KEY\"] = \"<voyage-api-key>\"\n",
4343
"os.environ[\"OPENAI_API_KEY\"] = \"<openai-api-key>\"\n",
44-
"ATLAS_CONNECTION_STRING = \"<connection-string>\""
44+
"MONGODB_URI = \"<connection-string>\""
4545
]
4646
},
4747
{
@@ -86,7 +86,7 @@
8686
"\n",
8787
"# Create the parent document retriever\n",
8888
"parent_doc_retriever = MongoDBAtlasParentDocumentRetriever.from_connection_string(\n",
89-
" connection_string = ATLAS_CONNECTION_STRING,\n",
89+
" connection_string = MONGODB_URI,\n",
9090
" child_splitter = child_splitter,\n",
9191
" embedding_model = embedding_model,\n",
9292
" database_name = database_name,\n",

ai-integrations/langchain-self-query-retrieval.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"id": "a5762ee0",
155155
"metadata": {},
156156
"source": [
157-
"## Create the Atlas Vector Search index with filters"
157+
"## Create the Vector Search index with filters"
158158
]
159159
},
160160
{

ai-integrations/langchain.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"\n",
4242
"os.environ[\"VOYAGE_API_KEY\"] = \"<voyage-api-key>\"\n",
4343
"os.environ[\"OPENAI_API_KEY\"] = \"<openai-api-key>\"\n",
44-
"ATLAS_CONNECTION_STRING = \"<connection-string>\""
44+
"MONGODB_URI = \"<connection-string>\""
4545
]
4646
},
4747
{
@@ -76,7 +76,7 @@
7676
"\n",
7777
"# Instantiate the vector store using your MongoDB connection string\n",
7878
"vector_store = MongoDBAtlasVectorSearch.from_connection_string(\n",
79-
" connection_string = ATLAS_CONNECTION_STRING,\n",
79+
" connection_string = MONGODB_URI,\n",
8080
" namespace = \"langchain_db.test\",\n",
8181
" embedding = VoyageAIEmbeddings(model=\"voyage-3-large\"),\n",
8282
" index_name = \"vector_index\"\n",
@@ -184,7 +184,7 @@
184184
"from langchain_openai import ChatOpenAI\n",
185185
"from langchain.prompts import PromptTemplate\n",
186186
"\n",
187-
"# Instantiate Atlas Vector Search as a retriever\n",
187+
"# Instantiate MongoDB Vector Search as a retriever\n",
188188
"retriever = vector_store.as_retriever(\n",
189189
" search_type = \"similarity\",\n",
190190
" search_kwargs = { \"k\": 10 }\n",
@@ -241,7 +241,7 @@
241241
"metadata": {},
242242
"outputs": [],
243243
"source": [
244-
"# Instantiate Atlas Vector Search as a retriever\n",
244+
"# Instantiate MongoDB Vector Search as a retriever\n",
245245
"retriever = vector_store.as_retriever(\n",
246246
" search_type = \"similarity\",\n",
247247
" search_kwargs = {\n",

0 commit comments

Comments
 (0)