jadehardouin
commited on
Commit
•
3f6473e
1
Parent(s):
bbc8453
Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,9 @@ import time
|
|
5 |
text = "<h1 style='text-align: center; color: midnightblue; font-size: 30px;'>TCO Comparison Calculator"
|
6 |
text1 = "<h1 style='text-align: center; color: midnightblue; font-size: 20px;'>First solution"
|
7 |
text2 = "<h1 style='text-align: center; color: midnightblue; font-size: 20px;'>Second solution"
|
8 |
-
text3 = "<h1 style='text-align: center; color: midnightblue; font-size: 20px;'>Compute and compare
|
9 |
description=f"""
|
10 |
-
<p>In this demo application, we help you compare different solutions for your AI
|
11 |
<p>First, you'll have to choose the two solutions you'd like to compare. Then, follow the instructions to select your configurations for each solution and we will compute the cost/token accordingly to them. Eventually, both solutions are compared to evaluate which one best suits your needs.</p>
|
12 |
"""
|
13 |
|
@@ -28,7 +28,7 @@ def compute_ratio(tco1, tco2):
|
|
28 |
return f"Error: {str(e)}"
|
29 |
|
30 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
31 |
-
Models: list[models.BaseTCOModel] = [models.OpenAIModel, models.
|
32 |
model_names = [Model().get_name() for Model in Models]
|
33 |
gr.Markdown(value=text)
|
34 |
gr.Markdown(value=description)
|
@@ -37,31 +37,31 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
37 |
with gr.Column():
|
38 |
gr.Markdown(value=text1)
|
39 |
page1 = models.ModelPage(Models)
|
40 |
-
dropdown = gr.Dropdown(model_names, interactive=True, label="
|
41 |
page1.render()
|
42 |
|
43 |
with gr.Column():
|
44 |
gr.Markdown(value=text2)
|
45 |
page2 = models.ModelPage(Models)
|
46 |
-
dropdown2 = gr.Dropdown(model_names, interactive=True, label="
|
47 |
page2.render()
|
48 |
|
49 |
dropdown.change(page1.make_model_visible, inputs=dropdown, outputs=page1.get_all_components())
|
50 |
dropdown2.change(page2.make_model_visible, inputs=dropdown2, outputs=page2.get_all_components())
|
51 |
|
52 |
gr.Markdown(value=text3)
|
53 |
-
compute_tco_btn = gr.Button("Compute
|
54 |
tco1 = gr.State()
|
55 |
tco2 = gr.State()
|
56 |
|
57 |
with gr.Row():
|
58 |
with gr.Column():
|
59 |
-
tco_output = gr.Text("Output 1: ", label="
|
60 |
with gr.Accordion("Open to see the formula", open=False):
|
61 |
tco_formula = gr.Markdown()
|
62 |
|
63 |
with gr.Column():
|
64 |
-
tco_output2 = gr.Text("Output 2: ", label="
|
65 |
with gr.Accordion("Open to see the formula", open=False):
|
66 |
tco_formula2 = gr.Markdown()
|
67 |
|
|
|
5 |
text = "<h1 style='text-align: center; color: midnightblue; font-size: 30px;'>TCO Comparison Calculator"
|
6 |
text1 = "<h1 style='text-align: center; color: midnightblue; font-size: 20px;'>First solution"
|
7 |
text2 = "<h1 style='text-align: center; color: midnightblue; font-size: 20px;'>Second solution"
|
8 |
+
text3 = "<h1 style='text-align: center; color: midnightblue; font-size: 20px;'>Compute and compare cost/token for both solutions"
|
9 |
description=f"""
|
10 |
+
<p>In this demo application, we help you compare different solutions for your AI integration plans, such as Open source or SaaS.</p>
|
11 |
<p>First, you'll have to choose the two solutions you'd like to compare. Then, follow the instructions to select your configurations for each solution and we will compute the cost/token accordingly to them. Eventually, both solutions are compared to evaluate which one best suits your needs.</p>
|
12 |
"""
|
13 |
|
|
|
28 |
return f"Error: {str(e)}"
|
29 |
|
30 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
31 |
+
Models: list[models.BaseTCOModel] = [models.OpenAIModel, models.CohereModel, models.OpenSourceLlama2Model,models.OpenSourceDIY]
|
32 |
model_names = [Model().get_name() for Model in Models]
|
33 |
gr.Markdown(value=text)
|
34 |
gr.Markdown(value=description)
|
|
|
37 |
with gr.Column():
|
38 |
gr.Markdown(value=text1)
|
39 |
page1 = models.ModelPage(Models)
|
40 |
+
dropdown = gr.Dropdown(model_names, interactive=True, label="AI service options")
|
41 |
page1.render()
|
42 |
|
43 |
with gr.Column():
|
44 |
gr.Markdown(value=text2)
|
45 |
page2 = models.ModelPage(Models)
|
46 |
+
dropdown2 = gr.Dropdown(model_names, interactive=True, label="AI service options")
|
47 |
page2.render()
|
48 |
|
49 |
dropdown.change(page1.make_model_visible, inputs=dropdown, outputs=page1.get_all_components())
|
50 |
dropdown2.change(page2.make_model_visible, inputs=dropdown2, outputs=page2.get_all_components())
|
51 |
|
52 |
gr.Markdown(value=text3)
|
53 |
+
compute_tco_btn = gr.Button("Compute cost/token", size="lg")
|
54 |
tco1 = gr.State()
|
55 |
tco2 = gr.State()
|
56 |
|
57 |
with gr.Row():
|
58 |
with gr.Column():
|
59 |
+
tco_output = gr.Text("Output 1: ", label="Cost/token for the first solution")
|
60 |
with gr.Accordion("Open to see the formula", open=False):
|
61 |
tco_formula = gr.Markdown()
|
62 |
|
63 |
with gr.Column():
|
64 |
+
tco_output2 = gr.Text("Output 2: ", label="Cost/token for the second solution")
|
65 |
with gr.Accordion("Open to see the formula", open=False):
|
66 |
tco_formula2 = gr.Markdown()
|
67 |
|