Update ai_classifier.py

This commit is contained in:
shamoon 2025-07-15 14:42:56 -07:00
parent 3583470856
commit da2ac19193
No known key found for this signature in database

View File

@ -1,4 +1,3 @@
import json
import logging import logging
from django.contrib.auth.models import User from django.contrib.auth.models import User
@ -76,18 +75,14 @@ def get_context_for_document(
def parse_ai_response(raw: dict) -> dict: def parse_ai_response(raw: dict) -> dict:
try: return {
return { "title": raw.get("title", ""),
"title": raw.get("title", ""), "tags": raw.get("tags", []),
"tags": raw.get("tags", []), "correspondents": raw.get("correspondents", []),
"correspondents": raw.get("correspondents", []), "document_types": raw.get("document_types", []),
"document_types": raw.get("document_types", []), "storage_paths": raw.get("storage_paths", []),
"storage_paths": raw.get("storage_paths", []), "dates": raw.get("dates", []),
"dates": raw.get("dates", []), }
}
except (ValueError, json.JSONDecodeError):
logger.exception("Failed to parse AI response")
return {}
def get_ai_document_classification( def get_ai_document_classification(