batch-analyse / main.py
pjxcharya's picture
Moved severity classifier to utils and exposed endpoint
62c9986
raw
history blame contribute delete
859 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
from typing import List
from core.preprocess import preprocess_text_list
from core.analyzer import analyze_feedback
from utils.counter import aggregate_results
# ✅ NEW import (moved from severity_service)
from utils.severity_classifier import classify_issues, InputPayload
app = FastAPI(title="Batch Sentiment + Severity Classifier")
class FeedbackBatch(BaseModel):
texts: List[str]
@app.post("/analyze-batch")
def analyze_batch_endpoint(batch: FeedbackBatch):
cleaned_texts = preprocess_text_list(batch.texts)
results = [analyze_feedback(text) for text in cleaned_texts if analyze_feedback(text)]
summary = aggregate_results(results)
return summary
@app.post("/classify-severity")
def classify_severity_endpoint(payload: InputPayload):
return classify_issues(payload)