feat: add authenticated engine processing boundary
This commit is contained in:
@@ -252,7 +252,7 @@ def extract_document(document, llm_client=None, batch_id=None):
|
||||
"""Извлечь паспорт одного документа, изолируя ошибки на уровне документа."""
|
||||
document_id = document["id"]
|
||||
batch_id = batch_id if batch_id is not None else document.get("batch_id")
|
||||
elements = _decode_elements(document.get("elements_json"))
|
||||
elements = _decode_elements(document.get("elements", document.get("elements_json")))
|
||||
structured_text = format_elements_with_structure(elements)
|
||||
raw_response = "{}"
|
||||
try:
|
||||
@@ -306,13 +306,14 @@ 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, progress_callback=None):
|
||||
def extract_batch(batch_id, llm_client=None, progress_callback=None, documents=None):
|
||||
"""Обработать документы batch и вернуть сводку без batch-wide failure.
|
||||
|
||||
Optional progress callback получает (completed_count, document_result) после
|
||||
каждого документа; ошибки callback не должны останавливать обработку batch.
|
||||
"""
|
||||
documents = db_docs.list_for_extraction(batch_id)
|
||||
if documents is None:
|
||||
documents = db_docs.list_for_extraction(batch_id)
|
||||
results = []
|
||||
for completed, document in enumerate(documents, start=1):
|
||||
result = extract_document(document, llm_client=llm_client, batch_id=batch_id)
|
||||
|
||||
Reference in New Issue
Block a user