From 64f5968a81f823f70d7fb15cbbccb9e0664668d3 Mon Sep 17 00:00:00 2001 From: Raunak Date: Sun, 7 Jan 2024 06:34:59 +0530 Subject: [PATCH] community: Replaced hardcoded "metadata" with FIELDS_METADATA variable in semantic_hybrid_search_with_score_and_rerank (#15642) - **Description:** This PR is to fix a bug in semantic_hybrid_search_with_score_and_rerank() function in langchain_community/vectorstores/azuresearch.py. The hardcoded "metadata" name is replaced with FIELDS_METADATA variable with an if block to check if the metadata column exists or not. - **Issue:** Fixed #15581 - **Dependencies:** No - **Twitter handle:** None Co-authored-by: H161961 --- .../langchain_community/vectorstores/azuresearch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py index 0b449688bd..f3ab8ae1e7 100644 --- a/libs/community/langchain_community/vectorstores/azuresearch.py +++ b/libs/community/langchain_community/vectorstores/azuresearch.py @@ -653,7 +653,10 @@ class AzureSearch(VectorStore): if result.get("@search.captions") else {}, "answers": semantic_answers_dict.get( - json.loads(result["metadata"]).get("key"), "" + json.loads(result[FIELDS_METADATA]).get("key") + if FIELDS_METADATA in result + else "", + "", ), }, },