From 9eeeab7dacb4b6a86862382c278b5d53b7040a1a Mon Sep 17 00:00:00 2001 From: Dai Sugimori Date: Mon, 11 Nov 2024 22:20:58 +0900 Subject: [PATCH 1/2] Remove unnecessary override code --- elasticsearch/helpers/vectorstore/_async/vectorstore.py | 4 +--- elasticsearch/helpers/vectorstore/_sync/vectorstore.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/elasticsearch/helpers/vectorstore/_async/vectorstore.py b/elasticsearch/helpers/vectorstore/_async/vectorstore.py index 3b8c1e9e9..9ed77d408 100644 --- a/elasticsearch/helpers/vectorstore/_async/vectorstore.py +++ b/elasticsearch/helpers/vectorstore/_async/vectorstore.py @@ -83,10 +83,8 @@ def __init__( # client.options preserves existing (non-user-agent) headers. client = client.options(headers={"User-Agent": user_agent}) - if hasattr(retrieval_strategy, "text_field"): + if hasattr(retrieval_strategy, "text_field") and retrieval_strategy.text_field is None: retrieval_strategy.text_field = text_field - if hasattr(retrieval_strategy, "vector_field"): - retrieval_strategy.vector_field = vector_field self.client = client self.index = index diff --git a/elasticsearch/helpers/vectorstore/_sync/vectorstore.py b/elasticsearch/helpers/vectorstore/_sync/vectorstore.py index 3c4a0d51a..e3b021e67 100644 --- a/elasticsearch/helpers/vectorstore/_sync/vectorstore.py +++ b/elasticsearch/helpers/vectorstore/_sync/vectorstore.py @@ -80,10 +80,8 @@ def __init__( # client.options preserves existing (non-user-agent) headers. client = client.options(headers={"User-Agent": user_agent}) - if hasattr(retrieval_strategy, "text_field"): + if hasattr(retrieval_strategy, "text_field") and retrieval_strategy.text_field is None: retrieval_strategy.text_field = text_field - if hasattr(retrieval_strategy, "vector_field"): - retrieval_strategy.vector_field = vector_field self.client = client self.index = index From fd9c24a35e22f342b2d436bdb1a38f47c8f44212 Mon Sep 17 00:00:00 2001 From: Dai Sugimori Date: Mon, 11 Nov 2024 22:50:27 +0900 Subject: [PATCH 2/2] Apply lint --- elasticsearch/helpers/vectorstore/_async/vectorstore.py | 5 ++++- elasticsearch/helpers/vectorstore/_sync/vectorstore.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/elasticsearch/helpers/vectorstore/_async/vectorstore.py b/elasticsearch/helpers/vectorstore/_async/vectorstore.py index 9ed77d408..b642f8753 100644 --- a/elasticsearch/helpers/vectorstore/_async/vectorstore.py +++ b/elasticsearch/helpers/vectorstore/_async/vectorstore.py @@ -83,7 +83,10 @@ def __init__( # client.options preserves existing (non-user-agent) headers. client = client.options(headers={"User-Agent": user_agent}) - if hasattr(retrieval_strategy, "text_field") and retrieval_strategy.text_field is None: + if ( + hasattr(retrieval_strategy, "text_field") + and retrieval_strategy.text_field is None + ): retrieval_strategy.text_field = text_field self.client = client diff --git a/elasticsearch/helpers/vectorstore/_sync/vectorstore.py b/elasticsearch/helpers/vectorstore/_sync/vectorstore.py index e3b021e67..40772d99c 100644 --- a/elasticsearch/helpers/vectorstore/_sync/vectorstore.py +++ b/elasticsearch/helpers/vectorstore/_sync/vectorstore.py @@ -80,7 +80,10 @@ def __init__( # client.options preserves existing (non-user-agent) headers. client = client.options(headers={"User-Agent": user_agent}) - if hasattr(retrieval_strategy, "text_field") and retrieval_strategy.text_field is None: + if ( + hasattr(retrieval_strategy, "text_field") + and retrieval_strategy.text_field is None + ): retrieval_strategy.text_field = text_field self.client = client