From 581774a377576806dcf872d9d76cee206e790bdf Mon Sep 17 00:00:00 2001 From: Renzo-vS Date: Sat, 9 Nov 2024 05:27:21 +0100 Subject: [PATCH 1/2] fix duplicate content --- .../community/langchain_community/vectorstores/azuresearch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py index 193f6fc680e69..fff825f4dd18c 100644 --- a/libs/community/langchain_community/vectorstores/azuresearch.py +++ b/libs/community/langchain_community/vectorstores/azuresearch.py @@ -1798,7 +1798,9 @@ def _result_to_document(result: Dict) -> Document: fields_metadata = json.loads(result[FIELDS_METADATA]) else: fields_metadata = { - key: value for key, value in result.items() if key != FIELDS_CONTENT_VECTOR + key: value + for key, value in result.items() + if key not in [FIELDS_CONTENT_VECTOR, FIELDS_CONTENT] } # IDs if FIELDS_ID in result: From 4a378764456c08f4a00af4d0fa477061b6cc693c Mon Sep 17 00:00:00 2001 From: Renzo-vS Date: Mon, 11 Nov 2024 07:22:00 +0100 Subject: [PATCH 2/2] faster key lookup --- libs/community/langchain_community/vectorstores/azuresearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py index fff825f4dd18c..2a715b846f816 100644 --- a/libs/community/langchain_community/vectorstores/azuresearch.py +++ b/libs/community/langchain_community/vectorstores/azuresearch.py @@ -1808,7 +1808,7 @@ def _result_to_document(result: Dict) -> Document: else: fields_id = {} return Document( - page_content=result.pop(FIELDS_CONTENT), + page_content=result[FIELDS_CONTENT], metadata={ **fields_id, **fields_metadata,