aman-s-affinsys's picture
feat: added logging
0c746c9
raw
history blame contribute delete
733 Bytes
from utils.commons import setup_logging
logger = setup_logging("predictor.log")
class Predictor:
def __init__(self, pipeline):
self.pipeline = pipeline
def predict(self, text):
"""Make prediction"""
try:
logger.info(f"Making prediction for text: {text}")
preds_list = self.pipeline(text)
best_pred = max(preds_list[0], key=lambda x: x["score"])
logger.info(f"Prediction successful: {best_pred}")
return {
"predicted_intent": best_pred["label"],
"confidence": best_pred["score"]
}
except Exception as e:
logger.error(f"Error during prediction: {e}")
raise