feat: wire v3 dossier API and reconciliation
This commit is contained in:
@@ -306,10 +306,22 @@ def extract_document(document, llm_client=None, batch_id=None):
|
||||
return {"ok": False, "document_id": document_id, "error": str(error)}
|
||||
|
||||
|
||||
def extract_batch(batch_id, llm_client=None):
|
||||
"""Обработать все документы batch и вернуть сводку без batch-wide failure."""
|
||||
def extract_batch(batch_id, llm_client=None, progress_callback=None):
|
||||
"""Обработать документы batch и вернуть сводку без batch-wide failure.
|
||||
|
||||
Optional progress callback получает (completed_count, document_result) после
|
||||
каждого документа; ошибки callback не должны останавливать обработку batch.
|
||||
"""
|
||||
documents = db_docs.list_for_extraction(batch_id)
|
||||
results = [extract_document(document, llm_client=llm_client, batch_id=batch_id) for document in documents]
|
||||
results = []
|
||||
for completed, document in enumerate(documents, start=1):
|
||||
result = extract_document(document, llm_client=llm_client, batch_id=batch_id)
|
||||
results.append(result)
|
||||
if progress_callback is not None:
|
||||
try:
|
||||
progress_callback(completed, result)
|
||||
except Exception:
|
||||
log.exception("Extraction progress callback failed for batch %s", batch_id)
|
||||
done = sum(1 for result in results if result["ok"])
|
||||
failed = len(results) - done
|
||||
classes = {}
|
||||
|
||||
Reference in New Issue
Block a user