mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 16:38:04 +08:00
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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user