mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-31 15:47:05 +00:00
fix issue2321:Provide an implementation of the truncate method (#2357)
# Description 构建社区摘要时(community_store.py中的build_communities方法),先清空向量存储,仅提供了ChromaStore对于实现truncate方法,未提供MilvusStore对于该方法的实现,当使用milvus作为向量数据库时会抛出错误“NotImplementedError”。提供一种实现方法,修复此问题。 # How Has This Been Tested? 使用milvus作为向量数据库,然后通过以下步骤: 1.构建一个知识图谱类型的知识库; 2.上传一个文件; 3.选择上传的文件,点击"同步" # Snapshots: Include snapshots for easier review. # Checklist: - [x] My code follows the style guidelines of this project - [x] I have already rebased the commits and make the commit message conform to the project standard. - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] Any dependent changes have been merged and published in downstream modules
This commit is contained in:
commit
49ce86f2ce
@ -639,3 +639,15 @@ class MilvusStore(VectorStoreBase):
|
||||
else:
|
||||
metadata_filter_expr = metadata_filters[0]
|
||||
return metadata_filter_expr
|
||||
|
||||
def truncate(self):
|
||||
"""Truncate milvus collection.
|
||||
"""
|
||||
logger.info(f"begin truncate milvus collection:{self.collection_name}")
|
||||
from pymilvus import utility
|
||||
if utility.has_collection(self.collection_name):
|
||||
utility.drop_collection(self.collection_name)
|
||||
|
||||
logger.info(
|
||||
f"truncate milvus collection {self.collection_name} success"
|
||||
)
|
Loading…
Reference in New Issue
Block a user