LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
Adapter error messages updated
Athul2064d49fb539
diff --git a/backend/adapter_processor/adapter_processor.py b/backend/adapter_processor/adapter_processor.pyindex 07650e251..95478cf5c 100644--- a/backend/adapter_processor/adapter_processor.py+++ b/backend/adapter_processor/adapter_processor.py@@ -126,11 +126,11 @@ class AdapterProcessor:except Exception as e:logger.error(f"Error while testing {adapter_id}: {e}")if isinstance(e, AdapterError):- raise TestAdapterInputException(str(e.message))+ raise TestAdapterInputException(e)elif isinstance(e, ActiveKeyNotFound):raise eelse:- raise TestAdapterException()+ raise TestAdapterException(str(e))@staticmethoddef __fetch_adapters_by_key_value(key: str, value: Any) -> Adapter:diff --git a/backend/adapter_processor/exceptions.py b/backend/adapter_processor/exceptions.pyindex 2feb8a298..5634a9017 100644--- a/backend/adapter_processor/exceptions.py+++ b/backend/adapter_processor/exceptions.py@@ -1,6 +1,7 @@-from backend.exceptions import UnstractBaseExceptionfrom rest_framework.exceptions import APIException+from backend.exceptions import UnstractBaseException+class IdIsMandatory(APIException):status_code = 400@@ -41,7 +42,7 @@ class UniqueConstraintViolation(APIException):class TestAdapterException(APIException):- status_code = 500+ status_code = 401default_detail = "Error while testing adapter."diff --git a/backend/adapter_processor/views.py b/backend/adapter_processor/views.pyindex 670b5d561..ab2e35450 100644--- a/backend/adapter_processor/views.py+++ b/backend/adapter_processor/views.py@@ -105,16 +105,13 @@ class AdapterViewSet(GenericViewSet):status=status.HTTP_200_OK,)except Exception as e:- if str(e).find("invalid_api_key") != -1:- return Response(- {"message": "Incorrect API key provided."},- status=status.HTTP_401_UNAUTHORIZED,- )+ logger.error(f"Error testing adapter: {str(e)}")return Response(- {AdapterKeys.IS_VALID: False},- status=status.HTTP_500_INTERNAL_SERVER_ERROR,+ {"message": str(e)},+ status=status.HTTP_401_UNAUTHORIZED,)+class AdapterInstanceViewSet(ModelViewSet):queryset = AdapterInstance.objects.all()diff --git a/backend/backend/exceptions.py b/backend/backend/exceptions.pyindex f95597670..cf770a477 100644--- a/backend/backend/exceptions.py+++ b/backend/backend/exceptions.py@@ -1,8 +1,11 @@+import astfrom typing import Any, Optionalfrom rest_framework.exceptions import APIExceptionfrom rest_framework.response import Responsefrom rest_framework.views import exception_handler+from unstract.adapters.exceptions import AdapterError+from unstract.connectors.exceptions import ConnectorBaseException@@ -11,7 +14,7 @@ class UnstractBaseException(APIException):def __init__(self,- detail: Optional[str] = None,+ detail: Optional[AdapterError] = None,core_err: Optional[ConnectorBaseException] = None,**kwargs: Any,) -> None:@@ -19,6 +22,13 @@ class UnstractBaseException(APIException):detail = self.default_detailif core_err and core_err.user_message:detail = core_err.user_message+ if detail and detail.message:+ message = detail.message+ start = message.find("{")+ dict_str = message[start:]+ error_object = ast.literal_eval(dict_str)+ err_message = error_object["error"]["message"]+ detail = err_messagesuper().__init__(detail=detail, **kwargs)self._core_err = core_errdiff --git a/frontend/src/components/input-output/configure-ds/ConfigureDs.jsx b/frontend/src/components/input-output/configure-ds/ConfigureDs.jsxindex 60c2f8cd6..255229513 100644--- a/frontend/src/components/input-output/configure-ds/ConfigureDs.jsx+++ b/frontend/src/components/input-output/configure-ds/ConfigureDs.jsx@@ -128,7 +128,9 @@ function ConfigureDs({}}).catch((err) => {- setAlertDetails(handleException(err, "Test connection failed"));+ const TestErrorMessage =+ err?.response?.data?.message || "Test connection failed";+ setAlertDetails(handleException(err, TestErrorMessage));}).finally(() => {setIsTcLoading(false);diff --git a/frontend/src/helpers/GetStaticData.js b/frontend/src/helpers/GetStaticData.jsindex 996ed44bc..fb72d9fce 100644--- a/frontend/src/helpers/GetStaticData.js+++ b/frontend/src/helpers/GetStaticData.js@@ -258,7 +258,7 @@ const handleException = (err, errMessage) => {} else {return {type: "error",- content: err?.message,+ content: errMessage || err?.message,};}};diff --git a/tools/translate/src/main.py b/tools/translate/src/main.pyindex 3e18285b4..a415d2a83 100644--- a/tools/translate/src/main.py+++ b/tools/translate/src/main.py@@ -6,7 +6,7 @@ from typing import Anyfrom constants import EnvKey, GoogleTranslateKey, StaticDatafrom google.auth.transport import requests as google_requests-from google.cloud import translate_v2 as translate # type: ignore+from google.cloud import translate_v2 as translatefrom google.oauth2.service_account import Credentialsfrom unstract.sdk.cache import ToolCachefrom unstract.sdk.constants import LogState, MetadataKey, ToolEnvdiff --git a/unstract/connectors/src/unstract/connectors/connectorkit.py b/unstract/connectors/src/unstract/connectors/connectorkit.pyindex aba55e9a2..e53ad43e8 100644--- a/unstract/connectors/src/unstract/connectors/connectorkit.py+++ b/unstract/connectors/src/unstract/connectors/connectorkit.py@@ -1,7 +1,7 @@import loggingfrom typing import Any, Optional-from unstract.connectors import ConnectorDict+from unstract.connectors import ConnectorDict # type: ignorefrom unstract.connectors.base import UnstractConnectorfrom unstract.connectors.constants import Commonfrom unstract.connectors.databases import connectors as db_connectorsdiff --git a/unstract/connectors/src/unstract/connectors/databases/__init__.py b/unstract/connectors/src/unstract/connectors/databases/__init__.pyindex 402e69e66..fbdc6050e 100644--- a/unstract/connectors/src/unstract/connectors/databases/__init__.py+++ b/unstract/connectors/src/unstract/connectors/databases/__init__.py@@ -1,4 +1,4 @@-from unstract.connectors import ConnectorDict+from unstract.connectors import ConnectorDict # type: ignorefrom unstract.connectors.databases.register import register_connectorsconnectors: ConnectorDict = {}diff --git a/unstract/connectors/src/unstract/connectors/filesystems/__init__.py b/unstract/connectors/src/unstract/connectors/filesystems/__init__.pyindex 9cdfe1083..4826bdb25 100644--- a/unstract/connectors/src/unstract/connectors/filesystems/__init__.py+++ b/unstract/connectors/src/unstract/connectors/filesystems/__init__.py@@ -1,4 +1,4 @@-from unstract.connectors import ConnectorDict+from unstract.connectors import ConnectorDict # type: ignorefrom unstract.connectors.filesystems.register import register_connectorsconnectors: ConnectorDict = {}