Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,28 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
from model.anomaly_detector import detect_anomaly
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
iface = gr.Interface(
|
| 14 |
-
fn=
|
| 15 |
-
inputs=
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
title="Agent Behavior Anomaly Detector",
|
| 18 |
-
description="Detects
|
| 19 |
)
|
| 20 |
|
| 21 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from model.anomaly_detector import detect_anomaly_plain_text
|
|
|
|
| 3 |
|
| 4 |
+
def predict(agent_id, weekly_calls, missed_visits, travel_distance, lead_drop_rate):
|
| 5 |
+
input_data = {
|
| 6 |
+
"agent_id": agent_id,
|
| 7 |
+
"weekly_calls": weekly_calls,
|
| 8 |
+
"missed_visits": missed_visits,
|
| 9 |
+
"travel_distance": travel_distance,
|
| 10 |
+
"lead_drop_rate": lead_drop_rate
|
| 11 |
+
}
|
| 12 |
+
return detect_anomaly_plain_text(input_data)
|
| 13 |
|
| 14 |
iface = gr.Interface(
|
| 15 |
+
fn=predict,
|
| 16 |
+
inputs=[
|
| 17 |
+
gr.Textbox(label="Agent ID", placeholder="e.g., AG1541"),
|
| 18 |
+
gr.Slider(0, 20, step=1, label="Weekly Calls"),
|
| 19 |
+
gr.Slider(0, 20, step=1, label="Missed Visits"),
|
| 20 |
+
gr.Slider(0, 100, step=1, label="Travel Distance (km)"),
|
| 21 |
+
gr.Slider(0.0, 1.0, step=0.01, label="Lead Drop Rate")
|
| 22 |
+
],
|
| 23 |
+
outputs=gr.Textbox(label="Analysis Result"),
|
| 24 |
title="Agent Behavior Anomaly Detector",
|
| 25 |
+
description="Detects anomalies in agent behavior and provides reason in plain English."
|
| 26 |
)
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|