import gradio as gr from predict_impulse import predict_impulse def run(category, amount, payment_method, day): result = predict_impulse( category=category, amount=amount, payment_method=payment_method, day=day ) if result["impulsive"]: return f"🚨 Impulsive Spend Detected\nConfidence: {result['confidence']}" else: return f"✅ Normal Spend\nConfidence: {result['confidence']}" demo = gr.Interface( fn=run, inputs=[ gr.Dropdown( ["Dining", "Entertainment", "Subscriptions", "Groceries", "Transport", "Utilities"], label="Category" ), gr.Number(label="Amount"), gr.Dropdown( ["Cash", "Debit Card", "Credit Card", "Bank Transfer"], label="Payment Method" ), gr.Dropdown( ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], label="Day of Week" ) ], outputs=gr.Textbox(label="Impulse Analysis"), title="Sensei Budget AI – Impulse Detection", description="Detects impulsive spending behavior using a trained ML model + Opik observability." ) demo.launch()