mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-23 12:21:08 +00:00
fix: Fix milvus vector_name_exists bug (#2818)
This commit is contained in:
parent
1eea9c8eec
commit
cecac56a26
@ -649,15 +649,17 @@ class MilvusStore(VectorStoreBase):
|
|||||||
def vector_name_exists(self):
|
def vector_name_exists(self):
|
||||||
"""Whether vector name exists."""
|
"""Whether vector name exists."""
|
||||||
try:
|
try:
|
||||||
from pymilvus import utility
|
if not self._milvus_client.has_collection(self.collection_name):
|
||||||
except ImportError:
|
logger.info(f"Collection {self.collection_name} does not exist")
|
||||||
raise ValueError(
|
return False
|
||||||
"Could not import pymilvus python package. "
|
|
||||||
"Please install it with `pip install pymilvus`."
|
|
||||||
)
|
|
||||||
|
|
||||||
"""is vector store name exist."""
|
stats = self._milvus_client.get_collection_stats(self.collection_name)
|
||||||
return utility.has_collection(self.collection_name)
|
row_count = stats.get("row_count", 0)
|
||||||
|
return row_count > 0
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"vector_name_exists error, {str(e)}")
|
||||||
|
return False
|
||||||
|
|
||||||
def delete_vector_name(self, vector_name: str):
|
def delete_vector_name(self, vector_name: str):
|
||||||
"""Delete vector name."""
|
"""Delete vector name."""
|
||||||
|
Loading…
Reference in New Issue
Block a user