mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-16 17:25:11 -05:00
Update ai_classifier.py
This commit is contained in:
parent
3583470856
commit
da2ac19193
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user