Skip to content

Commit

Permalink
docs,examples[patch]: Replace .getRelevantDocuments with .invoke (#5749)
Browse files Browse the repository at this point in the history
* docs,examples[patch]: Replace .getRelevantDocuments with .invoke

* fix formatting issue
  • Loading branch information
bracesproul authored Jun 13, 2024
1 parent 09f6af2 commit ce4b8ef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions docs/core_docs/docs/tutorials/agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ const vectorstore = await MemoryVectorStore.fromDocuments(
);
const retriever = vectorstore.asRetriever();

const retrieverResult = await retriever.getRelevantDocuments(
"how to upload a dataset"
);
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 ce4b8ef

Please sign in to comment.