[Small upgrade] Allow document limit in AzureCognitiveSearchRetriever (#7690)

Multiple people have asked in #5081 for a way to limit the documents
returned from an AzureCognitiveSearchRetriever. This PR adds the `top_n`
parameter to allow that.


Twitter handle:
 [@UmerHAdil](twitter.com/umerHAdil)
This commit is contained in:
UmerHA
2023-07-14 05:04:40 +02:00
committed by GitHub
parent af6d333147
commit 82f3e32d8d
3 changed files with 39 additions and 2 deletions

View File

@@ -91,7 +91,7 @@
"metadata": {},
"outputs": [],
"source": [
"retriever = AzureCognitiveSearchRetriever(content_key=\"content\")"
"retriever = AzureCognitiveSearchRetriever(content_key=\"content\", top_k=10)"
]
},
{
@@ -111,6 +111,36 @@
"source": [
"retriever.get_relevant_documents(\"what is langchain\")"
]
},
{
"cell_type": "markdown",
"id": "72eca08e",
"metadata": {},
"source": [
"You can change the number of results returned with the `top_k` parameter. The default value is `None`, which returns all results. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "097146c5",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "6d9963f5",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "dc120696",
"metadata": {},
"source": []
}
],
"metadata": {