From 6fb3d33bf4849244c9db6f5eac20054668b1b89b Mon Sep 17 00:00:00 2001 From: Aries-ckt <916701291@qq.com> Date: Fri, 17 May 2024 10:33:30 +0800 Subject: [PATCH] fix: delete datasource bug (#1533) --- dbgpt/storage/vector_store/connector.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dbgpt/storage/vector_store/connector.py b/dbgpt/storage/vector_store/connector.py index 260127e05..72e9b7a13 100644 --- a/dbgpt/storage/vector_store/connector.py +++ b/dbgpt/storage/vector_store/connector.py @@ -4,7 +4,7 @@ import logging import os from collections import defaultdict -from typing import Any, Dict, List, Optional, Tuple, Type, cast +from typing import Any, DefaultDict, Dict, List, Optional, Tuple, Type, cast from dbgpt.core import Chunk, Embeddings from dbgpt.core.awel.flow import ( @@ -22,7 +22,7 @@ logger = logging.getLogger(__name__) connector: Dict[str, Tuple[Type, Type]] = {} -pools = defaultdict(dict) +pools: DefaultDict[str, Dict] = defaultdict(dict) def _load_vector_options() -> List[OptionValue]: @@ -248,7 +248,13 @@ def delete_vector_name(self, vector_name: str): Args: - vector_name: vector store name """ - return self.client.delete_vector_name(vector_name) + try: + if self.vector_name_exists(): + self.client.delete_vector_name(vector_name) + except Exception as e: + logger.error(f"delete vector name {vector_name} failed: {e}") + raise Exception(f"delete name {vector_name} failed") + return True def delete_by_ids(self, ids): """Delete vector by ids.