From 9329636f3aff4a510d634afc60552a49bbdab288 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Wed, 12 Jun 2024 16:39:50 -0700 Subject: [PATCH] docs,examples[patch]: Replace .getRelevantDocuments with .invoke --- docs/core_docs/docs/tutorials/agents.mdx | 2 +- docs/core_docs/docs/tutorials/rag.ipynb | 4 ++-- .../src/retrievers/parent_document_retriever_rerank.ts | 4 +--- examples/src/retrievers/qdrant_self_query.ts | 8 ++++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/core_docs/docs/tutorials/agents.mdx b/docs/core_docs/docs/tutorials/agents.mdx index 26085a14bdb2..73849c2aeb6c 100644 --- a/docs/core_docs/docs/tutorials/agents.mdx +++ b/docs/core_docs/docs/tutorials/agents.mdx @@ -83,7 +83,7 @@ const vectorstore = await MemoryVectorStore.fromDocuments( ); const retriever = vectorstore.asRetriever(); -const retrieverResult = await retriever.getRelevantDocuments( +const retrieverResult = await retriever.invoke( "how to upload a dataset" ); console.log(retrieverResult[0]); diff --git a/docs/core_docs/docs/tutorials/rag.ipynb b/docs/core_docs/docs/tutorials/rag.ipynb index 483190981af6..8db0dd70f6d1 100644 --- a/docs/core_docs/docs/tutorials/rag.ipynb +++ b/docs/core_docs/docs/tutorials/rag.ipynb @@ -136,7 +136,7 @@ " outputParser: new StringOutputParser(),\n", "})\n", "\n", - "const retrievedDocs = await retriever.getRelevantDocuments(\"what is task decomposition\")" + "const retrievedDocs = await retriever.invoke(\"what is task decomposition\")" ] }, { @@ -817,7 +817,7 @@ " prompt: customRagPrompt,\n", " outputParser: new StringOutputParser(),\n", "})\n", - "const context = await retriever.getRelevantDocuments(\"what is task decomposition\");\n", + "const context = await retriever.invoke(\"what is task decomposition\");\n", "\n", "await ragChain.invoke({\n", " question: \"What is Task Decomposition?\",\n", diff --git a/examples/src/retrievers/parent_document_retriever_rerank.ts b/examples/src/retrievers/parent_document_retriever_rerank.ts index 11726aae3396..f0918b602a67 100644 --- a/examples/src/retrievers/parent_document_retriever_rerank.ts +++ b/examples/src/retrievers/parent_document_retriever_rerank.ts @@ -69,9 +69,7 @@ await retriever.addDocuments(docs); // This will search for documents in vector store and return for LLM already reranked and sorted document // with appropriate minimum relevance score -const retrievedDocs = await retriever.getRelevantDocuments( - "What is Pam's favorite color?" -); +const retrievedDocs = await retriever.invoke("What is Pam's favorite color?"); // Pam's favorite color is returned first! console.log(JSON.stringify(retrievedDocs, null, 2)); diff --git a/examples/src/retrievers/qdrant_self_query.ts b/examples/src/retrievers/qdrant_self_query.ts index 44f5ab85d39f..becc23b62096 100644 --- a/examples/src/retrievers/qdrant_self_query.ts +++ b/examples/src/retrievers/qdrant_self_query.ts @@ -118,16 +118,16 @@ const selfQueryRetriever = SelfQueryRetriever.fromLLM({ * We can also ask questions like "Which movies are either comedy or drama and are less than 90 minutes?". * The retriever will automatically convert these questions into queries that can be used to retrieve documents. */ -const query1 = await selfQueryRetriever.getRelevantDocuments( +const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); -const query2 = await selfQueryRetriever.getRelevantDocuments( +const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); -const query3 = await selfQueryRetriever.getRelevantDocuments( +const query3 = await selfQueryRetriever.invoke( "Which cool movies are directed by Greta Gerwig?" ); -const query4 = await selfQueryRetriever.getRelevantDocuments( +const query4 = await selfQueryRetriever.invoke( "Which movies are either comedy or drama and are less than 90 minutes?" ); console.log(query1, query2, query3, query4);