Sovereign AI Ecosystem

ai_core/views.py [chapter] deterministic

import json from django.http import JsonResponse from django.views.decorators.csrf import csrf_exempt from django.utils.decorators import method_decorator from rest_framework.decorators import api_vie

import json from django.http import JsonResponse from django.views.decorators.csrf import csrf_exempt from django.utils.decorators import method_decorator from rest_framework.decorators import api_view, permission_classes from rest_framework.permissions import AllowAny from .services import classify_message @method_decorator(csrf_exempt, name='dispatch') @api_view(["POST"]) @permission_classes([AllowAny]) def classify_and_route(request): if request.method != "POST": return JsonResponse({"error": "Only POST allowed"}, status=405) try: data = json.loads(request.body) user_message = data.get("message", "") except (json.JSONDecodeError, ValueError): return JsonResponse({"error": "Invalid JSON"}, status=400) category = classify_message(user_message)["category"]

Sources

Sovereign AI: Building Local-First Intelligent Systems (book) · source

Related (0)

No recorded relationships.

← all Book