From 90e22ac1362b00d7543b1c9bb293bd356ba09375 Mon Sep 17 00:00:00 2001 From: geebytes Date: Thu, 10 Apr 2025 07:36:43 +0800 Subject: [PATCH] fix: Bugfix/elasticsearch store read config dict (#2577) --- .../src/dbgpt_ext/storage/vector_store/elastic_store.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/elastic_store.py b/packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/elastic_store.py index cce3ea65e..8232476fd 100644 --- a/packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/elastic_store.py +++ b/packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/elastic_store.py @@ -167,7 +167,7 @@ class ElasticStore(VectorStoreBase): self._vector_store_config = vector_store_config connect_kwargs = {} - elasticsearch_vector_config = vector_store_config.dict() + elasticsearch_vector_config = vector_store_config.to_dict() self.uri = os.getenv( "ELASTICSEARCH_URL", "localhost" ) or elasticsearch_vector_config.get("uri") @@ -224,7 +224,10 @@ class ElasticStore(VectorStoreBase): "`pip install elasticsearch`." ) try: - if self.username != "" and self.password != "": + # The condition should check for both None and empty string ("") + # When reading non-existent keys from env/config files, + # the value will be None + if self.username and self.password: self.es_client_python = Elasticsearch( f"http://{self.uri}:{self.port}", basic_auth=(self.username, self.password), @@ -248,7 +251,7 @@ class ElasticStore(VectorStoreBase): # create es index try: - if self.username != "" and self.password != "": + if self.username and self.password: self.db_init = ElasticsearchStore( es_url=f"http://{self.uri}:{self.port}", index_name=self.index_name,