Update app.py
Browse files
app.py
CHANGED
@@ -205,22 +205,35 @@ with gr.Blocks(title="Cloud Cost Estimator", theme=gr.themes.Soft(primary_hue="i
|
|
205 |
gr.HTML('<h1 style="text-align:center;">Cloud Cost Estimator</h1>')
|
206 |
with gr.Row():
|
207 |
with gr.Column(scale=1):
|
208 |
-
compute_hours = gr.Slider(label="Compute Hours per Month", minimum=1, maximum=
|
209 |
-
tokens_per_month = gr.Slider(label="Tokens per Month (M)", minimum=1, maximum=
|
210 |
-
input_ratio = gr.Slider(label="Input Ratio (%)", minimum=10, maximum=
|
211 |
-
api_calls = gr.Slider(label="API Calls per Month", minimum=100, maximum=
|
212 |
model_size = gr.Dropdown(label="Model Size", choices=list(model_sizes.keys()), value="Medium (13B parameters)")
|
213 |
storage_gb = gr.Slider(label="Storage (GB)", minimum=10, maximum=1000, value=100)
|
214 |
reserved_instances = gr.Checkbox(label="Reserved Instances", value=False)
|
215 |
spot_instances = gr.Checkbox(label="Spot Instances", value=False)
|
216 |
multi_year_commitment = gr.Radio(label="Commitment Period (years)", choices=["1","3"], value="1")
|
217 |
-
submit = gr.Button("Calculate Costs")
|
218 |
with gr.Column(scale=2):
|
219 |
out_html = gr.HTML()
|
220 |
out_plot = gr.Plot()
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
|
226 |
demo.launch()
|
|
|
205 |
gr.HTML('<h1 style="text-align:center;">Cloud Cost Estimator</h1>')
|
206 |
with gr.Row():
|
207 |
with gr.Column(scale=1):
|
208 |
+
compute_hours = gr.Slider(label="Compute Hours per Month", minimum=1, maximum=300, value=50)
|
209 |
+
tokens_per_month = gr.Slider(label="Tokens per Month (M)", minimum=1, maximum=200, value=5)
|
210 |
+
input_ratio = gr.Slider(label="Input Ratio (%)", minimum=10, maximum=70, value=25)
|
211 |
+
api_calls = gr.Slider(label="API Calls per Month", minimum=100, maximum=100000, value=5000, step=100)
|
212 |
model_size = gr.Dropdown(label="Model Size", choices=list(model_sizes.keys()), value="Medium (13B parameters)")
|
213 |
storage_gb = gr.Slider(label="Storage (GB)", minimum=10, maximum=1000, value=100)
|
214 |
reserved_instances = gr.Checkbox(label="Reserved Instances", value=False)
|
215 |
spot_instances = gr.Checkbox(label="Spot Instances", value=False)
|
216 |
multi_year_commitment = gr.Radio(label="Commitment Period (years)", choices=["1","3"], value="1")
|
|
|
217 |
with gr.Column(scale=2):
|
218 |
out_html = gr.HTML()
|
219 |
out_plot = gr.Plot()
|
220 |
+
|
221 |
+
# Automatic calculation function
|
222 |
+
def auto_calculate():
|
223 |
+
html, plot = generate_cost_comparison(
|
224 |
+
compute_hours.value, tokens_per_month.value, input_ratio.value,
|
225 |
+
api_calls.value, model_size.value, storage_gb.value,
|
226 |
+
reserved_instances.value, spot_instances.value, multi_year_commitment.value
|
227 |
+
)
|
228 |
+
return html, plot
|
229 |
+
|
230 |
+
# Initial calculation
|
231 |
+
demo.load(auto_calculate, [], [out_html, out_plot])
|
232 |
+
|
233 |
+
# Add event listeners for automatic recalculation
|
234 |
+
for input_component in [compute_hours, tokens_per_month, input_ratio, api_calls,
|
235 |
+
model_size, storage_gb, reserved_instances,
|
236 |
+
spot_instances, multi_year_commitment]:
|
237 |
+
input_component.change(auto_calculate, [], [out_html, out_plot])
|
238 |
|
239 |
demo.launch()
|