11import { RecursiveCharacterTextSplitter } from "langchain/text_splitter" ;
2- import { MongoDBAtlasVectorSearch } from "@langchain/mongodb" ;
2+ import { MongoDBVectorSearch } from "@langchain/mongodb" ;
33import { OpenAIEmbeddings } from "@langchain/openai" ;
44import { MongoClient } from "mongodb" ;
55import { PDFLoader } from "langchain/document_loaders/fs/pdf" ;
66import dotenv from "dotenv" ;
77dotenv . config ( ) ;
88
9- const client = new MongoClient ( process . env . ATLAS_CONNECTION_STRING , appname = "devrel.showcase.apps.graph_rag_demo" ) ;
9+ const client = new MongoClient ( process . env . _CONNECTION_STRING , appname = "devrel.showcase.apps.graph_rag_demo" ) ;
1010process . env . OPENAI_API_KEY = process . env . OPENAI_API_KEY1 ;
1111
1212async function run ( ) {
@@ -17,7 +17,7 @@ async function run() {
1717 const collection = database . collection ( "knowledge_graph" ) ;
1818 const dbConfig = {
1919 collection : collection ,
20- indexName : "vector_index" , // The name of the Atlas search index to use.
20+ indexName : "vector_index" , // The name of the MongoDB search index to use.
2121 textKey : "chunks" , // Field name for the raw text content. Defaults to "text".
2222 embeddingKey : "embedding" , // Field name for the vector embeddings. Defaults to "embedding".
2323 } ;
@@ -44,7 +44,7 @@ async function run() {
4444 chunkOverlap : 200 ,
4545 } ) ;
4646 const docs = await textSplitter . splitDocuments ( data ) ;
47- await MongoDBAtlasVectorSearch . fromDocuments ( docs , new OpenAIEmbeddings ( ) , dbConfig ) ;
47+ await MongoDBVectorSearch . fromDocuments ( docs , new OpenAIEmbeddings ( ) , dbConfig ) ;
4848 console . log ( "Ending sync..." , pdfname ) ;
4949 } )
5050 } catch ( error ) {
0 commit comments