File size: 1,035 Bytes
3c6f21d
9982e81
3c6f21d
9982e81
 
 
 
 
 
 
 
 
3c6f21d
 
9982e81
 
 
 
 
 
 
 
 
3c6f21d
9982e81
3c6f21d
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
from model.anomaly_detector import detect_anomaly_plain_text

def predict(agent_id, weekly_calls, missed_visits, travel_distance, lead_drop_rate):
    input_data = {
        "agent_id": agent_id,
        "weekly_calls": weekly_calls,
        "missed_visits": missed_visits,
        "travel_distance": travel_distance,
        "lead_drop_rate": lead_drop_rate
    }
    return detect_anomaly_plain_text(input_data)

iface = gr.Interface(
    fn=predict,
    inputs=[
        gr.Textbox(label="Agent ID", placeholder="e.g., AG1541"),
        gr.Slider(0, 20, step=1, label="Weekly Calls"),
        gr.Slider(0, 20, step=1, label="Missed Visits"),
        gr.Slider(0, 100, step=1, label="Travel Distance (km)"),
        gr.Slider(0.0, 1.0, step=0.01, label="Lead Drop Rate")
    ],
    outputs=gr.Textbox(label="Analysis Result"),
    title="Agent Behavior Anomaly Detector",
    description="Detects anomalies in agent behavior and provides reason in plain English."
)

if __name__ == "__main__":
    iface.launch()