mirror of
https://github.com/hwchase17/langchain.git
synced 2026-01-29 21:30:18 +00:00
[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:
@@ -13,6 +13,10 @@ def test_azure_cognitive_search_get_relevant_documents() -> None:
|
||||
assert isinstance(doc, Document)
|
||||
assert doc.page_content
|
||||
|
||||
retriever = AzureCognitiveSearchRetriever(top_k=1)
|
||||
documents = retriever.get_relevant_documents("what is langchain")
|
||||
assert len(documents) <= 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_azure_cognitive_search_aget_relevant_documents() -> None:
|
||||
|
||||
Reference in New Issue
Block a user