[Bug] [KG] Resolve the error in obtaining authentication information from the env file for ElasticSearch vector database
#1,811 opened on Aug 12, 2024
Repository metrics
- Stars
- (19,732 stars)
- PR merge metrics
- (Avg merge 5d 22h) (5 merged PRs in 30d)
Description
Search before asking
- I had searched in the issues and found no similar issues.
Operating system information
Linux
Python version information
=3.11
DB-GPT version
main
Related scenes
- Chat Data
- Chat Excel
- Chat DB
- Chat Knowledge
- Model Management
- Dashboard
- Plugins
Installation Information
-
AutoDL Image
-
Other
Device information
Device:CPU
Models information
LLM:Proxy LLM
What happened
When deploying the ElasticSearch vector database on a machine different from DB-GPT, the DB connection to the ElasticSearch vector database will fail.
What you expected to happen
Can correctly read the configuration information about ElasticSearch vector db from the env file。
By modifying the following files, you can correctly read the configuration information about ElasticSearch db from the env file.
- Modify the. env. template file.
Before modification:
ElasticSearch vector db config
#VECTOR_STORE_TYPE=ElasticSearch ElasticSearch_URL=127.0.0.1 ElasticSearch_PORT=9200 ElasticSearch_USERNAME=elastic ElasticSearch_PASSWORD=i=+iLw9y0Jduq86XTi6W
After modification:
ElasticSearch vector db config
#VECTOR_STORE_TYPE=ElasticSearch ELASTICSEARCH_URL=127.0.0.1 ELASTICSEARCH_PORT=9200 ELASTICSEARCH_USERNAME=elastic ELASTICSEARCH_PASSWORD=i=+iLw9y0Jduq86XTi6W
- Modify/DB-GPT/dbgpt/storage/sector_store/elastic_store.py
Before modification: class ElasticsearchVectorConfig(VectorStoreConfig): """Elasticsearch vector store config.""" class Config: """Config for BaseModel.""" arbitrary_types_allowed = True uri: str = Field( default="localhost", //当default="localhost"时, env文件中关于ELASTICSEARCH_URL 将不会被读取。 description="The uri of elasticsearch store, if not set, will use the default " "uri.", ) port: str = Field( default="9200", ////当default="9200"时, env文件中关于ELASTICSEARCH_PORT 将不会被读取。 description="The port of elasticsearch store, if not set, will use the default " "port.", ) alias: str = Field( default="default", description="The alias of elasticsearch store, if not set, will use the " "default " "alias.", ) ......... 134 lines of code: self.port = elasticsearch_vector_config.get("post") or os.getenv( // 单词拼写错误 "ELASTICSEARCH_PORT", "9200" )
After modification: class ElasticsearchVectorConfig(VectorStoreConfig): """Elasticsearch vector store config.""" class Config: """Config for BaseModel.""" arbitrary_types_allowed = True uri: Optional[str] = Field( default=None, //修改后,可正确读取env文件中关于ELASTICSEARCH_URL的值 description="The uri of elasticsearch store, if not set, will use the default " "uri.", ) port: Optional[str] = Field( default=None, //修改后,可正确读取env文件中关于ELASTICSEARCH_PORT的值 description="The port of elasticsearch store, if not set, will use the default " "port.", ) alias: str = Field( default="default", description="The alias of elasticsearch store, if not set, will use the " "default " "alias.", )
......... 134 lines of code: self.port = elasticsearch_vector_config.get("port") or os.getenv( "ELASTICSEARCH_PORT", "9200" )
How to reproduce
Deploying ElasticSearch vector db on a machine different from DB-GPT and specifying ElasticSearch connection information in the env file will result in connection failure.
Additional context
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!