Spaces:
Runtime error
Runtime error
Commit
·
e0e93c4
1
Parent(s):
f5562e5
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def calculate_tco(model_choice, vm_rental_choice):
|
| 4 |
+
VM_cost_per_hour=3.6730
|
| 5 |
+
tokens_per_request = 64
|
| 6 |
+
|
| 7 |
+
if model_choice == "Llama-2-7B":
|
| 8 |
+
tokens_per_second=694.38
|
| 9 |
+
|
| 10 |
+
elif model_choice == "Llama-2-13B":
|
| 11 |
+
tokens_per_second=1000
|
| 12 |
+
|
| 13 |
+
elif model_choice == "Llama-2-70B":
|
| 14 |
+
tokens_per_second=10000
|
| 15 |
+
|
| 16 |
+
if vm_rental_option == "1 month" or "3 months" or "6 months":
|
| 17 |
+
reduction = 0
|
| 18 |
+
|
| 19 |
+
elif vm_rental_option == "1 year":
|
| 20 |
+
reduction = 0.34
|
| 21 |
+
|
| 22 |
+
elif vm_rental_option == "3 years":
|
| 23 |
+
reduction = 0.62
|
| 24 |
+
|
| 25 |
+
homemade_cost_per_request = VM_cost_per_hour * (1 - reduction) * tokens_per_request / (tokens_per_second * 3600) #* 0.8 * 0.5
|
| 26 |
+
saas_cost_per_request = 0.018 * tokens_per_request
|
| 27 |
+
|
| 28 |
+
output = f"Cost/request with a plan for {vm_rental_choice} using:\n"
|
| 29 |
+
output += f"- SaaS solution from OpenAI: ${saas_cost_per_request:.5f}\n"
|
| 30 |
+
output += f"- Home-made solution with the model {model_choice}: ${homemade_cost_per_request:.5f}"
|
| 31 |
+
return output
|
| 32 |
+
|
| 33 |
+
models = ["Llama-2-7B", "Llama-2-13B", "Llama-2-70B"]
|
| 34 |
+
vm_rental_option = ["1 month", "3 months", "6 months", "1 year", "3 years"]
|
| 35 |
+
|
| 36 |
+
iface = gr.Interface(
|
| 37 |
+
fn=calculate_tco,
|
| 38 |
+
inputs=[gr.inputs.Dropdown(models, label="Select AI Model"),
|
| 39 |
+
gr.inputs.Dropdown(vm_rental_option, label="Select VM Rental Duration")],
|
| 40 |
+
outputs=gr.outputs.Textbox()
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
iface.launch()
|