eosphoros-ai/DB-GPT

[Bug] [KG] Resolve the error in obtaining authentication information from the env file for ElasticSearch vector database

Aperta

#1811 aperta il 12 ago 2024

 (0 commenti) (0 reazioni) (0 assegnatari)Python (2885 fork)batch import
Waiting for replybughacktoberfest

Metriche repository

Star
 (19.774 stelle)
Metriche merge PR
 (Merge medio 5g 22h) (5 PR mergiate in 30 g)

Descrizione

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

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.

  1. 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

  1. 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!

Guida contributor