Skip to content

Commit

Permalink
fix:multi client error (#1532)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aries-ckt authored May 16, 2024
1 parent af700d1 commit c500fb9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dbgpt/storage/vector_store/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import copy
import logging
import os
from collections import defaultdict
from typing import Any, Dict, List, Optional, Tuple, Type, cast

from dbgpt.core import Chunk, Embeddings
Expand All @@ -21,6 +22,7 @@
logger = logging.getLogger(__name__)

connector: Dict[str, Tuple[Type, Type]] = {}
pools = defaultdict(dict)


def _load_vector_options() -> List[OptionValue]:
Expand Down Expand Up @@ -115,8 +117,15 @@ def __init__(
config_dict = vector_store_config.dict()
config.llm_client = config_dict.get("llm_client", None)
config.model_name = config_dict.get("model_name", None)

self.client = self.connector_class(config)
if (
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:
logger.error("connect vector store failed: %s", e)
raise e
Expand Down

0 comments on commit c500fb9

Please sign in to comment.