mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-23 12:58:18 -05:00
Some logging, error handling
This commit is contained in:
parent
b31d60ea44
commit
71364d73fe
@ -1,6 +1,10 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
logger = logging.getLogger("paperless.ai.client")
|
||||||
|
|
||||||
|
|
||||||
def run_llm_query(prompt: str) -> str:
|
def run_llm_query(prompt: str) -> str:
|
||||||
if settings.LLM_BACKEND == "ollama":
|
if settings.LLM_BACKEND == "ollama":
|
||||||
|
@ -33,12 +33,14 @@ def get_ai_document_classification(document: Document) -> dict:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
logger.debug(f"LLM classification prompt: {prompt}")
|
||||||
result = run_llm_query(prompt)
|
result = run_llm_query(prompt)
|
||||||
|
logger.debug(f"LLM classification result: {result}")
|
||||||
suggestions = parse_llm_classification_response(result)
|
suggestions = parse_llm_classification_response(result)
|
||||||
return suggestions
|
return suggestions or {}
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.error(f"Error during LLM classification: {e}")
|
logger.exception("Error during LLM classification: %s", exc_info=True)
|
||||||
return None
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def parse_llm_classification_response(text: str) -> dict:
|
def parse_llm_classification_response(text: str) -> dict:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user