LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
Conflict fix and additional case for connection error
Athulfc395a16be64
diff --cc backend/adapter_processor/adapter_processor.pyindex 95478cf5c,b44088a64..92b246b93--- a/backend/adapter_processor/adapter_processor.py+++ b/backend/adapter_processor/adapter_processor.py@@@ -120,13 -120,11 +120,13 @@@ class AdapterProcessorlogger.info(f"{adapter_id} test result: {test_result}")return test_resultexcept ActiveKeyNotFound:- raise+ raise ActiveKeyNotFound()+ except InvalidRequest as e:+ raise InvalidRequest(str(e.detail))except Exception as e:-- logger.error(f"Error while testing {adapter_id}: {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:diff --cc backend/adapter_processor/views.pyindex dab0dce59,8b7144371..cc82a98c7--- a/backend/adapter_processor/views.py+++ b/backend/adapter_processor/views.py@@@ -97,20 -97,13 +97,20 @@@ class AdapterViewSet(GenericViewSet)adapter_metadata[AdapterKeys.ADAPTER_TYPE] = serializer.validated_data.get(AdapterKeys.ADAPTER_TYPE)- test_result = AdapterProcessor.test_adapter(- adapter_id=adapter_id, adapter_metadata=adapter_metadata- )- return Response(- {AdapterKeys.IS_VALID: test_result},- status=status.HTTP_200_OK,- )+ try:+ test_result = AdapterProcessor.test_adapter(+ adapter_id=adapter_id, adapter_metadata=adapter_metadata+ )+ return Response(+ {AdapterKeys.IS_VALID: test_result},+ status=status.HTTP_200_OK,+ )+ except Exception as e:- logger.error(f"Error testing adapter: {str(e)}")++ logger.error(f"Error testing adapter : {str(e)}")+ return Response(+ {"message": str(e)},+ status=status.HTTP_401_UNAUTHORIZED,+ )class AdapterInstanceViewSet(ModelViewSet):diff --cc backend/backend/exceptions.pyindex cf770a477,f95597670..0e017f862--- a/backend/backend/exceptions.py+++ b/backend/backend/exceptions.py@@@ -18,17 -15,10 +18,25 @@@ class UnstractBaseException(APIExceptiocore_err: Optional[ConnectorBaseException] = None,**kwargs: Any,) -> None:-- if detail is None:-- detail = self.default_detail-- if 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_message++ if detail and "Name or service not known" in str(detail):++ detail = (++ "Failed to establish a new connection: "++ "Name or service not known"++ )++ else:++ if detail is None:++ detail = self.default_detail++ if 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["message"] or error_object["error"]["message"]++ )++ detail = err_messagesuper().__init__(detail=detail, **kwargs)self._core_err = core_errdiff --cc frontend/src/helpers/GetStaticData.jsindex fb72d9fce,be060d76a..7b683313b--- a/frontend/src/helpers/GetStaticData.js+++ b/frontend/src/helpers/GetStaticData.js@@@ -255,11 -259,62 +259,62 @@@ const handleException = (err, errMessagerrMessage ||"Something went wrong",};- } else {- return {- type: "error",- content: errMessage || err?.message,- };+ }++ return {+ type: "error",- content: err?.message || errMessage,++ content: errMessage || err?.message,+ };+ };++ const base64toBlob = (data) => {+ const bytes = atob(data);+ let length = bytes.length;+ const out = new Uint8Array(length);++ while (length--) {+ out[length] = bytes.charCodeAt(length);+ }++ return new Blob([out], { type: "application/pdf" });+ };++ const removeFileExtension = (fileName) => {+ if (!fileName) {+ return "";+ }+ const fileNameSplit = fileName.split(".");+ const fileNameSplitLength = fileNameSplit.length;+ const modFileName = fileNameSplit.slice(0, fileNameSplitLength - 1);+ return modFileName.join(".");+ };++ const isJson = (text) => {+ try {+ if (typeof text === "object") {+ return true;+ }++ if (typeof text === "string") {+ const json = JSON.parse(text);+ return typeof json === "object";+ }+ return false;+ } catch (err) {+ return false;+ }+ };++ const displayPromptResult = (output) => {+ try {+ if (isJson(output)) {+ return JSON.stringify(JSON.parse(output), null, 4);+ }++ const outputParsed = JSON.parse(output);+ return outputParsed;+ } catch (err) {+ return output;}};