Spaces:
Runtime error
Runtime error
from fastapi import APIRouter, HTTPException | |
from pydantic import BaseModel | |
from ..models.nlp_model import classify_text # Relative import | |
router = APIRouter() | |
class SMSInput(BaseModel): | |
text: str | |
async def predict_sms(input: SMSInput): | |
try: | |
prediction = classify_text(input.text) | |
return {"text": input.text, "prediction": prediction} | |
except Exception as e: | |
raise HTTPException(status_code=500, detail="Model prediction error.") | |