Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import pandas as pd | |
| def calculate(daily_queries, cloud_cost, days): | |
| cloud_total = (daily_queries / 1000) * cloud_cost * days | |
| device_total = 0.50 | |
| savings = cloud_total - device_total | |
| data = pd.DataFrame([ | |
| {"Approach": "Cloud API", "Cost ($)": round(cloud_total, 2)}, | |
| {"Approach": "dispatchAI On-Device", "Cost ($)": round(device_total, 2)}, | |
| ]) | |
| return data, f"Annual savings: ${savings:,.2f} ({(savings/cloud_total*100):.0f}%)" if cloud_total > 0 else "N/A" | |
| with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), title="Cost Visualizer") as demo: | |
| gr.Markdown("# 💰 dispatchAI Cost Savings Visualizer") | |
| with gr.Row(): | |
| dq = gr.Slider(100, 100000, value=10000, step=100, label="Daily Queries") | |
| cc = gr.Slider(0.1, 10, value=0.5, step=0.1, label="Cloud $/1K queries") | |
| dy = gr.Slider(30, 3650, value=365, step=30, label="Days") | |
| btn = gr.Button("Calculate", variant="primary") | |
| chart = gr.BarPlot(x="Approach", y="Cost ($)", title="Cost Comparison", height=300) | |
| text = gr.Markdown("") | |
| btn.click(fn=calculate, inputs=[dq, cc, dy], outputs=[chart, text]) | |
| gr.Markdown("---\n🚀 [dispatchAI](https://huggingface.co/dispatchAI)") | |
| demo.launch() | |