LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
Health check API for backend & Prompt Sevice (#1048)
harini-venkataramanae00a496bf1c
diff --git a/backend/backend/base_urls.py b/backend/backend/base_urls.pyindex 1d235aad6..3a37717ab 100644--- a/backend/backend/base_urls.py+++ b/backend/backend/base_urls.py@@ -22,4 +22,5 @@ urlpatterns = [f"{settings.API_DEPLOYMENT_PATH_PREFIX}/pipeline/",include("pipeline_v2.public_api_urls"),),+ path("", include("health.urls")),]diff --git a/backend/backend/public_urls_v2.py b/backend/backend/public_urls_v2.pyindex dee9b28df..366fc695f 100644--- a/backend/backend/public_urls_v2.py+++ b/backend/backend/public_urls_v2.py@@ -33,6 +33,8 @@ urlpatterns = [path("flags/", include("feature_flag.urls")),# Pipelinepath("pipeline/", include("pipeline_v2.public_api_urls")),+ # health checks+ path("", include("health.urls")),]if settings.ADMIN_ENABLED:# Admin URLsdiff --git a/backend/backend/settings/base.py b/backend/backend/settings/base.pyindex 025da5eb5..c9614c1dc 100644--- a/backend/backend/settings/base.py+++ b/backend/backend/settings/base.py@@ -224,6 +224,8 @@ SHARED_APPS = ("django_celery_beat",# For additional helper commands"commands",+ # health checks+ "health",)v2_apps = ("migrating.v2",@@ -446,6 +448,8 @@ WHITELISTED_PATHS = [f"/{PATH_PREFIX}{PATH}" for PATH in WHITELISTED_PATHS_LIST]# White lists workflow-api-deployment pathWHITELISTED_PATHS.append(f"/{API_DEPLOYMENT_PATH_PREFIX}")+# Whitelisting health check API+WHITELISTED_PATHS.append("/health")# API Doc Generator Settings# https://drf-yasg.readthedocs.io/en/stable/settings.htmldiff --git a/backend/health/__init__.py b/backend/health/__init__.pynew file mode 100644index 000000000..e69de29bbdiff --git a/backend/health/apps.py b/backend/health/apps.pynew file mode 100644index 000000000..e860540e5--- /dev/null+++ b/backend/health/apps.py@@ -0,0 +1,5 @@+from django.apps import AppConfig+++class HealthConfig(AppConfig):+ name = "health"diff --git a/backend/health/urls.py b/backend/health/urls.pynew file mode 100644index 000000000..7e4143c84--- /dev/null+++ b/backend/health/urls.py@@ -0,0 +1,8 @@+from django.urls import path+from rest_framework.urlpatterns import format_suffix_patterns++from .views import health_check++urlpatterns = format_suffix_patterns(+ [path("health", health_check, name="health-check")]+)diff --git a/backend/health/views.py b/backend/health/views.pynew file mode 100644index 000000000..715b17902--- /dev/null+++ b/backend/health/views.py@@ -0,0 +1,15 @@+import logging++from django.views.decorators.http import require_http_methods+from rest_framework.decorators import api_view+from rest_framework.request import Request+from rest_framework.response import Response++logger = logging.getLogger(__name__)+++@api_view(["GET"])+@require_http_methods(["GET"])+def health_check(request: Request) -> Response:+ logger.debug("Verifying backend health..")+ return Response(status=200)diff --git a/prompt-service/src/unstract/prompt_service/main.py b/prompt-service/src/unstract/prompt_service/main.pyindex 7942ff292..617453b9f 100644--- a/prompt-service/src/unstract/prompt_service/main.py+++ b/prompt-service/src/unstract/prompt_service/main.py@@ -83,6 +83,11 @@ def authentication_middleware(func: Any) -> Any:return wrapper[email protected]("/health", methods=["GET"], endpoint="health_check")+def health_check() -> str:+ return "OK"++@app.route("/answer-prompt",endpoint="answer_prompt",