patch: deprecate (a)get_relevant_documents (#20477)

- `.get_relevant_documents(query)` -> `.invoke(query)`
- `.get_relevant_documents(query=query)` -> `.invoke(query)`
- `.get_relevant_documents(query, callbacks=callbacks)` ->
`.invoke(query, config={"callbacks": callbacks})`
- `.get_relevant_documents(query, **kwargs)` -> `.invoke(query,
**kwargs)`

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
pull/20460/head^2
ccurme 4 weeks ago committed by GitHub
parent 939d113d10
commit c010ec8b71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -604,7 +604,7 @@
"source": [ "source": [
"# Check retrieval\n", "# Check retrieval\n",
"query = \"Give me company names that are interesting investments based on EV / NTM and NTM rev growth. Consider EV / NTM multiples vs historical?\"\n", "query = \"Give me company names that are interesting investments based on EV / NTM and NTM rev growth. Consider EV / NTM multiples vs historical?\"\n",
"docs = retriever_multi_vector_img.get_relevant_documents(query, limit=6)\n", "docs = retriever_multi_vector_img.invoke(query, limit=6)\n",
"\n", "\n",
"# We get 4 docs\n", "# We get 4 docs\n",
"len(docs)" "len(docs)"
@ -630,7 +630,7 @@
"source": [ "source": [
"# Check retrieval\n", "# Check retrieval\n",
"query = \"What are the EV / NTM and NTM rev growth for MongoDB, Cloudflare, and Datadog?\"\n", "query = \"What are the EV / NTM and NTM rev growth for MongoDB, Cloudflare, and Datadog?\"\n",
"docs = retriever_multi_vector_img.get_relevant_documents(query, limit=6)\n", "docs = retriever_multi_vector_img.invoke(query, limit=6)\n",
"\n", "\n",
"# We get 4 docs\n", "# We get 4 docs\n",
"len(docs)" "len(docs)"

@ -604,7 +604,7 @@
], ],
"source": [ "source": [
"query = \"What are the EV / NTM and NTM rev growth for MongoDB, Cloudflare, and Datadog?\"\n", "query = \"What are the EV / NTM and NTM rev growth for MongoDB, Cloudflare, and Datadog?\"\n",
"docs = retriever_multi_vector_img.get_relevant_documents(query, limit=1)\n", "docs = retriever_multi_vector_img.invoke(query, limit=1)\n",
"\n", "\n",
"# We get 2 docs\n", "# We get 2 docs\n",
"len(docs)" "len(docs)"

@ -562,9 +562,7 @@
], ],
"source": [ "source": [
"# We can retrieve this table\n", "# We can retrieve this table\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What are results for LLaMA across across domains / subjects?\")[1]"
" \"What are results for LLaMA across across domains / subjects?\"\n",
")[1]"
] ]
}, },
{ {
@ -614,9 +612,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"Images / figures with playful and creative examples\")[\n", "retriever.invoke(\"Images / figures with playful and creative examples\")[1]"
" 1\n",
"]"
] ]
}, },
{ {

@ -501,9 +501,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"Images / figures with playful and creative examples\")[\n", "retriever.invoke(\"Images / figures with playful and creative examples\")[0]"
" 0\n",
"]"
] ]
}, },
{ {

@ -342,7 +342,7 @@
"# Testing on retrieval\n", "# Testing on retrieval\n",
"query = \"What percentage of CPI is dedicated to Housing, and how does it compare to the combined percentage of Medical Care, Apparel, and Other Goods and Services?\"\n", "query = \"What percentage of CPI is dedicated to Housing, and how does it compare to the combined percentage of Medical Care, Apparel, and Other Goods and Services?\"\n",
"suffix_for_images = \" Include any pie charts, graphs, or tables.\"\n", "suffix_for_images = \" Include any pie charts, graphs, or tables.\"\n",
"docs = retriever_multi_vector_img.get_relevant_documents(query + suffix_for_images)" "docs = retriever_multi_vector_img.invoke(query + suffix_for_images)"
] ]
}, },
{ {

@ -169,7 +169,7 @@
"\n", "\n",
"def get_tools(query):\n", "def get_tools(query):\n",
" # Get documents, which contain the Plugins to use\n", " # Get documents, which contain the Plugins to use\n",
" docs = retriever.get_relevant_documents(query)\n", " docs = retriever.invoke(query)\n",
" # Get the toolkits, one for each plugin\n", " # Get the toolkits, one for each plugin\n",
" tool_kits = [toolkits_dict[d.metadata[\"plugin_name\"]] for d in docs]\n", " tool_kits = [toolkits_dict[d.metadata[\"plugin_name\"]] for d in docs]\n",
" # Get the tools: a separate NLAChain for each endpoint\n", " # Get the tools: a separate NLAChain for each endpoint\n",

@ -193,7 +193,7 @@
"\n", "\n",
"def get_tools(query):\n", "def get_tools(query):\n",
" # Get documents, which contain the Plugins to use\n", " # Get documents, which contain the Plugins to use\n",
" docs = retriever.get_relevant_documents(query)\n", " docs = retriever.invoke(query)\n",
" # Get the toolkits, one for each plugin\n", " # Get the toolkits, one for each plugin\n",
" tool_kits = [toolkits_dict[d.metadata[\"plugin_name\"]] for d in docs]\n", " tool_kits = [toolkits_dict[d.metadata[\"plugin_name\"]] for d in docs]\n",
" # Get the tools: a separate NLAChain for each endpoint\n", " # Get the tools: a separate NLAChain for each endpoint\n",

@ -142,7 +142,7 @@
"\n", "\n",
"\n", "\n",
"def get_tools(query):\n", "def get_tools(query):\n",
" docs = retriever.get_relevant_documents(query)\n", " docs = retriever.invoke(query)\n",
" return [ALL_TOOLS[d.metadata[\"index\"]] for d in docs]" " return [ALL_TOOLS[d.metadata[\"index\"]] for d in docs]"
] ]
}, },

@ -206,7 +206,7 @@
" print(\"---RETRIEVE---\")\n", " print(\"---RETRIEVE---\")\n",
" state_dict = state[\"keys\"]\n", " state_dict = state[\"keys\"]\n",
" question = state_dict[\"question\"]\n", " question = state_dict[\"question\"]\n",
" documents = retriever.get_relevant_documents(question)\n", " documents = retriever.invoke(question)\n",
" return {\"keys\": {\"documents\": documents, \"question\": question}}\n", " return {\"keys\": {\"documents\": documents, \"question\": question}}\n",
"\n", "\n",
"\n", "\n",

@ -213,7 +213,7 @@
" print(\"---RETRIEVE---\")\n", " print(\"---RETRIEVE---\")\n",
" state_dict = state[\"keys\"]\n", " state_dict = state[\"keys\"]\n",
" question = state_dict[\"question\"]\n", " question = state_dict[\"question\"]\n",
" documents = retriever.get_relevant_documents(question)\n", " documents = retriever.invoke(question)\n",
" return {\"keys\": {\"documents\": documents, \"question\": question}}\n", " return {\"keys\": {\"documents\": documents, \"question\": question}}\n",
"\n", "\n",
"\n", "\n",

@ -435,7 +435,7 @@
" display(HTML(image_html))\n", " display(HTML(image_html))\n",
"\n", "\n",
"\n", "\n",
"docs = retriever.get_relevant_documents(\"Woman with children\", k=10)\n", "docs = retriever.invoke(\"Woman with children\", k=10)\n",
"for doc in docs:\n", "for doc in docs:\n",
" if is_base64(doc.page_content):\n", " if is_base64(doc.page_content):\n",
" plt_img_base64(doc.page_content)\n", " plt_img_base64(doc.page_content)\n",

@ -443,7 +443,7 @@
"\n", "\n",
"\n", "\n",
"query = \"Woman with children\"\n", "query = \"Woman with children\"\n",
"docs = retriever.get_relevant_documents(query, k=10)\n", "docs = retriever.invoke(query, k=10)\n",
"\n", "\n",
"for doc in docs:\n", "for doc in docs:\n",
" if is_base64(doc.page_content):\n", " if is_base64(doc.page_content):\n",

@ -168,7 +168,7 @@
"\n", "\n",
"retriever = vector_store.as_retriever(search_type=\"similarity\", search_kwargs={\"k\": 3})\n", "retriever = vector_store.as_retriever(search_type=\"similarity\", search_kwargs={\"k\": 3})\n",
"\n", "\n",
"retrieved_docs = retriever.get_relevant_documents(\"<your question>\")\n", "retrieved_docs = retriever.invoke(\"<your question>\")\n",
"\n", "\n",
"print(retrieved_docs[0].page_content)\n", "print(retrieved_docs[0].page_content)\n",
"\n", "\n",

@ -1227,7 +1227,7 @@
} }
], ],
"source": [ "source": [
"results = retriever.get_relevant_documents(\n", "results = retriever.invoke(\n",
" \"I want to stay somewhere highly rated along the coast. I want a room with a patio and a fireplace.\"\n", " \"I want to stay somewhere highly rated along the coast. I want a room with a patio and a fireplace.\"\n",
")\n", ")\n",
"for res in results:\n", "for res in results:\n",

@ -184,7 +184,7 @@
"\n", "\n",
"query = \"Qual o tempo máximo para realização da prova?\"\n", "query = \"Qual o tempo máximo para realização da prova?\"\n",
"\n", "\n",
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"\n", "\n",
"chain.invoke(\n", "chain.invoke(\n",
" {\"input_documents\": docs, \"query\": query}\n", " {\"input_documents\": docs, \"query\": query}\n",

@ -630,7 +630,7 @@
], ],
"source": [ "source": [
"# Query retriever, should return parents (using MMR since that was set as search_type above)\n", "# Query retriever, should return parents (using MMR since that was set as search_type above)\n",
"retrieved_parent_docs = retriever.get_relevant_documents(\n", "retrieved_parent_docs = retriever.invoke(\n",
" \"what signs does Birch Street allow on their property?\"\n", " \"what signs does Birch Street allow on their property?\"\n",
")\n", ")\n",
"for chunk in retrieved_parent_docs:\n", "for chunk in retrieved_parent_docs:\n",

@ -97,7 +97,7 @@
" # delete the gpt-4 model_name to use the default gpt-3.5 turbo for faster results\n", " # delete the gpt-4 model_name to use the default gpt-3.5 turbo for faster results\n",
" gpt_4 = ChatOpenAI(temperature=0.02, model_name=\"gpt-4\")\n", " gpt_4 = ChatOpenAI(temperature=0.02, model_name=\"gpt-4\")\n",
" # Use the retriever's 'get_relevant_documents' method if needed to filter down longer docs\n", " # Use the retriever's 'get_relevant_documents' method if needed to filter down longer docs\n",
" relevant_nodes = figma_doc_retriever.get_relevant_documents(human_input)\n", " relevant_nodes = figma_doc_retriever.invoke(human_input)\n",
" conversation = [system_message_prompt, human_message_prompt]\n", " conversation = [system_message_prompt, human_message_prompt]\n",
" chat_prompt = ChatPromptTemplate.from_messages(conversation)\n", " chat_prompt = ChatPromptTemplate.from_messages(conversation)\n",
" response = gpt_4(\n", " response = gpt_4(\n",

@ -99,7 +99,7 @@
], ],
"source": [ "source": [
"# Test the retriever\n", "# Test the retriever\n",
"spreedly_doc_retriever.get_relevant_documents(\"CRC\")" "spreedly_doc_retriever.invoke(\"CRC\")"
] ]
}, },
{ {

@ -82,7 +82,7 @@
")\n", ")\n",
"\n", "\n",
"query = \"What is the plan for the economy?\"\n", "query = \"What is the plan for the economy?\"\n",
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"pretty_print_docs(docs)" "pretty_print_docs(docs)"
] ]
}, },
@ -162,9 +162,7 @@
" base_compressor=compressor, base_retriever=retriever\n", " base_compressor=compressor, base_retriever=retriever\n",
")\n", ")\n",
"\n", "\n",
"compressed_docs = compression_retriever.get_relevant_documents(\n", "compressed_docs = compression_retriever.invoke(\"What is the plan for the economy?\")\n",
" \"What is the plan for the economy?\"\n",
")\n",
"pretty_print_docs(compressed_docs)" "pretty_print_docs(compressed_docs)"
] ]
}, },

@ -350,7 +350,7 @@
"retriever = FAISS.from_documents(texts, embedding).as_retriever(search_kwargs={\"k\": 20})\n", "retriever = FAISS.from_documents(texts, embedding).as_retriever(search_kwargs={\"k\": 20})\n",
"\n", "\n",
"query = \"What did the president say about Ketanji Brown Jackson\"\n", "query = \"What did the president say about Ketanji Brown Jackson\"\n",
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"pretty_print_docs(docs)" "pretty_print_docs(docs)"
] ]
}, },
@ -388,7 +388,7 @@
" base_compressor=ov_compressor, base_retriever=retriever\n", " base_compressor=ov_compressor, base_retriever=retriever\n",
")\n", ")\n",
"\n", "\n",
"compressed_docs = compression_retriever.get_relevant_documents(\n", "compressed_docs = compression_retriever.invoke(\n",
" \"What did the president say about Ketanji Jackson Brown\"\n", " \"What did the president say about Ketanji Jackson Brown\"\n",
")\n", ")\n",
"print([doc.metadata[\"id\"] for doc in compressed_docs])" "print([doc.metadata[\"id\"] for doc in compressed_docs])"

@ -320,7 +320,7 @@
").as_retriever(search_kwargs={\"k\": 20})\n", ").as_retriever(search_kwargs={\"k\": 20})\n",
"\n", "\n",
"query = \"What did the president say about Ketanji Brown Jackson\"\n", "query = \"What did the president say about Ketanji Brown Jackson\"\n",
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"pretty_print_docs(docs)" "pretty_print_docs(docs)"
] ]
}, },
@ -382,7 +382,7 @@
" base_compressor=compressor, base_retriever=retriever\n", " base_compressor=compressor, base_retriever=retriever\n",
")\n", ")\n",
"\n", "\n",
"compressed_docs = compression_retriever.get_relevant_documents(\n", "compressed_docs = compression_retriever.invoke(\n",
" \"What did the president say about Ketanji Jackson Brown\"\n", " \"What did the president say about Ketanji Jackson Brown\"\n",
")\n", ")\n",
"pretty_print_docs(compressed_docs)" "pretty_print_docs(compressed_docs)"

@ -623,7 +623,7 @@ docai_wh_retriever = GoogleDocumentAIWarehouseRetriever(
project_number=... project_number=...
) )
query = ... query = ...
documents = docai_wh_retriever.get_relevant_documents( documents = docai_wh_retriever.invoke(
query, user_ldap=... query, user_ldap=...
) )
``` ```

@ -83,7 +83,7 @@ from langchain.retrievers import CohereRagRetriever
from langchain_core.documents import Document from langchain_core.documents import Document
rag = CohereRagRetriever(llm=ChatCohere()) rag = CohereRagRetriever(llm=ChatCohere())
print(rag.get_relevant_documents("What is cohere ai?")) print(rag.invoke("What is cohere ai?"))
``` ```
Usage of the Cohere [RAG Retriever](/docs/integrations/retrievers/cohere) Usage of the Cohere [RAG Retriever](/docs/integrations/retrievers/cohere)

@ -22,5 +22,5 @@ from metal_sdk.metal import Metal
metal = Metal("API_KEY", "CLIENT_ID", "INDEX_ID"); metal = Metal("API_KEY", "CLIENT_ID", "INDEX_ID");
retriever = MetalRetriever(metal, params={"limit": 2}) retriever = MetalRetriever(metal, params={"limit": 2})
docs = retriever.get_relevant_documents("search term") docs = retriever.invoke("search term")
``` ```

@ -199,7 +199,7 @@
" base_compressor=RAG.as_langchain_document_compressor(), base_retriever=retriever\n", " base_compressor=RAG.as_langchain_document_compressor(), base_retriever=retriever\n",
")\n", ")\n",
"\n", "\n",
"compressed_docs = compression_retriever.get_relevant_documents(\n", "compressed_docs = compression_retriever.invoke(\n",
" \"What animation studio did Miyazaki found\"\n", " \"What animation studio did Miyazaki found\"\n",
")" ")"
] ]

@ -154,9 +154,7 @@
"openai_api_key = os.environ[\"OPENAI_API_KEY\"]\n", "openai_api_key = os.environ[\"OPENAI_API_KEY\"]\n",
"llm = OpenAI(openai_api_key=openai_api_key, temperature=0)\n", "llm = OpenAI(openai_api_key=openai_api_key, temperature=0)\n",
"retriever = vectara.as_retriever()\n", "retriever = vectara.as_retriever()\n",
"d = retriever.get_relevant_documents(\n", "d = retriever.invoke(\"What did the president say about Ketanji Brown Jackson\", k=2)\n",
" \"What did the president say about Ketanji Brown Jackson\", k=2\n",
")\n",
"print(d)" "print(d)"
] ]
}, },

@ -69,7 +69,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"retriever.get_relevant_documents(\"what is langchain\")" "retriever.invoke(\"what is langchain\")"
] ]
} }
], ],

@ -83,7 +83,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"query = \"Can AI-driven music therapy contribute to the rehabilitation of patients with disorders of consciousness?\"\n", "query = \"Can AI-driven music therapy contribute to the rehabilitation of patients with disorders of consciousness?\"\n",
"documents = retriever.get_relevant_documents(query=query)" "documents = retriever.invoke(query)"
] ]
}, },
{ {
@ -108,7 +108,7 @@
"]\n", "]\n",
"\n", "\n",
"# Retrieve documents with filters and size params\n", "# Retrieve documents with filters and size params\n",
"documents = retriever.get_relevant_documents(query=query, size=5, filters=filters)" "documents = retriever.invoke(query, size=5, filters=filters)"
] ]
} }
], ],

@ -97,7 +97,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"docs = retriever.get_relevant_documents(query=\"1605.08386\")" "docs = retriever.invoke(\"1605.08386\")"
] ]
}, },
{ {
@ -162,7 +162,7 @@
}, },
"outputs": [ "outputs": [
{ {
"name": "stdin", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
" ········\n" " ········\n"

@ -117,7 +117,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"retriever.get_relevant_documents(\"what is langchain?\")" "retriever.invoke(\"what is langchain?\")"
] ]
}, },
{ {
@ -263,7 +263,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"What is Azure OpenAI?\")" "retriever.invoke(\"What is Azure OpenAI?\")"
] ]
} }
], ],

@ -58,7 +58,7 @@
"source": [ "source": [
"query = \"What did the president say about Ketanji Brown?\"\n", "query = \"What did the president say about Ketanji Brown?\"\n",
"\n", "\n",
"retriever.get_relevant_documents(query=query)" "retriever.invoke(query)"
] ]
}, },
{ {

@ -103,7 +103,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"result = retriever.get_relevant_documents(\"foo\")" "result = retriever.invoke(\"foo\")"
] ]
}, },
{ {

@ -64,7 +64,7 @@
"source": [ "source": [
"breeb_key = \"Parivoyage\"\n", "breeb_key = \"Parivoyage\"\n",
"retriever = BreebsRetriever(breeb_key)\n", "retriever = BreebsRetriever(breeb_key)\n",
"documents = retriever.get_relevant_documents(\n", "documents = retriever.invoke(\n",
" \"What are some unique, lesser-known spots to explore in Paris?\"\n", " \"What are some unique, lesser-known spots to explore in Paris?\"\n",
")\n", ")\n",
"print(documents)" "print(documents)"

@ -83,7 +83,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"What is Daftpage?\")" "retriever.invoke(\"What is Daftpage?\")"
] ]
} }
], ],

@ -150,7 +150,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"alice's phone number\")" "retriever.invoke(\"alice's phone number\")"
] ]
}, },
{ {

@ -314,7 +314,7 @@
")\n", ")\n",
"\n", "\n",
"query = \"What did the president say about Ketanji Brown Jackson\"\n", "query = \"What did the president say about Ketanji Brown Jackson\"\n",
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"pretty_print_docs(docs)" "pretty_print_docs(docs)"
] ]
}, },
@ -344,7 +344,7 @@
" base_compressor=compressor, base_retriever=retriever\n", " base_compressor=compressor, base_retriever=retriever\n",
")\n", ")\n",
"\n", "\n",
"compressed_docs = compression_retriever.get_relevant_documents(\n", "compressed_docs = compression_retriever.invoke(\n",
" \"What did the president say about Ketanji Jackson Brown\"\n", " \"What did the president say about Ketanji Jackson Brown\"\n",
")\n", ")\n",
"pretty_print_docs(compressed_docs)" "pretty_print_docs(compressed_docs)"

@ -118,7 +118,7 @@
} }
], ],
"source": [ "source": [
"_pretty_print(rag.get_relevant_documents(\"What is cohere ai?\"))" "_pretty_print(rag.invoke(\"What is cohere ai?\"))"
] ]
}, },
{ {
@ -172,7 +172,7 @@
} }
], ],
"source": [ "source": [
"_pretty_print(await rag.aget_relevant_documents(\"What is cohere ai?\")) # async version" "_pretty_print(await rag.ainvoke(\"What is cohere ai?\")) # async version"
] ]
}, },
{ {
@ -198,7 +198,7 @@
} }
], ],
"source": [ "source": [
"docs = rag.get_relevant_documents(\n", "docs = rag.invoke(\n",
" \"Does langchain support cohere RAG?\",\n", " \"Does langchain support cohere RAG?\",\n",
" source_documents=[\n", " source_documents=[\n",
" Document(page_content=\"Langchain supports cohere RAG!\"),\n", " Document(page_content=\"Langchain supports cohere RAG!\"),\n",

@ -143,7 +143,7 @@
")\n", ")\n",
"\n", "\n",
"# find the relevant document\n", "# find the relevant document\n",
"doc = retriever.get_relevant_documents(\"some query\")\n", "doc = retriever.invoke(\"some query\")\n",
"print(doc)" "print(doc)"
] ]
}, },
@ -216,7 +216,7 @@
")\n", ")\n",
"\n", "\n",
"# find the relevant document\n", "# find the relevant document\n",
"doc = retriever.get_relevant_documents(\"some query\")\n", "doc = retriever.invoke(\"some query\")\n",
"print(doc)" "print(doc)"
] ]
}, },
@ -313,7 +313,7 @@
")\n", ")\n",
"\n", "\n",
"# find the relevant document\n", "# find the relevant document\n",
"doc = retriever.get_relevant_documents(\"some query\")\n", "doc = retriever.invoke(\"some query\")\n",
"print(doc)" "print(doc)"
] ]
}, },
@ -388,7 +388,7 @@
")\n", ")\n",
"\n", "\n",
"# find the relevant document\n", "# find the relevant document\n",
"doc = retriever.get_relevant_documents(\"some query\")\n", "doc = retriever.invoke(\"some query\")\n",
"print(doc)" "print(doc)"
] ]
}, },
@ -481,7 +481,7 @@
")\n", ")\n",
"\n", "\n",
"# find the relevant document\n", "# find the relevant document\n",
"doc = retriever.get_relevant_documents(\"some query\")\n", "doc = retriever.invoke(\"some query\")\n",
"print(doc)" "print(doc)"
] ]
}, },
@ -658,7 +658,7 @@
")\n", ")\n",
"\n", "\n",
"# find the relevant document\n", "# find the relevant document\n",
"doc = retriever.get_relevant_documents(\"movie about dreams\")\n", "doc = retriever.invoke(\"movie about dreams\")\n",
"print(doc)" "print(doc)"
] ]
}, },
@ -700,7 +700,7 @@
")\n", ")\n",
"\n", "\n",
"# find relevant documents\n", "# find relevant documents\n",
"docs = retriever.get_relevant_documents(\"space travel\")\n", "docs = retriever.invoke(\"space travel\")\n",
"print(docs)" "print(docs)"
] ]
}, },
@ -743,7 +743,7 @@
")\n", ")\n",
"\n", "\n",
"# find relevant documents\n", "# find relevant documents\n",
"docs = retriever.get_relevant_documents(\"action movies\")\n", "docs = retriever.invoke(\"action movies\")\n",
"print(docs)" "print(docs)"
] ]
}, },

@ -158,7 +158,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"query = \"Find information about Dria.\"\n", "query = \"Find information about Dria.\"\n",
"result = retriever.get_relevant_documents(query)\n", "result = retriever.invoke(query)\n",
"for doc in result:\n", "for doc in result:\n",
" print(doc)" " print(doc)"
] ]

@ -130,7 +130,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"result = retriever.get_relevant_documents(\"foo\")" "result = retriever.invoke(\"foo\")"
] ]
}, },
{ {

@ -263,7 +263,7 @@
" url=es_url,\n", " url=es_url,\n",
")\n", ")\n",
"\n", "\n",
"vector_retriever.get_relevant_documents(\"foo\")" "vector_retriever.invoke(\"foo\")"
] ]
}, },
{ {
@ -313,7 +313,7 @@
" url=es_url,\n", " url=es_url,\n",
")\n", ")\n",
"\n", "\n",
"bm25_retriever.get_relevant_documents(\"foo\")" "bm25_retriever.invoke(\"foo\")"
] ]
}, },
{ {
@ -371,7 +371,7 @@
" url=es_url,\n", " url=es_url,\n",
")\n", ")\n",
"\n", "\n",
"hybrid_retriever.get_relevant_documents(\"foo\")" "hybrid_retriever.invoke(\"foo\")"
] ]
}, },
{ {
@ -424,7 +424,7 @@
" url=es_url,\n", " url=es_url,\n",
")\n", ")\n",
"\n", "\n",
"fuzzy_retriever.get_relevant_documents(\"fox\") # note the character tolernace" "fuzzy_retriever.invoke(\"fox\") # note the character tolernace"
] ]
}, },
{ {
@ -483,7 +483,7 @@
" url=es_url,\n", " url=es_url,\n",
")\n", ")\n",
"\n", "\n",
"filtering_retriever.get_relevant_documents(\"foo\")" "filtering_retriever.invoke(\"foo\")"
] ]
}, },
{ {
@ -541,7 +541,7 @@
" url=es_url,\n", " url=es_url,\n",
")\n", ")\n",
"\n", "\n",
"custom_mapped_retriever.get_relevant_documents(\"foo\")" "custom_mapped_retriever.invoke(\"foo\")"
] ]
} }
], ],

@ -194,9 +194,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"result = retriever.get_relevant_documents(\n", "result = retriever.invoke(\"How many companies does Elon Musk run and name those?\")"
" \"How many companies does Elon Musk run and name those?\"\n",
")"
] ]
}, },
{ {

@ -328,7 +328,7 @@
"retriever = FAISS.from_documents(texts, embedding).as_retriever(search_kwargs={\"k\": 20})\n", "retriever = FAISS.from_documents(texts, embedding).as_retriever(search_kwargs={\"k\": 20})\n",
"\n", "\n",
"query = \"What did the president say about Ketanji Brown Jackson\"\n", "query = \"What did the president say about Ketanji Brown Jackson\"\n",
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"pretty_print_docs(docs)" "pretty_print_docs(docs)"
] ]
}, },
@ -375,7 +375,7 @@
" base_compressor=compressor, base_retriever=retriever\n", " base_compressor=compressor, base_retriever=retriever\n",
")\n", ")\n",
"\n", "\n",
"compressed_docs = compression_retriever.get_relevant_documents(\n", "compressed_docs = compression_retriever.invoke(\n",
" \"What did the president say about Ketanji Jackson Brown\"\n", " \"What did the president say about Ketanji Jackson Brown\"\n",
")\n", ")\n",
"print([doc.metadata[\"id\"] for doc in compressed_docs])" "print([doc.metadata[\"id\"] for doc in compressed_docs])"

@ -131,7 +131,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"vecstore_retriever.get_relevant_documents(\"How does the multi vector retriever work\")" "vecstore_retriever.invoke(\"How does the multi vector retriever work\")"
] ]
}, },
{ {
@ -176,7 +176,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"parent_retriever.get_relevant_documents(\"How does the multi vector retriever work\")" "parent_retriever.invoke(\"How does the multi vector retriever work\")"
] ]
}, },
{ {

@ -114,7 +114,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"retriever.get_relevant_documents(\"machine learning\")" "retriever.invoke(\"machine learning\")"
] ]
}, },
{ {
@ -149,7 +149,7 @@
" template=\"gdrive-query\", # Search everywhere\n", " template=\"gdrive-query\", # Search everywhere\n",
" num_results=2, # But take only 2 documents\n", " num_results=2, # But take only 2 documents\n",
")\n", ")\n",
"for doc in retriever.get_relevant_documents(\"machine learning\"):\n", "for doc in retriever.invoke(\"machine learning\"):\n",
" print(\"---\")\n", " print(\"---\")\n",
" print(doc.page_content.strip()[:60] + \"...\")" " print(doc.page_content.strip()[:60] + \"...\")"
] ]
@ -187,7 +187,7 @@
" includeItemsFromAllDrives=False,\n", " includeItemsFromAllDrives=False,\n",
" supportsAllDrives=False,\n", " supportsAllDrives=False,\n",
")\n", ")\n",
"for doc in retriever.get_relevant_documents(\"machine learning\"):\n", "for doc in retriever.invoke(\"machine learning\"):\n",
" print(f\"{doc.metadata['name']}:\")\n", " print(f\"{doc.metadata['name']}:\")\n",
" print(\"---\")\n", " print(\"---\")\n",
" print(doc.page_content.strip()[:60] + \"...\")" " print(doc.page_content.strip()[:60] + \"...\")"
@ -222,7 +222,7 @@
" includeItemsFromAllDrives=False,\n", " includeItemsFromAllDrives=False,\n",
" supportsAllDrives=False,\n", " supportsAllDrives=False,\n",
")\n", ")\n",
"retriever.get_relevant_documents(\"machine learning\")" "retriever.invoke(\"machine learning\")"
] ]
} }
], ],

@ -198,7 +198,7 @@
"source": [ "source": [
"query = \"What are Alphabet's Other Bets?\"\n", "query = \"What are Alphabet's Other Bets?\"\n",
"\n", "\n",
"result = retriever.get_relevant_documents(query)\n", "result = retriever.invoke(query)\n",
"for doc in result:\n", "for doc in result:\n",
" print(doc)" " print(doc)"
] ]
@ -225,7 +225,7 @@
" get_extractive_answers=True,\n", " get_extractive_answers=True,\n",
")\n", ")\n",
"\n", "\n",
"result = retriever.get_relevant_documents(query)\n", "result = retriever.invoke(query)\n",
"for doc in result:\n", "for doc in result:\n",
" print(doc)" " print(doc)"
] ]
@ -251,7 +251,7 @@
" engine_data_type=1,\n", " engine_data_type=1,\n",
")\n", ")\n",
"\n", "\n",
"result = retriever.get_relevant_documents(query)\n", "result = retriever.invoke(query)\n",
"for doc in result:\n", "for doc in result:\n",
" print(doc)" " print(doc)"
] ]
@ -279,7 +279,7 @@
" engine_data_type=2,\n", " engine_data_type=2,\n",
")\n", ")\n",
"\n", "\n",
"result = retriever.get_relevant_documents(query)\n", "result = retriever.invoke(query)\n",
"for doc in result:\n", "for doc in result:\n",
" print(doc)" " print(doc)"
] ]
@ -305,7 +305,7 @@
" engine_data_type=3,\n", " engine_data_type=3,\n",
")\n", ")\n",
"\n", "\n",
"result = retriever.get_relevant_documents(query)\n", "result = retriever.invoke(query)\n",
"for doc in result:\n", "for doc in result:\n",
" print(doc)" " print(doc)"
] ]
@ -329,7 +329,7 @@
" project_id=PROJECT_ID, location_id=LOCATION_ID, data_store_id=DATA_STORE_ID\n", " project_id=PROJECT_ID, location_id=LOCATION_ID, data_store_id=DATA_STORE_ID\n",
")\n", ")\n",
"\n", "\n",
"result = retriever.get_relevant_documents(query)\n", "result = retriever.invoke(query)\n",
"for doc in result:\n", "for doc in result:\n",
" print(doc)" " print(doc)"
] ]

@ -92,7 +92,7 @@
"retriever = KayAiRetriever.create(\n", "retriever = KayAiRetriever.create(\n",
" dataset_id=\"company\", data_types=[\"10-K\", \"10-Q\", \"PressRelease\"], num_contexts=3\n", " dataset_id=\"company\", data_types=[\"10-K\", \"10-Q\", \"PressRelease\"], num_contexts=3\n",
")\n", ")\n",
"docs = retriever.get_relevant_documents(\n", "docs = retriever.invoke(\n",
" \"What were the biggest strategy changes and partnerships made by Roku in 2023??\"\n", " \"What were the biggest strategy changes and partnerships made by Roku in 2023??\"\n",
")" ")"
] ]

@ -62,7 +62,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"result = retriever.get_relevant_documents(\"foo\")" "result = retriever.invoke(\"foo\")"
] ]
}, },
{ {

@ -296,7 +296,7 @@
"retriever = FAISS.from_documents(texts, embedding).as_retriever(search_kwargs={\"k\": 20})\n", "retriever = FAISS.from_documents(texts, embedding).as_retriever(search_kwargs={\"k\": 20})\n",
"\n", "\n",
"query = \"What did the president say about Ketanji Brown Jackson\"\n", "query = \"What did the president say about Ketanji Brown Jackson\"\n",
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"pretty_print_docs(docs)" "pretty_print_docs(docs)"
] ]
}, },
@ -350,7 +350,7 @@
" base_compressor=compressor, base_retriever=retriever\n", " base_compressor=compressor, base_retriever=retriever\n",
")\n", ")\n",
"\n", "\n",
"compressed_docs = compression_retriever.get_relevant_documents(\n", "compressed_docs = compression_retriever.invoke(\n",
" \"What did the president say about Ketanji Jackson Brown\"\n", " \"What did the president say about Ketanji Jackson Brown\"\n",
")\n", ")\n",
"pretty_print_docs(compressed_docs)" "pretty_print_docs(compressed_docs)"

@ -123,7 +123,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"foo1\")" "retriever.invoke(\"foo1\")"
] ]
}, },
{ {

@ -109,7 +109,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(query=\"LangChain\", doc_content_chars_max=100)" "retriever.invoke(\"LangChain\", doc_content_chars_max=100)"
] ]
}, },
{ {

@ -295,7 +295,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"result = retriever.get_relevant_documents(\"foo\")" "result = retriever.invoke(\"foo\")"
] ]
}, },
{ {

@ -53,7 +53,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"chatgpt\")" "retriever.invoke(\"chatgpt\")"
] ]
}, },
{ {

@ -227,7 +227,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"Life and ethical dilemmas of AI\",\n", " \"Life and ethical dilemmas of AI\",\n",
")" ")"
] ]

@ -100,7 +100,7 @@
} }
], ],
"source": [ "source": [
"docs = retriever_from_llm.get_relevant_documents(\n", "docs = retriever_from_llm.invoke(\n",
" \"Hi I'm Lance. What are the approaches to Task Decomposition?\"\n", " \"Hi I'm Lance. What are the approaches to Task Decomposition?\"\n",
")" ")"
] ]
@ -120,7 +120,7 @@
} }
], ],
"source": [ "source": [
"docs = retriever_from_llm.get_relevant_documents(\n", "docs = retriever_from_llm.invoke(\n",
" \"I live in San Francisco. What are the Types of Memory?\"\n", " \"I live in San Francisco. What are the Types of Memory?\"\n",
")" ")"
] ]
@ -182,7 +182,7 @@
} }
], ],
"source": [ "source": [
"docs = retriever_from_llm_chain.get_relevant_documents(\n", "docs = retriever_from_llm_chain.invoke(\n",
" \"Hi I'm Lance. What is Maximum Inner Product Search?\"\n", " \"Hi I'm Lance. What is Maximum Inner Product Search?\"\n",
")" ")"
] ]

@ -270,7 +270,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -300,7 +300,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")\n", "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")\n",
"\n", "\n",
"# in case if this example errored out, consider installing libdeeplake manually: `pip install libdeeplake`, and then restart notebook." "# in case if this example errored out, consider installing libdeeplake manually: `pip install libdeeplake`, and then restart notebook."
] ]
@ -331,7 +331,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -360,9 +360,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -391,7 +389,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -457,7 +455,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -192,7 +192,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs?\")" "retriever.invoke(\"What are some movies about dinosaurs?\")"
] ]
}, },
{ {
@ -202,7 +202,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a filter\n", "# This example specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -212,7 +212,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a query and a filter\n", "# This example only specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -222,9 +222,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5), science fiction movie ?\")"
" \"What's a highly rated (above 8.5), science fiction movie ?\"\n",
")"
] ]
}, },
{ {
@ -234,7 +232,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie about toys after 1990 but before 2005, and is animated\"\n", " \"What's a movie about toys after 1990 but before 2005, and is animated\"\n",
")" ")"
] ]
@ -273,7 +271,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are two movies about dinosaurs?\")" "retriever.invoke(\"What are two movies about dinosaurs?\")"
] ]
}, },
{ {

@ -232,7 +232,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -262,7 +262,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -291,7 +291,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -320,9 +320,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -351,7 +349,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -418,7 +416,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
}, },
{ {

@ -269,7 +269,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -308,7 +308,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -346,7 +346,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -384,9 +384,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -468,7 +466,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
}, },
{ {

@ -352,7 +352,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -384,7 +384,7 @@
], ],
"source": [ "source": [
"# This example specifies a filter\n", "# This example specifies a filter\n",
"retriever.get_relevant_documents(\"What are some highly rated movies (above 9)?\")" "retriever.invoke(\"What are some highly rated movies (above 9)?\")"
] ]
}, },
{ {
@ -416,7 +416,7 @@
], ],
"source": [ "source": [
"# This example specifies both a relevant query and a filter\n", "# This example specifies both a relevant query and a filter\n",
"retriever.get_relevant_documents(\"What are the thriller movies that are highly rated?\")" "retriever.invoke(\"What are the thriller movies that are highly rated?\")"
] ]
}, },
{ {
@ -438,7 +438,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about dinosaurs, \\\n", " \"What's a movie after 1990 but before 2005 that's all about dinosaurs, \\\n",
" and preferably has a lot of action\"\n", " and preferably has a lot of action\"\n",
")" ")"
@ -520,7 +520,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"retriever.get_relevant_documents(\"What are two movies about dinosaurs?\")" "retriever.invoke(\"What are two movies about dinosaurs?\")"
] ]
} }
], ],

@ -265,7 +265,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -296,7 +296,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -326,7 +326,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -357,9 +357,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -389,7 +387,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -450,7 +448,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are two movies about dinosaurs\")" "retriever.invoke(\"What are two movies about dinosaurs\")"
] ]
} }
], ],

@ -197,7 +197,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -219,7 +219,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -275,7 +275,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
}, },
{ {
@ -305,7 +305,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"what animated or comedy movies have been released in the last 30 years about animated toys?\"\n", " \"what animated or comedy movies have been released in the last 30 years about animated toys?\"\n",
")" ")"
] ]

@ -190,7 +190,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -219,7 +219,7 @@
], ],
"source": [ "source": [
"# This example specifies a filter\n", "# This example specifies a filter\n",
"retriever.get_relevant_documents(\"What are some highly rated movies (above 9)?\")" "retriever.invoke(\"What are some highly rated movies (above 9)?\")"
] ]
}, },
{ {
@ -248,9 +248,7 @@
], ],
"source": [ "source": [
"# This example only specifies a query and a filter\n", "# This example only specifies a query and a filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"I want to watch a movie about toys rated higher than 9\")"
" \"I want to watch a movie about toys rated higher than 9\"\n",
")"
] ]
}, },
{ {
@ -278,9 +276,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above or equal 9) thriller film?\")"
" \"What's a highly rated (above or equal 9) thriller film?\"\n",
")"
] ]
}, },
{ {
@ -308,7 +304,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about dinosaurs, \\\n", " \"What's a movie after 1990 but before 2005 that's all about dinosaurs, \\\n",
" and preferably has a lot of action\"\n", " and preferably has a lot of action\"\n",
")" ")"
@ -367,7 +363,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are two movies about dinosaurs?\")" "retriever.invoke(\"What are two movies about dinosaurs?\")"
] ]
} }
], ],

@ -209,7 +209,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -219,7 +219,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a filter\n", "# This example specifies a filter\n",
"retriever.get_relevant_documents(\"What are some highly rated movies (above 9)?\")" "retriever.invoke(\"What are some highly rated movies (above 9)?\")"
] ]
}, },
{ {
@ -229,9 +229,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a query and a filter\n", "# This example only specifies a query and a filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"I want to watch a movie about toys rated higher than 9\")"
" \"I want to watch a movie about toys rated higher than 9\"\n",
")"
] ]
}, },
{ {
@ -241,9 +239,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above or equal 9) thriller film?\")"
" \"What's a highly rated (above or equal 9) thriller film?\"\n",
")"
] ]
}, },
{ {
@ -253,7 +249,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about dinosaurs, \\\n", " \"What's a movie after 1990 but before 2005 that's all about dinosaurs, \\\n",
" and preferably has a lot of action\"\n", " and preferably has a lot of action\"\n",
")" ")"
@ -293,7 +289,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are two movies about dinosaurs?\")" "retriever.invoke(\"What are two movies about dinosaurs?\")"
] ]
} }
], ],

@ -216,7 +216,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -227,7 +227,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -238,7 +238,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -249,9 +249,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -262,7 +260,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -285,7 +283,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# You can use length(genres) to do anything you want\n", "# You can use length(genres) to do anything you want\n",
"retriever.get_relevant_documents(\"What's a movie that have more than 1 genres?\")" "retriever.invoke(\"What's a movie that have more than 1 genres?\")"
] ]
}, },
{ {
@ -296,7 +294,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# Fine-grained datetime? You got it already.\n", "# Fine-grained datetime? You got it already.\n",
"retriever.get_relevant_documents(\"What's a movie that release after feb 1995?\")" "retriever.invoke(\"What's a movie that release after feb 1995?\")"
] ]
}, },
{ {
@ -307,7 +305,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# Don't know what your exact filter should be? Use string pattern match!\n", "# Don't know what your exact filter should be? Use string pattern match!\n",
"retriever.get_relevant_documents(\"What's a movie whose name is like Andrei?\")" "retriever.invoke(\"What's a movie whose name is like Andrei?\")"
] ]
}, },
{ {
@ -318,9 +316,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# Contain works for lists: so you can match a list with contain comparator!\n", "# Contain works for lists: so you can match a list with contain comparator!\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a movie who has genres science fiction and adventure?\")"
" \"What's a movie who has genres science fiction and adventure?\"\n",
")"
] ]
}, },
{ {
@ -364,7 +360,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -203,7 +203,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -233,7 +233,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -262,7 +262,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -291,9 +291,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -356,7 +354,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
}, },
{ {
@ -393,7 +391,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"what animated or comedy movies have been released in the last 30 years about animated toys?\"\n", " \"what animated or comedy movies have been released in the last 30 years about animated toys?\"\n",
")" ")"
] ]

@ -188,7 +188,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -199,7 +199,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -210,7 +210,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -221,9 +221,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -234,7 +232,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -280,7 +278,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -214,7 +214,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -244,7 +244,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -273,7 +273,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -302,9 +302,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -333,7 +331,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -375,7 +373,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are two movies about dinosaurs\")" "retriever.invoke(\"What are two movies about dinosaurs\")"
] ]
} }
], ],

@ -214,7 +214,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -244,7 +244,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -273,7 +273,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -302,9 +302,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -333,7 +331,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -399,7 +397,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -279,7 +279,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -310,7 +310,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.4\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.4\")"
] ]
}, },
{ {
@ -339,7 +339,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -369,9 +369,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -400,7 +398,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -465,7 +463,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -374,7 +374,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -404,7 +404,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -433,7 +433,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women?\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women?\")"
] ]
}, },
{ {
@ -462,9 +462,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -493,7 +491,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before (or on) 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before (or on) 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -558,7 +556,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -297,7 +297,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"movies about a superhero\")" "retriever.invoke(\"movies about a superhero\")"
] ]
}, },
{ {
@ -323,7 +323,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"movies that were released after 2010\")" "retriever.invoke(\"movies that were released after 2010\")"
] ]
}, },
{ {
@ -349,9 +349,7 @@
], ],
"source": [ "source": [
"# This example specifies both a relevant query and a filter\n", "# This example specifies both a relevant query and a filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"movies about a superhero which were released after 2010\")"
" \"movies about a superhero which were released after 2010\"\n",
")"
] ]
}, },
{ {
@ -413,7 +411,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"what are two movies about a superhero\")" "retriever.invoke(\"what are two movies about a superhero\")"
] ]
} }
], ],

@ -334,7 +334,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -366,7 +366,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -396,7 +396,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -426,9 +426,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -457,7 +455,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -523,7 +521,7 @@
], ],
"source": [ "source": [
"# This example specifies a query with a LIMIT value\n", "# This example specifies a query with a LIMIT value\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -225,7 +225,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -248,7 +248,7 @@
], ],
"source": [ "source": [
"# This example only specifies a filter\n", "# This example only specifies a filter\n",
"retriever.get_relevant_documents(\"I want to watch a movie rated higher than 8.5\")" "retriever.invoke(\"I want to watch a movie rated higher than 8.5\")"
] ]
}, },
{ {
@ -270,7 +270,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -292,9 +292,7 @@
], ],
"source": [ "source": [
"# This example specifies a composite filter\n", "# This example specifies a composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What's a highly rated (above 8.5) science fiction film?\")"
" \"What's a highly rated (above 8.5) science fiction film?\"\n",
")"
] ]
}, },
{ {
@ -316,7 +314,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and composite filter\n", "# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n", " \"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\"\n",
")" ")"
] ]
@ -374,7 +372,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -184,7 +184,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are some movies about dinosaurs\")" "retriever.invoke(\"What are some movies about dinosaurs\")"
] ]
}, },
{ {
@ -213,7 +213,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a filter\n", "# This example specifies a query and a filter\n",
"retriever.get_relevant_documents(\"Has Greta Gerwig directed any movies about women\")" "retriever.invoke(\"Has Greta Gerwig directed any movies about women\")"
] ]
}, },
{ {
@ -276,7 +276,7 @@
], ],
"source": [ "source": [
"# This example only specifies a relevant query\n", "# This example only specifies a relevant query\n",
"retriever.get_relevant_documents(\"what are two movies about dinosaurs\")" "retriever.invoke(\"what are two movies about dinosaurs\")"
] ]
} }
], ],

@ -91,9 +91,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"result = retriever.get_relevant_documents(\n", "result = retriever.invoke(\"What did the president say about Ketanji Brown Jackson\")\n",
" \"What did the president say about Ketanji Brown Jackson\"\n",
")\n",
"print(docs[0].page_content)" "print(docs[0].page_content)"
] ]
} }

@ -125,7 +125,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"result = retriever.get_relevant_documents(\"foo\")" "result = retriever.invoke(\"foo\")"
] ]
}, },
{ {

@ -105,7 +105,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"result = retriever.get_relevant_documents(\"foo\")" "result = retriever.invoke(\"foo\")"
] ]
}, },
{ {
@ -185,7 +185,7 @@
} }
], ],
"source": [ "source": [
"retriever_copy.get_relevant_documents(\"foo\")" "retriever_copy.invoke(\"foo\")"
] ]
}, },
{ {

@ -95,7 +95,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# This returns a list of LangChain Document objects\n", "# This returns a list of LangChain Document objects\n",
"documents = retriever.get_relevant_documents(\"query\", top_k=10)" "documents = retriever.invoke(\"query\", top_k=10)"
] ]
}, },
{ {

@ -110,7 +110,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"retriever.get_relevant_documents(\"what is vespa?\")" "retriever.invoke(\"what is vespa?\")"
] ]
} }
], ],

@ -202,7 +202,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"the ethical implications of AI\")" "retriever.invoke(\"the ethical implications of AI\")"
] ]
}, },
{ {
@ -233,7 +233,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"AI integration in society\",\n", " \"AI integration in society\",\n",
" where_filter={\n", " where_filter={\n",
" \"path\": [\"author\"],\n", " \"path\": [\"author\"],\n",
@ -272,7 +272,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\n", "retriever.invoke(\n",
" \"AI integration in society\",\n", " \"AI integration in society\",\n",
" score=True,\n", " score=True,\n",
")" ")"

@ -98,7 +98,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"docs = retriever.get_relevant_documents(query=\"HUNTER X HUNTER\")" "docs = retriever.invoke(\"HUNTER X HUNTER\")"
] ]
}, },
{ {

@ -314,7 +314,7 @@
" api_key=zep_api_key,\n", " api_key=zep_api_key,\n",
")\n", ")\n",
"\n", "\n",
"await zep_retriever.aget_relevant_documents(\"Who wrote Parable of the Sower?\")" "await zep_retriever.ainvoke(\"Who wrote Parable of the Sower?\")"
] ]
}, },
{ {
@ -355,7 +355,7 @@
} }
], ],
"source": [ "source": [
"zep_retriever.get_relevant_documents(\"Who wrote Parable of the Sower?\")" "zep_retriever.invoke(\"Who wrote Parable of the Sower?\")"
] ]
}, },
{ {
@ -407,7 +407,7 @@
" mmr_lambda=0.5,\n", " mmr_lambda=0.5,\n",
")\n", ")\n",
"\n", "\n",
"await zep_retriever.aget_relevant_documents(\"Who wrote Parable of the Sower?\")" "await zep_retriever.ainvoke(\"Who wrote Parable of the Sower?\")"
] ]
}, },
{ {
@ -445,9 +445,7 @@
"source": [ "source": [
"filter = {\"where\": {\"jsonpath\": '$[*] ? (@.Label == \"WORK_OF_ART\")'}}\n", "filter = {\"where\": {\"jsonpath\": '$[*] ? (@.Label == \"WORK_OF_ART\")'}}\n",
"\n", "\n",
"await zep_retriever.aget_relevant_documents(\n", "await zep_retriever.ainvoke(\"Who wrote Parable of the Sower?\", metadata=filter)"
" \"Who wrote Parable of the Sower?\", metadata=filter\n",
")"
] ]
}, },
{ {
@ -491,7 +489,7 @@
" mmr_lambda=0.5,\n", " mmr_lambda=0.5,\n",
")\n", ")\n",
"\n", "\n",
"await zep_retriever.aget_relevant_documents(\"Who wrote Parable of the Sower?\")" "await zep_retriever.ainvoke(\"Who wrote Parable of the Sower?\")"
] ]
}, },
{ {

@ -187,7 +187,7 @@
" embedding=UpstageEmbeddings(),\n", " embedding=UpstageEmbeddings(),\n",
")\n", ")\n",
"retriever = vectorstore.as_retriever()\n", "retriever = vectorstore.as_retriever()\n",
"docs = retriever.get_relevant_documents(\"Where did Harrison work?\")\n", "docs = retriever.invoke(\"Where did Harrison work?\")\n",
"print(docs)" "print(docs)"
] ]
} }

@ -196,7 +196,7 @@
"retriever = KNNRetriever.from_texts(documents, embeddings)\n", "retriever = KNNRetriever.from_texts(documents, embeddings)\n",
"\n", "\n",
"# retrieve the most relevant documents\n", "# retrieve the most relevant documents\n",
"result = retriever.get_relevant_documents(query)\n", "result = retriever.invoke(query)\n",
"top1_retrieved_doc = result[0].page_content # return the top1 retrieved result\n", "top1_retrieved_doc = result[0].page_content # return the top1 retrieved result\n",
"\n", "\n",
"print(top1_retrieved_doc)" "print(top1_retrieved_doc)"

@ -510,7 +510,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(query)[0]" "retriever.invoke(query)[0]"
] ]
}, },
{ {

@ -197,7 +197,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"retriever = docsearch.as_retriever(search_type=\"mmr\")\n", "retriever = docsearch.as_retriever(search_type=\"mmr\")\n",
"matched_docs = retriever.get_relevant_documents(query)\n", "matched_docs = retriever.invoke(query)\n",
"for i, d in enumerate(matched_docs):\n", "for i, d in enumerate(matched_docs):\n",
" print(f\"\\n## Document {i}\\n\")\n", " print(f\"\\n## Document {i}\\n\")\n",
" print(d.page_content)" " print(d.page_content)"

@ -487,7 +487,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# perform simple similarity search on retriever\n", "# perform simple similarity search on retriever\n",
"retriever.get_relevant_documents(\"What are my options in breathable fabric?\")" "retriever.invoke(\"What are my options in breathable fabric?\")"
] ]
}, },
{ {
@ -503,7 +503,7 @@
"retriever.search_kwargs = {\"filter\": filters}\n", "retriever.search_kwargs = {\"filter\": filters}\n",
"\n", "\n",
"# perform similarity search with filters on retriever\n", "# perform similarity search with filters on retriever\n",
"retriever.get_relevant_documents(\"What are my options in breathable fabric?\")" "retriever.invoke(\"What are my options in breathable fabric?\")"
] ]
}, },
{ {
@ -520,7 +520,7 @@
"\n", "\n",
"retriever.search_kwargs = {\"filter\": filters, \"numeric_filter\": numeric_filters}\n", "retriever.search_kwargs = {\"filter\": filters, \"numeric_filter\": numeric_filters}\n",
"\n", "\n",
"retriever.get_relevant_documents(\"What are my options in breathable fabric?\")" "retriever.invoke(\"What are my options in breathable fabric?\")"
] ]
}, },
{ {

@ -291,9 +291,9 @@
], ],
"source": [ "source": [
"# This will only get documents for Ankush\n", "# This will only get documents for Ankush\n",
"vectorstore.as_retriever(\n", "vectorstore.as_retriever(search_kwargs={\"expr\": 'namespace == \"ankush\"'}).invoke(\n",
" search_kwargs={\"expr\": 'namespace == \"ankush\"'}\n", " \"where did i work?\"\n",
").get_relevant_documents(\"where did i work?\")" ")"
] ]
}, },
{ {
@ -320,9 +320,9 @@
], ],
"source": [ "source": [
"# This will only get documents for Harrison\n", "# This will only get documents for Harrison\n",
"vectorstore.as_retriever(\n", "vectorstore.as_retriever(search_kwargs={\"expr\": 'namespace == \"harrison\"'}).invoke(\n",
" search_kwargs={\"expr\": 'namespace == \"harrison\"'}\n", " \"where did i work?\"\n",
").get_relevant_documents(\"where did i work?\")" ")"
] ]
}, },
{ {

@ -694,7 +694,7 @@
], ],
"source": [ "source": [
"retriever = store.as_retriever()\n", "retriever = store.as_retriever()\n",
"retriever.get_relevant_documents(query)[0]" "retriever.invoke(query)[0]"
] ]
}, },
{ {

@ -256,7 +256,7 @@
], ],
"source": [ "source": [
"retriever = docsearch.as_retriever(search_type=\"mmr\")\n", "retriever = docsearch.as_retriever(search_type=\"mmr\")\n",
"matched_docs = retriever.get_relevant_documents(query)\n", "matched_docs = retriever.invoke(query)\n",
"for i, d in enumerate(matched_docs):\n", "for i, d in enumerate(matched_docs):\n",
" print(f\"\\n## Document {i}\\n\")\n", " print(f\"\\n## Document {i}\\n\")\n",
" print(d.page_content)" " print(d.page_content)"

@ -605,7 +605,7 @@
], ],
"source": [ "source": [
"query = \"What did the president say about Ketanji Brown Jackson\"\n", "query = \"What did the president say about Ketanji Brown Jackson\"\n",
"retriever.get_relevant_documents(query)[0]" "retriever.invoke(query)[0]"
] ]
}, },
{ {

@ -1078,7 +1078,7 @@
} }
], ],
"source": [ "source": [
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"docs" "docs"
] ]
}, },
@ -1120,7 +1120,7 @@
} }
], ],
"source": [ "source": [
"docs = retriever.get_relevant_documents(query)\n", "docs = retriever.invoke(query)\n",
"docs" "docs"
] ]
}, },
@ -1162,7 +1162,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"foo\")" "retriever.invoke(\"foo\")"
] ]
}, },
{ {
@ -1196,7 +1196,7 @@
} }
], ],
"source": [ "source": [
"retriever.get_relevant_documents(\"foo\")" "retriever.invoke(\"foo\")"
] ]
}, },
{ {

@ -362,7 +362,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"matched_docs = retriever.get_relevant_documents(query)" "matched_docs = retriever.invoke(query)"
] ]
}, },
{ {

@ -418,7 +418,7 @@
" search_type=\"similarity_score_threshold\",\n", " search_type=\"similarity_score_threshold\",\n",
" search_kwargs={\"k\": 3, \"score_threshold\": 0.8},\n", " search_kwargs={\"k\": 3, \"score_threshold\": 0.8},\n",
")\n", ")\n",
"docs_retrieved = retriever.get_relevant_documents(query)\n", "docs_retrieved = retriever.invoke(query)\n",
"for doc in docs_retrieved:\n", "for doc in docs_retrieved:\n",
" print(\"-\" * 80)\n", " print(\"-\" * 80)\n",
" print(doc.page_content)\n", " print(doc.page_content)\n",
@ -538,7 +538,7 @@
" search_kwargs={\"k\": 3, \"score_threshold\": 0.85},\n", " search_kwargs={\"k\": 3, \"score_threshold\": 0.85},\n",
")\n", ")\n",
"semantic_query = \"Could you recommend a US airport with clean lounges and good vegetarian dining options?\"\n", "semantic_query = \"Could you recommend a US airport with clean lounges and good vegetarian dining options?\"\n",
"reviews = retriever.get_relevant_documents(semantic_query)\n", "reviews = retriever.invoke(semantic_query)\n",
"for r in reviews:\n", "for r in reviews:\n",
" print(\"-\" * 80)\n", " print(\"-\" * 80)\n",
" print(r.page_content)\n", " print(r.page_content)\n",

@ -132,7 +132,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"retriever = db.as_retriever(search_type=\"mmr\")\n", "retriever = db.as_retriever(search_type=\"mmr\")\n",
"retriever.get_relevant_documents(query)" "retriever.invoke(query)"
] ]
}, },
{ {

@ -1350,7 +1350,7 @@
], ],
"source": [ "source": [
"# This example specifies a relevant query\n", "# This example specifies a relevant query\n",
"retriever.get_relevant_documents(\"What are improvements made to continuous aggregates?\")" "retriever.invoke(\"What are improvements made to continuous aggregates?\")"
] ]
}, },
{ {
@ -1381,7 +1381,7 @@
], ],
"source": [ "source": [
"# This example specifies a filter\n", "# This example specifies a filter\n",
"retriever.get_relevant_documents(\"What commits did Sven Klemm add?\")" "retriever.invoke(\"What commits did Sven Klemm add?\")"
] ]
}, },
{ {
@ -1412,9 +1412,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and filter\n", "# This example specifies a query and filter\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What commits about timescaledb_functions did Sven Klemm add?\")"
" \"What commits about timescaledb_functions did Sven Klemm add?\"\n",
")"
] ]
}, },
{ {
@ -1445,7 +1443,7 @@
], ],
"source": [ "source": [
"# This example specifies a time-based filter\n", "# This example specifies a time-based filter\n",
"retriever.get_relevant_documents(\"What commits were added in July 2023?\")" "retriever.invoke(\"What commits were added in July 2023?\")"
] ]
}, },
{ {
@ -1474,9 +1472,7 @@
], ],
"source": [ "source": [
"# This example specifies a query and a LIMIT value\n", "# This example specifies a query and a LIMIT value\n",
"retriever.get_relevant_documents(\n", "retriever.invoke(\"What are two commits about hierarchical continuous aggregates?\")"
" \"What are two commits about hierarchical continuous aggregates?\"\n",
")"
] ]
}, },
{ {

@ -216,7 +216,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"query = \"What did the president say about Ketanji Brown Jackson\"\n", "query = \"What did the president say about Ketanji Brown Jackson\"\n",
"retriever.get_relevant_documents(query)[0]" "retriever.invoke(query)[0]"
] ]
} }
], ],

@ -129,7 +129,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"retriever = db.as_retriever(search_type=\"mmr\")\n", "retriever = db.as_retriever(search_type=\"mmr\")\n",
"retriever.get_relevant_documents(query)" "retriever.invoke(query)"
] ]
}, },
{ {
@ -279,7 +279,7 @@
"retriever = db.as_retriever(\n", "retriever = db.as_retriever(\n",
" search_kwargs={\"search_type\": \"mmr\", \"grpc_metadata\": metadata}\n", " search_kwargs={\"search_type\": \"mmr\", \"grpc_metadata\": metadata}\n",
")\n", ")\n",
"retriever.get_relevant_documents(query, grpc_metadata=metadata)" "retriever.invoke(query, grpc_metadata=metadata)"
] ]
}, },
{ {

@ -895,7 +895,7 @@
], ],
"source": [ "source": [
"retriever = db.as_retriever()\n", "retriever = db.as_retriever()\n",
"relevant_docs = retriever.get_relevant_documents(query)[0]\n", "relevant_docs = retriever.invoke(query)[0]\n",
"\n", "\n",
"print_document_details(relevant_docs)" "print_document_details(relevant_docs)"
] ]
@ -940,7 +940,7 @@
], ],
"source": [ "source": [
"retriever = db.as_retriever(search_type=\"mmr\")\n", "retriever = db.as_retriever(search_type=\"mmr\")\n",
"relevant_docs = retriever.get_relevant_documents(query)[0]\n", "relevant_docs = retriever.invoke(query)[0]\n",
"\n", "\n",
"print_document_details(relevant_docs)" "print_document_details(relevant_docs)"
] ]

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save