Add logging for tracing errors.

main
KKlochko 1 month ago
parent 12475d8d0a
commit be811ddb59
Signed by: KKlochko
GPG Key ID: 572ECCD219BBA91B

@ -5,12 +5,15 @@ from typing import List, Optional, Union, Dict, Any, Tuple
from contextlib import asynccontextmanager
import os
import torch
import logging
from gliner import GLiNER
from .models import *
from .helpers import *
# Global model instance
model = None
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
@asynccontextmanager
@ -113,6 +116,7 @@ async def general_extraction(request: GeneralRequest):
return {"outputs": results[0]}
except Exception as e:
logger.error(f"Error in general: {str(e)}", exc_info=True)
handle_error(e)
@ -285,6 +289,7 @@ async def relation_extraction(request: RelationExtractionRequest):
return {"outputs": results[0]}
except Exception as e:
logger.error(f"Error in relation extraction: {str(e)}", exc_info=True)
handle_error(e)
@ -324,6 +329,7 @@ async def summarization(request: SummarizationRequest):
return {"outputs": results[0]}
except Exception as e:
logger.error(f"Error in summarization: {str(e)}", exc_info=True)
handle_error(e)

Loading…
Cancel
Save