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