Skip to content

Commit 2ad2ede

Browse files
committed
fix: 修复web站点知识库同步状态错误
1 parent 93d40b4 commit 2ad2ede

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

apps/dataset/serializers/document_serializers.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ def sync(self, with_valid=True, with_embedding=True):
432432
ListenerManagement.update_status(QuerySet(Document).filter(id=document_id),
433433
TaskType.SYNC,
434434
State.PENDING)
435+
ListenerManagement.get_aggregation_document_status(document_id)()
435436
source_url = document.meta.get('source_url')
436437
selector_list = document.meta.get('selector').split(
437438
" ") if 'selector' in document.meta and document.meta.get('selector') is not None else []
@@ -444,10 +445,10 @@ def sync(self, with_valid=True, with_embedding=True):
444445
# 删除向量库
445446
delete_embedding_by_document(document_id)
446447
paragraphs = get_split_model('web.md').parse(result.content)
447-
document.char_length = reduce(lambda x, y: x + y,
448-
[len(p.get('content')) for p in paragraphs],
449-
0)
450-
document.save()
448+
char_length = reduce(lambda x, y: x + y,
449+
[len(p.get('content')) for p in paragraphs],
450+
0)
451+
QuerySet(Document).filter(id=document_id).update(char_length=char_length)
451452
document_paragraph_model = DocumentSerializers.Create.get_paragraph_model(document, paragraphs)
452453

453454
paragraph_model_list = document_paragraph_model.get('paragraph_model_list')
@@ -464,6 +465,13 @@ def sync(self, with_valid=True, with_embedding=True):
464465
# 向量化
465466
if with_embedding:
466467
embedding_model_id = get_embedding_model_id_by_dataset_id(document.dataset_id)
468+
ListenerManagement.update_status(QuerySet(Document).filter(id=document_id),
469+
TaskType.EMBEDDING,
470+
State.PENDING)
471+
ListenerManagement.update_status(QuerySet(Paragraph).filter(document_id=document_id),
472+
TaskType.EMBEDDING,
473+
State.PENDING)
474+
ListenerManagement.get_aggregation_document_status(document_id)()
467475
embedding_by_document.delay(document_id, embedding_model_id)
468476

469477
else:
@@ -477,6 +485,7 @@ def sync(self, with_valid=True, with_embedding=True):
477485
ListenerManagement.update_status(QuerySet(Paragraph).filter(document_id=document_id),
478486
TaskType.SYNC,
479487
state)
488+
ListenerManagement.get_aggregation_document_status(document_id)()
480489
return True
481490

482491
class Operate(ApiMixin, serializers.Serializer):

0 commit comments

Comments
 (0)