Skip to content

Commit c6847e3

Browse files
authored
Merge pull request #21 from davidhou17/DOCSP-50370
(DOCSP-50370): Create new LangChain self-query retrieval notebook
2 parents af95f91 + faf9e4f commit c6847e3

File tree

9 files changed

+690
-177
lines changed

9 files changed

+690
-177
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ The following table summarizes the contents of the notebooks in each directory:
1414
|--------------------|--------------------------------------------------|
1515
| [/create-embeddings](https://github.com/mongodb/docs-notebooks/tree/main/create-embeddings) | Learn how to generate embeddings for vector search |
1616
| [/get-started](https://github.com/mongodb/docs-notebooks/tree/main/get-started) | Complete our quick start tutorial |
17-
| [/ai-integrations](https://github.com/mongodb/docs-notebooks/tree/main/ai-integrations) | Implement RAG with popular AI frameworks that integrate with MongoDB |
17+
| [/ai-integrations](https://github.com/mongodb/docs-notebooks/tree/main/ai-integrations) | Build AI applications and agents with popular AI frameworks that integrate with MongoDB |
1818
| [/manage-indexes](https://github.com/mongodb/docs-notebooks/tree/main/manage-indexes) | Create, view, edit, and delete vector search indexes |
1919
| [/quantization](https://github.com/mongodb/docs-notebooks/tree/main/quantization) | Quantize your vector embeddings for efficient processing |
2020
| [/run-queries](https://github.com/mongodb/docs-notebooks/tree/main/run-queries) | Learn how to run vector search queries (ANN and ENN) |
21-
| [/use-cases](https://github.com/mongodb/docs-notebooks/tree/main/use-cases) | Implement RAG using a MongoDB-native retrieval system |
21+
| [/use-cases](https://github.com/mongodb/docs-notebooks/tree/main/use-cases) | Implement RAG and build AI agents using a MongoDB-native retrieval system |
2222

2323
## Other Resources
2424

ai-integrations/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# AI Integrations
2+
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.
4+
5+
| Notebook | Description |
6+
|----------|-------------|
7+
| [langchain](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain.ipynb) | Implement basic RAG with LangChain and MongoDB Atlas Vector Search |
8+
| [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 |
9+
| [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 |
10+
| [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 |
11+
| [langchain-self-query-retrieval](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-self-query-retrieval.ipynb) | Perform self-querying retrieval with LangChain and MongoDB |
12+
| [langchain-local-rag](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-local-rag.ipynb) | Implement RAG with local models with LangChain and MongoDB |
13+
| [langchain-graphrag](https://github.com/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-graphrag.ipynb) | Implement graph-based RAG with LangChain and MongoDB |
14+
| [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 |
15+
| [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 |

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"This notebook is a companion to the [LangChain Parent Document Retrieval](https://www.mongodb.com/docs/atlas/atlas-vector-search/ai-integrations/langchain/parent-document-retrieval/) page. Refer to the page for set-up instructions and detailed explanations.\n",
14+
"This notebook is a companion to the [Parent Document Retrieval](https://www.mongodb.com/docs/atlas/atlas-vector-search/ai-integrations/langchain/parent-document-retrieval/) page. Refer to the page for set-up instructions and detailed explanations.\n",
1515
"\n",
1616
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-hybrid-search.ipynb\">\n",
1717
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
@@ -28,7 +28,7 @@
2828
},
2929
"outputs": [],
3030
"source": [
31-
"pip install --quiet --upgrade langchain langchain-community langchain-core langchain-mongodb langchain-openai pymongo pypdf"
31+
"pip install --quiet --upgrade langchain langchain-community langchain-core langchain-mongodb langchain-voyageai langchain-openai pymongo pypdf"
3232
]
3333
},
3434
{
@@ -39,7 +39,8 @@
3939
"source": [
4040
"import os\n",
4141
"\n",
42-
"os.environ[\"OPENAI_API_KEY\"] = \"<api-key>\"\n",
42+
"os.environ[\"VOYAGE_API_KEY\"] = \"<voyage-api-key>\"\n",
43+
"os.environ[\"OPENAI_API_KEY\"] = \"<openai-api-key>\"\n",
4344
"ATLAS_CONNECTION_STRING = \"<connection-string>\""
4445
]
4546
},
@@ -71,15 +72,15 @@
7172
"outputs": [],
7273
"source": [
7374
"from langchain_mongodb.retrievers import MongoDBAtlasParentDocumentRetriever\n",
74-
"from langchain_openai import OpenAIEmbeddings\n",
75+
"from langchain_voyageai import VoyageAIEmbeddings\n",
7576
"\n",
7677
"# Define the embedding model to use\n",
77-
"embedding_model = OpenAIEmbeddings(model=\"text-embedding-3-small\")\n",
78+
"embedding_model = VoyageAIEmbeddings(model=\"voyage-3-large\")\n",
7879
"\n",
7980
"# Define the chunking method for the child documents\n",
8081
"child_splitter = RecursiveCharacterTextSplitter(chunk_size=200, chunk_overlap=20)\n",
8182
"\n",
82-
"# Database and collection name\n",
83+
"# Specify the database and collection name\n",
8384
"database_name = \"langchain_db\"\n",
8485
"collection_name = \"parent_document\"\n",
8586
"\n",
@@ -117,7 +118,7 @@
117118
"\n",
118119
"# Use helper method to create the vector search index\n",
119120
"vector_store.create_vector_search_index(\n",
120-
" dimensions = 1536, # The dimensions of the vector embeddings to be indexed\n",
121+
" dimensions = 1024, # The dimensions of the vector embeddings to be indexed\n",
121122
" wait_until_complete = 60 # Number of seconds to wait for the index to build (can take around a minute)\n",
122123
")\n"
123124
]

0 commit comments

Comments
 (0)