1- # Copyright (C) 2025 Huawei Technologies Co., Ltd.
1+ # Copyright (C) 2025 Huawei Technologies Co., Ltd.
22# SPDX-License-Identifier: Apache-2.0
33
44
55import os
6+ from urllib .parse import urlparse
67
78from fastapi import HTTPException
89from langchain_community .embeddings import HuggingFaceBgeEmbeddings , HuggingFaceInferenceAPIEmbeddings
9- from langchain_opengauss import OpenGauss , OpenGaussSettings
1010from langchain_huggingface import HuggingFaceEmbeddings
11- from urllib . parse import urlparse
11+ from langchain_opengauss import OpenGauss , OpenGaussSettings
1212
1313from comps import CustomLogger , EmbedDoc , OpeaComponent , OpeaComponentRegistry , ServiceType
1414
15- from .config import EMBED_MODEL , HF_TOKEN , GS_CONNECTION_STRING , GS_INDEX_NAME , TEI_EMBEDDING_ENDPOINT
15+ from .config import EMBED_MODEL , GS_CONNECTION_STRING , GS_INDEX_NAME , HF_TOKEN , TEI_EMBEDDING_ENDPOINT
1616
1717logger = CustomLogger ("opengauss_retrievers" )
1818logflag = os .getenv ("LOGFLAG" , False )
@@ -75,17 +75,9 @@ def _initialize_client(self) -> OpenGauss:
7575 port = result .port
7676
7777 self .opengauss_config = OpenGaussSettings (
78- host = hostname ,
79- port = port ,
80- user = username ,
81- password = password ,
82- database = database ,
83- embedding_dimension = 768
84- )
85- vector_db = OpenGauss (
86- embedding = self .embedder ,
87- config = self .opengauss_config
78+ host = hostname , port = port , user = username , password = password , database = database , embedding_dimension = 768
8879 )
80+ vector_db = OpenGauss (embedding = self .embedder , config = self .opengauss_config )
8981 return vector_db
9082
9183 def check_health (self ) -> bool :
@@ -101,7 +93,6 @@ def check_health(self) -> bool:
10193 hostname = result .hostname
10294 port = result .port
10395
104-
10596 if logflag :
10697 logger .info ("[ check health ] start to check health of openGauss" )
10798 try :
@@ -128,4 +119,4 @@ async def invoke(self, input: EmbedDoc) -> list:
128119
129120 if logflag :
130121 logger .info (f"[ similarity search ] search result: { search_res } " )
131- return search_res
122+ return search_res
0 commit comments