fix: Fix the case where documents were created when summary_index_setting was disabled. Fix the problem that summaries of chunks without text content is always in English.

This commit is contained in:
FFXN
2026-01-30 22:11:14 +08:00
parent 9f123391db
commit d4844a902e
10 changed files with 133 additions and 8 deletions

View File

@ -1339,6 +1339,21 @@ class DocumentGenerateSummaryApi(Resource):
missing_ids = set(document_list) - found_ids
raise NotFound(f"Some documents not found: {list(missing_ids)}")
# Update need_summary to True for documents that don't have it set
# This handles the case where documents were created when summary_index_setting was disabled
documents_to_update = [
doc for doc in documents
if not doc.need_summary and doc.doc_form != "qa_model"
]
if documents_to_update:
document_ids_to_update = [str(doc.id) for doc in documents_to_update]
DocumentService.update_documents_need_summary(
dataset_id=dataset_id,
document_ids=document_ids_to_update,
need_summary=True,
)
# Dispatch async tasks for each document
for document in documents:
# Skip qa_model documents as they don't generate summaries