mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-30 07:11:56 +00:00
fix:multi client error (#1532)
This commit is contained in:
parent
af700d1dc0
commit
c500fb9060
@ -3,6 +3,7 @@
|
|||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from collections import defaultdict
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Type, cast
|
from typing import Any, Dict, List, Optional, Tuple, Type, cast
|
||||||
|
|
||||||
from dbgpt.core import Chunk, Embeddings
|
from dbgpt.core import Chunk, Embeddings
|
||||||
@ -21,6 +22,7 @@ from dbgpt.util.i18n_utils import _
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
connector: Dict[str, Tuple[Type, Type]] = {}
|
connector: Dict[str, Tuple[Type, Type]] = {}
|
||||||
|
pools = defaultdict(dict)
|
||||||
|
|
||||||
|
|
||||||
def _load_vector_options() -> List[OptionValue]:
|
def _load_vector_options() -> List[OptionValue]:
|
||||||
@ -115,8 +117,15 @@ class VectorStoreConnector:
|
|||||||
config_dict = vector_store_config.dict()
|
config_dict = vector_store_config.dict()
|
||||||
config.llm_client = config_dict.get("llm_client", None)
|
config.llm_client = config_dict.get("llm_client", None)
|
||||||
config.model_name = config_dict.get("model_name", None)
|
config.model_name = config_dict.get("model_name", None)
|
||||||
|
if (
|
||||||
self.client = self.connector_class(config)
|
vector_store_type in pools
|
||||||
|
and config.name in pools[vector_store_type]
|
||||||
|
):
|
||||||
|
self.client = pools[vector_store_type][config.name]
|
||||||
|
else:
|
||||||
|
client = self.connector_class(config)
|
||||||
|
pools[vector_store_type][config.name] = self.client = client
|
||||||
|
self.client = client
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("connect vector store failed: %s", e)
|
logger.error("connect vector store failed: %s", e)
|
||||||
raise e
|
raise e
|
||||||
|
Loading…
Reference in New Issue
Block a user