Skip to content

Commit

Permalink
docs,examples[patch]: Replace .getRelevantDocuments with .invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 12, 2024
1 parent 4f3deb2 commit 9329636
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/core_docs/docs/tutorials/agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions docs/core_docs/docs/tutorials/rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions examples/src/retrievers/parent_document_retriever_rerank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions examples/src/retrievers/qdrant_self_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 9329636

Please sign in to comment.