mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-02-07 15:38:27 +08:00
elasticsearch更新https连接 (#2390)
This commit is contained in:
parent
29ef5dda64
commit
a5b52e1bd1
@ -15,7 +15,7 @@ class ESKBService(KBService):
|
|||||||
|
|
||||||
def do_init(self):
|
def do_init(self):
|
||||||
self.kb_path = self.get_kb_path(self.kb_name)
|
self.kb_path = self.get_kb_path(self.kb_name)
|
||||||
self.index_name = self.kb_path.split("/")[-1]
|
self.index_name = kbs_config[self.vs_type()]['index_name']
|
||||||
self.IP = kbs_config[self.vs_type()]['host']
|
self.IP = kbs_config[self.vs_type()]['host']
|
||||||
self.PORT = kbs_config[self.vs_type()]['port']
|
self.PORT = kbs_config[self.vs_type()]['port']
|
||||||
self.user = kbs_config[self.vs_type()].get("user",'')
|
self.user = kbs_config[self.vs_type()].get("user",'')
|
||||||
@ -25,11 +25,11 @@ class ESKBService(KBService):
|
|||||||
try:
|
try:
|
||||||
# ES python客户端连接(仅连接)
|
# ES python客户端连接(仅连接)
|
||||||
if self.user != "" and self.password != "":
|
if self.user != "" and self.password != "":
|
||||||
self.es_client_python = Elasticsearch(f"http://{self.IP}:{self.PORT}",
|
self.es_client_python = Elasticsearch(f"https://{self.IP}:{self.PORT}",
|
||||||
basic_auth=(self.user,self.password))
|
basic_auth=(self.user,self.password))
|
||||||
else:
|
else:
|
||||||
logger.warning("ES未配置用户名和密码")
|
logger.warning("ES未配置用户名和密码")
|
||||||
self.es_client_python = Elasticsearch(f"http://{self.IP}:{self.PORT}")
|
self.es_client_python = Elasticsearch(f"https://{self.IP}:{self.PORT}")
|
||||||
except ConnectionError:
|
except ConnectionError:
|
||||||
logger.error("连接到 Elasticsearch 失败!")
|
logger.error("连接到 Elasticsearch 失败!")
|
||||||
raise ConnectionError
|
raise ConnectionError
|
||||||
@ -47,7 +47,7 @@ class ESKBService(KBService):
|
|||||||
# langchain ES 连接、创建索引
|
# langchain ES 连接、创建索引
|
||||||
if self.user != "" and self.password != "":
|
if self.user != "" and self.password != "":
|
||||||
self.db_init = ElasticsearchStore(
|
self.db_init = ElasticsearchStore(
|
||||||
es_url=f"http://{self.IP}:{self.PORT}",
|
es_url=f"https://{self.IP}:{self.PORT}",
|
||||||
index_name=self.index_name,
|
index_name=self.index_name,
|
||||||
query_field="context",
|
query_field="context",
|
||||||
vector_query_field="dense_vector",
|
vector_query_field="dense_vector",
|
||||||
@ -58,7 +58,7 @@ class ESKBService(KBService):
|
|||||||
else:
|
else:
|
||||||
logger.warning("ES未配置用户名和密码")
|
logger.warning("ES未配置用户名和密码")
|
||||||
self.db_init = ElasticsearchStore(
|
self.db_init = ElasticsearchStore(
|
||||||
es_url=f"http://{self.IP}:{self.PORT}",
|
es_url=f"https://{self.IP}:{self.PORT}",
|
||||||
index_name=self.index_name,
|
index_name=self.index_name,
|
||||||
query_field="context",
|
query_field="context",
|
||||||
vector_query_field="dense_vector",
|
vector_query_field="dense_vector",
|
||||||
@ -110,7 +110,7 @@ class ESKBService(KBService):
|
|||||||
self.db = ElasticsearchStore.from_documents(
|
self.db = ElasticsearchStore.from_documents(
|
||||||
documents=docs,
|
documents=docs,
|
||||||
embedding=embed_model,
|
embedding=embed_model,
|
||||||
es_url= f"http://{self.IP}:{self.PORT}",
|
es_url= f"https://{self.IP}:{self.PORT}",
|
||||||
index_name=self.index_name,
|
index_name=self.index_name,
|
||||||
distance_strategy="COSINE",
|
distance_strategy="COSINE",
|
||||||
query_field="context",
|
query_field="context",
|
||||||
@ -123,7 +123,7 @@ class ESKBService(KBService):
|
|||||||
self.db = ElasticsearchStore.from_documents(
|
self.db = ElasticsearchStore.from_documents(
|
||||||
documents=docs,
|
documents=docs,
|
||||||
embedding=embed_model,
|
embedding=embed_model,
|
||||||
es_url= f"http://{self.IP}:{self.PORT}",
|
es_url= f"https://{self.IP}:{self.PORT}",
|
||||||
index_name=self.index_name,
|
index_name=self.index_name,
|
||||||
distance_strategy="COSINE",
|
distance_strategy="COSINE",
|
||||||
query_field="context",
|
query_field="context",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user