Spaces:
Sleeping
Sleeping
| 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() | |