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/api deployment response (#157)
ali5bfbeaa3379b
diff --git a/backend/api/api_deployment_views.py b/backend/api/api_deployment_views.pyindex 4de36c821..f8b5007ea 100644--- a/backend/api/api_deployment_views.py+++ b/backend/api/api_deployment_views.py@@ -16,6 +16,7 @@ from rest_framework.decorators import actionfrom rest_framework.request import Requestfrom rest_framework.response import Responsefrom rest_framework.serializers import Serializer+from utils.enums import CeleryTaskStatefrom workflow_manager.workflow.dto import ExecutionResponse@@ -51,6 +52,11 @@ class DeploymentExecution(views.APIView):file_objs=file_objs,timeout=timeout,)+ if "error" in response and response["error"]:+ return Response(+ {"message": response},+ status=status.HTTP_422_UNPROCESSABLE_ENTITY,+ )return Response({"message": response}, status=status.HTTP_200_OK)@DeploymentHelper.validate_api_key@@ -63,6 +69,14 @@ class DeploymentExecution(views.APIView):response: ExecutionResponse = DeploymentHelper.get_execution_status(execution_id=execution_id)+ if response.execution_status != CeleryTaskState.SUCCESS.value:+ return Response(+ {+ "status": response.execution_status,+ "message": response.result,+ },+ status=status.HTTP_422_UNPROCESSABLE_ENTITY,+ )return Response({"status": response.execution_status, "message": response.result},status=status.HTTP_200_OK,diff --git a/backend/api/deployment_helper.py b/backend/api/deployment_helper.pyindex 8969bdb99..3a484dbc2 100644--- a/backend/api/deployment_helper.py+++ b/backend/api/deployment_helper.py@@ -148,7 +148,7 @@ class DeploymentHelper:str: The complete status endpoint URL."""query_parameters = urlencode({"execution_id": execution_id})- complete_endpoint = f"{api_endpoint}?{query_parameters}"+ complete_endpoint = f"/{api_endpoint}?{query_parameters}"return complete_endpoint@staticmethoddiff --git a/backend/utils/enums.py b/backend/utils/enums.pynew file mode 100644index 000000000..0dcc541a6--- /dev/null+++ b/backend/utils/enums.py@@ -0,0 +1,11 @@+from enum import Enum+++class CeleryTaskState(Enum):+ FAILURE = "FAILURE"+ PENDING = "PENDING"+ RECEIVED = "RECEIVED"+ RETRY = "RETRY"+ REVOKED = "REVOKED"+ STARTED = "STARTED"+ SUCCESS = "SUCCESS"