|
11 | 11 | "cell_type": "markdown",
|
12 | 12 | "metadata": {},
|
13 | 13 | "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", |
15 | 15 | "\n",
|
16 | 16 | "<a target=\"_blank\" href=\"https://colab.research.google.com/github/mongodb/docs-notebooks/blob/main/ai-integrations/langchain-hybrid-search.ipynb\">\n",
|
17 | 17 | " <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
|
|
28 | 28 | },
|
29 | 29 | "outputs": [],
|
30 | 30 | "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" |
32 | 32 | ]
|
33 | 33 | },
|
34 | 34 | {
|
|
39 | 39 | "source": [
|
40 | 40 | "import os\n",
|
41 | 41 | "\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", |
43 | 44 | "ATLAS_CONNECTION_STRING = \"<connection-string>\""
|
44 | 45 | ]
|
45 | 46 | },
|
|
71 | 72 | "outputs": [],
|
72 | 73 | "source": [
|
73 | 74 | "from langchain_mongodb.retrievers import MongoDBAtlasParentDocumentRetriever\n",
|
74 |
| - "from langchain_openai import OpenAIEmbeddings\n", |
| 75 | + "from langchain_voyageai import VoyageAIEmbeddings\n", |
75 | 76 | "\n",
|
76 | 77 | "# 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", |
78 | 79 | "\n",
|
79 | 80 | "# Define the chunking method for the child documents\n",
|
80 | 81 | "child_splitter = RecursiveCharacterTextSplitter(chunk_size=200, chunk_overlap=20)\n",
|
81 | 82 | "\n",
|
82 |
| - "# Database and collection name\n", |
| 83 | + "# Specify the database and collection name\n", |
83 | 84 | "database_name = \"langchain_db\"\n",
|
84 | 85 | "collection_name = \"parent_document\"\n",
|
85 | 86 | "\n",
|
|
117 | 118 | "\n",
|
118 | 119 | "# Use helper method to create the vector search index\n",
|
119 | 120 | "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", |
121 | 122 | " wait_until_complete = 60 # Number of seconds to wait for the index to build (can take around a minute)\n",
|
122 | 123 | ")\n"
|
123 | 124 | ]
|
|
0 commit comments