LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
Fix/hitl db sync rules (#1311)
alia68b66575afe
diff --git a/backend/workflow_manager/endpoint_v2/dto.py b/backend/workflow_manager/endpoint_v2/dto.pyindex ead8e5c02..b1a9aab4e 100644--- a/backend/workflow_manager/endpoint_v2/dto.py+++ b/backend/workflow_manager/endpoint_v2/dto.py@@ -21,6 +21,7 @@ class FileHash:None # To which destination this file wants to go for MRQ percentage)is_executed: bool = False+ file_number: int | None = Nonedef to_json(self) -> dict[str, Any]:return {@@ -34,6 +35,7 @@ class FileHash:"mime_type": self.mime_type,"provider_file_uuid": self.provider_file_uuid,"fs_metadata": self.fs_metadata,+ "file_number": self.file_number,}@staticmethoddiff --git a/backend/workflow_manager/endpoint_v2/source.py b/backend/workflow_manager/endpoint_v2/source.pyindex 46ae39553..688e762a0 100644--- a/backend/workflow_manager/endpoint_v2/source.py+++ b/backend/workflow_manager/endpoint_v2/source.py@@ -450,10 +450,16 @@ class SourceConnector(BaseConnector):"""connection_type = self.endpoint.connection_typeif connection_type == WorkflowEndpoint.ConnectionType.FILESYSTEM:- return self.list_files_from_file_connector()+ files, count = self.list_files_from_file_connector()elif connection_type == WorkflowEndpoint.ConnectionType.API:- return self.list_file_from_api_storage(file_hashes)- raise InvalidSourceConnectionType()+ files, count = self.list_file_from_api_storage(file_hashes)+ else:+ raise InvalidSourceConnectionType()+ # TODO: move this to where file is listed at source.+ for index, file_hash in enumerate(files.values(), start=1):+ file_hash.file_number = index++ return files, countdef get_file_content_hash(self, source_fs: UnstractFileSystem, file_path: str) -> str:"""Generate a hash value from the file content.diff --git a/backend/workflow_manager/workflow_v2/dto.py b/backend/workflow_manager/workflow_v2/dto.pyindex fc52d36e7..91dcad76c 100644--- a/backend/workflow_manager/workflow_v2/dto.py+++ b/backend/workflow_manager/workflow_v2/dto.py@@ -154,6 +154,7 @@ class FileData:scheduled: boolexecution_mode: struse_file_history: bool+ q_file_no_list: list[int]@classmethoddef from_dict(cls, data: dict[str, Any]) -> FileData:diff --git a/backend/workflow_manager/workflow_v2/file_execution_tasks.py b/backend/workflow_manager/workflow_v2/file_execution_tasks.pyindex 4ccb66a51..ee88977d7 100644--- a/backend/workflow_manager/workflow_v2/file_execution_tasks.py+++ b/backend/workflow_manager/workflow_v2/file_execution_tasks.py@@ -138,9 +138,7 @@ class FileExecutionTasks:StateStore.set(Common.LOG_EVENTS_ID, log_events_id)total_files = len(file_batch_data.files)- q_file_no_list = (- WorkflowUtil.get_q_no_list(workflow, total_files) if total_files > 0 else []- )+ q_file_no_list = set(file_data.q_file_no_list)logger.info(f"Processing {total_files} files of execution {execution_id} in a batch"@@ -160,9 +158,10 @@ class FileExecutionTasks:fs_metadata=file_hash_dict.get("fs_metadata"),file_destination=file_hash_dict.get("file_destination"),is_executed=file_hash_dict.get("is_executed"),+ file_number=file_hash_dict.get("file_number"),)file_hash = WorkflowUtil.add_file_destination_filehash(- file_number,+ file_hash.file_number,q_file_no_list,file_hash,)diff --git a/backend/workflow_manager/workflow_v2/workflow_helper.py b/backend/workflow_manager/workflow_v2/workflow_helper.pyindex 414a20440..c79544cf8 100644--- a/backend/workflow_manager/workflow_v2/workflow_helper.py+++ b/backend/workflow_manager/workflow_v2/workflow_helper.py@@ -14,6 +14,7 @@ from celery.result import AsyncResultfrom django.conf import settingsfrom django.db import IntegrityErrorfrom pipeline_v2.models import Pipeline+from plugins.workflow_manager.workflow_v2.utils import WorkflowUtilfrom rest_framework import serializersfrom tool_instance_v2.constants import ToolInstanceKeyfrom tool_instance_v2.models import ToolInstance@@ -148,6 +149,10 @@ class WorkflowHelper:status=ExecutionStatus.EXECUTING, increment_attempt=True)+ q_file_no_list = (+ WorkflowUtil.get_q_no_list(workflow, total_files) if total_files > 0 else []+ )+if not input_files:logger.info(f"Execution {workflow_execution.id} no files to process")workflow_execution.update_execution(@@ -179,6 +184,7 @@ class WorkflowHelper:scheduled=scheduled,execution_mode=mode,use_file_history=use_file_history,+ q_file_no_list=list(q_file_no_list) if q_file_no_list else [],)batch_data = FileBatchData(files=batch, file_data=file_data)@@ -197,7 +203,7 @@ class WorkflowHelper:execution_id=str(workflow_execution.id)).set(queue=file_processing_queue))- if not result.id:+ if not result:exception = f"Failed to queue execution task {workflow_execution.id}"logger.error(exception)raise WorkflowExecutionError(exception)@@ -207,7 +213,9 @@ class WorkflowHelper:status=ExecutionStatus.ERROR,error=f"Error while processing files: {str(e)}",)- return result.id+ logger.error(+ f"Execution {workflow_execution.id} failed: {str(e)}", exc_info=True+ )@staticmethoddef validate_tool_instances_meta(