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