diff --git a/django_project.zip b/django_project.zip new file mode 100644 index 0000000..9886931 Binary files /dev/null and b/django_project.zip differ diff --git a/pxy_agents_coral/urls.py b/pxy_agents_coral/urls.py index 24ee5f9..f1d6722 100644 --- a/pxy_agents_coral/urls.py +++ b/pxy_agents_coral/urls.py @@ -1,10 +1,11 @@ from django.urls import path from .formatters import format_sami, format_sites -from .views import agents_list, agents_execute +from .views import agents_list, agents_execute, agents_health urlpatterns = [ path("api/agents/list", agents_list, name="agents_list"), path("api/agents/execute", agents_execute, name="agents_execute"), path("api/agents/format/sami", format_sami, name="agents_format_sami"), path("api/agents/format/sites", format_sites, name="agents_format_sites"), + path("api/agents/health", agents_health), ] diff --git a/pxy_agents_coral/views.py b/pxy_agents_coral/views.py index a10e30d..1ca8db5 100644 --- a/pxy_agents_coral/views.py +++ b/pxy_agents_coral/views.py @@ -231,3 +231,28 @@ def format_sites(request: HttpRequest): except Exception: pass return JsonResponse(data, status=status, safe=False) + +# pxy_agents_coral/views.py (add this function) +from django.http import JsonResponse +from django.conf import settings +import requests + +def agents_health(request): + data = { + "service": "polisplexity-agents", + "version": "1.0.0", + "spec_version": settings.SPEC_VERSION if hasattr(settings, "SPEC_VERSION") else "0.1.0", + "checks": {}, + } + try: + r1 = requests.get(f"{request.build_absolute_uri('/')[:-1]}/api/sami/health", timeout=3) + data["checks"]["sami"] = {"ok": r1.status_code == 200} + except Exception as e: + data["checks"]["sami"] = {"ok": False, "error": str(e)} + try: + r2 = requests.get(f"{request.build_absolute_uri('/')[:-1]}/api/sites/health", timeout=3) + data["checks"]["sites"] = {"ok": r2.status_code == 200} + except Exception as e: + data["checks"]["sites"] = {"ok": False, "error": str(e)} + return JsonResponse(data) +