|
|
@@ -523,18 +523,18 @@ class KnowledgeBaseService:
|
|
|
|
|
|
try:
|
|
|
# 创建 collection1
|
|
|
- if kb.collection_name1 and not milvus_service.has_collection(kb.collection_name1):
|
|
|
+ if kb.collection_name_parent and not milvus_service.has_collection(kb.collection_name_parent):
|
|
|
milvus_service.create_collection(
|
|
|
- name=kb.collection_name1,
|
|
|
+ name=kb.collection_name_parent,
|
|
|
dimension=milvus_service.DENSE_DIM,
|
|
|
description=kb.description or "",
|
|
|
fields=fields
|
|
|
)
|
|
|
|
|
|
# 创建 collection2
|
|
|
- if kb.collection_name2 and not milvus_service.has_collection(kb.collection_name2):
|
|
|
+ if kb.collection_name_children and not milvus_service.has_collection(kb.collection_name_children):
|
|
|
milvus_service.create_collection(
|
|
|
- name=kb.collection_name2,
|
|
|
+ name=kb.collection_name_children,
|
|
|
dimension=milvus_service.DENSE_DIM,
|
|
|
description=kb.description or "",
|
|
|
fields=fields
|
|
|
@@ -557,8 +557,8 @@ class KnowledgeBaseService:
|
|
|
meta_result = await db.execute(meta_query)
|
|
|
metadata_fields = [f.to_dict() for f in meta_result.scalars().all()]
|
|
|
|
|
|
- # 自动推断逻辑:如果 DB 中没有定义元数据,且 Milvus 中有数据,尝试推断 (优先推断 collection1)
|
|
|
- target_col = kb.collection_name1
|
|
|
+ # 自动推断逻辑:如果 DB 中没有定义元数据,且 Milvus 中有数据,尝试推断 (优先推断 collection_name_parent)
|
|
|
+ target_col = kb.collection_name_parent
|
|
|
if not metadata_fields and target_col and milvus_service.has_collection(target_col):
|
|
|
try:
|
|
|
# 采样查询 (获取前10条)
|
|
|
@@ -682,7 +682,7 @@ class KnowledgeBaseService:
|
|
|
await db.commit()
|
|
|
return total_count
|
|
|
except Exception as e:
|
|
|
- print(f"Failed to update doc count for {collection_name}: {e}")
|
|
|
+ logger.exception(f"Failed to update doc count for {collection_name}: {e}")
|
|
|
return 0
|
|
|
return 0
|
|
|
|