Skip to content

The agent engineering platform.

community: AzureSearch: fix reranking for empty lists (#27104)

Oleksii Pokotylo37ca468d033a
diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py
index 3e022d3165..193f6fc680 100644
--- a/libs/community/langchain_community/vectorstores/azuresearch.py
+++ b/libs/community/langchain_community/vectorstores/azuresearch.py
@@ -1769,6 +1769,8 @@ def _reorder_results_with_maximal_marginal_relevance(
)
for result in results
]
+ if not docs:
+ return []
documents, scores, vectors = map(list, zip(*docs))
# Get the new order of results.