|
@@ -863,6 +863,8 @@ class KbmService:
|
|
|
if not result:
|
|
|
raise ValueError("处理结果为空。")
|
|
|
|
|
|
+
|
|
|
+
|
|
|
KbmService.saveTask(document_id, len(result))
|
|
|
end_time = time.time()
|
|
|
execution_time = round(end_time - start_time, 2)
|
|
@@ -1184,7 +1186,7 @@ class KbmService:
|
|
|
document_id=document_id,
|
|
|
name=image_name,
|
|
|
page_number=i,
|
|
|
- chunk_number=inder,
|
|
|
+ chunk_number=j,
|
|
|
content=chunk['content'],
|
|
|
milvus_id=chunk['milvus_id']
|
|
|
)
|
|
@@ -1194,7 +1196,7 @@ class KbmService:
|
|
|
'chunk_number': page_inder,
|
|
|
})
|
|
|
page_inder += inder
|
|
|
-
|
|
|
+ logger.info(page_inder)
|
|
|
|
|
|
logger.info("解析结束")
|
|
|
return result
|
|
@@ -1457,23 +1459,41 @@ class KbmService:
|
|
|
# 根据 TaskSublist 的存在与否设置运行状态
|
|
|
progress_status = 1 if count > 0 else -1
|
|
|
|
|
|
+ # 更新 DocumentKbm 对象
|
|
|
+ # updated = DocumentKbm.objects.filter(id=document_id).update(
|
|
|
+ # token_num=max_tokens,
|
|
|
+ # chunk_num=total_chunks,
|
|
|
+ # progress=progress_status,
|
|
|
+ # process_begin_at=timezone.now(),
|
|
|
+ # process_duation= execution_time
|
|
|
+ # )
|
|
|
+ document = DocumentKbm.objects.select_for_update().get(id=document_id)
|
|
|
+ try:
|
|
|
+ logger.info(f'document_id { document_id}')
|
|
|
+ logger.info(f'max_tokens { max_tokens}')
|
|
|
+ logger.info(f'total_chunks {total_chunks}')
|
|
|
+ logger.info(f'progress {progress_status}')
|
|
|
+ # logger.info(f'process_begin_at {timezone.now()}')
|
|
|
+ logger.info(f'process_duation {execution_time}')
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(e)
|
|
|
|
|
|
# 更新 DocumentKbm 对象
|
|
|
- updated = DocumentKbm.objects.filter(id=document_id).update(
|
|
|
- token_num=max_tokens,
|
|
|
- chunk_num=total_chunks,
|
|
|
- progress=progress_status,
|
|
|
- process_begin_at=timezone.now(),
|
|
|
- process_duation= execution_time
|
|
|
- )
|
|
|
+ document.token_num = max_tokens
|
|
|
+ document.chunk_num = total_chunks
|
|
|
+ document.progress = progress_status
|
|
|
+ # document.process_begin_at = timezone.now()
|
|
|
+ document.process_duation = execution_time
|
|
|
+ document.save()
|
|
|
|
|
|
- if updated:
|
|
|
+ if document:
|
|
|
return True, f"Document {document_id} updated successfully."
|
|
|
else:
|
|
|
return False, f"Document {document_id} not found."
|
|
|
|
|
|
except Exception as e:
|
|
|
# 如果发生任何错误,事务会自动回滚
|
|
|
+ logger.error(str(e))
|
|
|
return False, f"Error updating document: {str(e)}"
|
|
|
#异步调用
|
|
|
|