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