import gradio as gr
from predict_utils import load_model_and_thresholds, predict

model, tokenizer, thresholds = load_model_and_thresholds()

def classify(text):
    return predict(text, model, tokenizer, thresholds)

gr.Interface(
    fn=classify,
    inputs=gr.Textbox(lines=4, placeholder="Masukkan teks cyberbullying..."),
    outputs=gr.Label(label="Prediksi Cyberbullying", num_top_classes=12),
    title="💬 Deteksi Cyberbullying Multi-Label 🇮🇩",
    description="Model IndoBERT + BiLSTM dengan threshold ROC-AUC. Menampilkan 12 label klasifikasi multi-label teks bahasa Indonesia.",
    examples=[
        ["Dasar kamu goblok dan gak punya otak!"],
        ["Cewek seperti itu emang pantas dihina."],
        ["Pribumi kampungan gak punya budaya!"]
    ]
).launch()