From 2330dbb04e8a4588af82b6f7db595c80a1280fef Mon Sep 17 00:00:00 2001 From: certified-dodo <131419135+certified-dodo@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:17:42 -0800 Subject: [PATCH] community[patch]: Fix MongoDBAtlasVectorSearch max_marginal_relevance_search (#17971) Description: * `self._embedding_key` is accessed after deletion, breaking `max_marginal_relevance_search` search * Introduced in: https://github.com/langchain-ai/langchain/commit/e135e5257c4ed8185308b976a1dde1f0951d1324 * Updated but still persists in: https://github.com/langchain-ai/langchain/commit/ce22e10c4b18b9706bf6630c248e29597a86a583 Issue: https://github.com/langchain-ai/langchain/issues/17963 Co-authored-by: Bagatur --- libs/community/langchain_community/vectorstores/mongodb_atlas.py | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/mongodb_atlas.py b/libs/community/langchain_community/vectorstores/mongodb_atlas.py index ab15d0a7fcd708..ae645568f99206 100644 --- a/libs/community/langchain_community/vectorstores/mongodb_atlas.py +++ b/libs/community/langchain_community/vectorstores/mongodb_atlas.py @@ -215,7 +215,6 @@ def _similarity_search_with_score( for res in cursor: text = res.pop(self._text_key) score = res.pop("score") - del res[self._embedding_key] docs.append((Document(page_content=text, metadata=res), score)) return docs