jadehardouin commited on
Commit
2d9906b
1 Parent(s): 73d3fc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -190
app.py CHANGED
@@ -1,11 +1,16 @@
1
  import gradio as gr
 
2
 
3
  text = "<h1 style='text-align: center; color: blue; font-size: 30px;'>TCO Comparison Calculator"
4
  text1 = "<h1 style='text-align: center; color: blue; font-size: 20px;'>First solution"
5
  text2 = "<h1 style='text-align: center; color: blue; font-size: 20px;'>Second solution"
6
  text3 = "<h1 style='text-align: center; color: blue; font-size: 25px;'>Comparison"
 
7
 
8
- def calculate_tco(model_choice, vm_rental_choice):
 
 
 
9
  VM_cost_per_hour=3.6730 #at Azure for the basic pay as you go option
10
  maxed_out = 0.8 #percentage of time the VM is maxed out
11
  used = 0.5 #percentage of time the VM is used
@@ -31,11 +36,10 @@ def calculate_tco(model_choice, vm_rental_choice):
31
 
32
  homemade_cost_per_token = VM_cost_per_hour * (1 - reduction) / (tokens_per_second * 3600 * maxed_out * used)
33
  homemade_cost_per_request = tokens_per_request * homemade_cost_per_token
 
 
34
 
35
- output = f"In a situation of a {vm_rental_choice} plan, using an Home-made solution with the open-source model {model_choice}: \ncost per request = ${homemade_cost_per_request:.7f}"
36
- return output
37
-
38
- def calculate_tco_2(model_provider, context):
39
  tokens_per_request = 64
40
 
41
  if model_provider == "OpenAI":
@@ -45,7 +49,8 @@ def calculate_tco_2(model_provider, context):
45
  elif context == "16K context" :
46
  saas_cost_per_token = 0.0007
47
  saas_cost_per_request = saas_cost_per_token * tokens_per_request
48
- return f"When renting services from {model_provider} for a SaaS solution, specifying a {context}, you'll get: \ncost per request = ${saas_cost_per_request:.7f}"
 
49
 
50
  def extract_cost_from_text(text):
51
  try:
@@ -74,23 +79,32 @@ def compare(cost_text1, cost_text2):
74
  except ValueError as e:
75
  return f"Error: {str(e)}"
76
 
 
 
 
 
 
 
 
 
 
77
  description=f"""
78
  <p>In this demo application, we help you compare different solutions for your AI incorporation plans, such as open-source or SaaS.</p>
79
- <p>First, you'll have to choose the two options you'd like to compare. Then, follow the instructions to select your configurations for each option and we will compute the cost/request accordingly to them. Eventually, you can compare both solutions to evaluate which one best suits your needs, in the short or long term.</p>
80
  """
81
  description1=f"""
82
- <p>This interface provides you with the cost per token you get using the open-source solution, based on the model you choose to use and how long you're planning to use it.</p>
83
  <p>The selected prices for a Virtual Machine rental come from Azure's VM rental plans, which can offer reductions for long-term reserved usage.</p>
84
- <p>To compute this cost per token, some adjustments were chosen: the VM is an A100 40GB, supposedly maxed out at 80% and utilized 50% of the time in a full day. Plus, the number of tokens per request was set to 64.</p>
85
  <p>To see the formula used to compute the cost/request, check the box just below!</p>
86
  """
87
  description2=f"""
88
- <p>This interface provides you with the cost per token resulting from the AI model provider you choose and the number of tokens you select for context, which the model will take into account when processing input texts.</p>
89
- <p>To compute this cost per token, some adjustments were chosen: the number of tokensper request was set to 64.</p>
90
  <p>To see the formula used to compute the cost/request, check the box just below!</p>
91
  """
92
  description3=f"""
93
- <p>This interface compares the cost per token for the two solutions you selected and gives you an insight of whether a solution is more valuable in the long term.</p>
94
  """
95
 
96
  models = ["Llama-2-7B", "Llama-2-13B", "Llama-2-70B"]
@@ -98,18 +112,20 @@ vm_rental_choice = ["pay as you go", "1 year reserved", "3 years reserved"]
98
  model_provider = ["OpenAI"]
99
  context = ["4K context", "16K context"]
100
  error_box = gr.Textbox(label="Error", visible=False)
101
- bool_diy = False
102
- bool_saas = False
103
 
104
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
105
  gr.Markdown(value=text)
106
  gr.Markdown(value=description)
107
 
 
 
 
 
 
108
  with gr.Row():
109
- with gr.Column(scale=2):
110
 
111
- solution_selection = gr.Dropdown(["SaaS", "Home-made"], label="Select a Solution")
112
- submit_btn = gr.Button("Submit")
113
 
114
  with gr.Row(visible=False) as title_column:
115
  gr.Markdown(value=text1)
@@ -117,108 +133,48 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
117
  with gr.Row(visible=False) as text_diy_column:
118
  gr.Markdown(description1)
119
 
120
- with gr.Row(visible=False) as see_formula_diy:
121
- formula_diy_btn = gr.Checkbox(label="See formula", value=False)
122
- with gr.Row(visible=False) as formula_diy:
123
- gr.Markdown(
124
- r"$ homemade\_cost\_per\_request = \frac{tokens\_per\_request \times VM\_cost\_per\_hour \times (1 - reduction)}{tokens\_per\_second \times 3600 \times maxed\_out \times used}$"
125
- )
126
- def submit_formula_diy(formula_diy_btn):
127
- if formula_diy_btn:
128
- return{
129
- formula_diy: gr.update(visible=True),
130
- }
131
- else:
132
- return{
133
- formula_diy: gr.update(visible=False),
134
- }
135
-
136
- formula_diy_btn.select(
137
- submit_formula_diy,
138
- [formula_diy_btn],
139
- [formula_diy]
140
- )
141
-
142
  with gr.Row(visible=False) as input_diy_column:
143
- inp = gr.Dropdown(models, label="Select an AI Model")
144
- inp2 = gr.Dropdown(vm_rental_choice, label="Select a VM Rental Plan")
145
-
146
- with gr.Row(visible=False) as output_diy_column:
147
- out = gr.Textbox(label="Cost/request")
148
- btn = gr.Button("Compute the cost/request")
149
- btn.click(fn=calculate_tco, inputs=[inp, inp2], outputs=out)
150
 
151
  with gr.Row(visible=False) as text_saas_column:
152
  gr.Markdown(description2)
153
 
154
- with gr.Row(visible=False) as see_formula_saas:
155
- formula_saas_btn = gr.Checkbox(label="See formula", value=False)
156
- with gr.Row(visible=False) as formula_saas:
157
- gr.Markdown(
158
- r"$ saas\_cost\_per\_request = saas\_cost\_per\_token \times tokens\_per\_request$"
159
- )
160
- def submit_formula_diy(formula_saas_btn):
161
- if formula_saas_btn:
162
- return{
163
- formula_saas: gr.update(visible=True),
164
- }
165
- else:
166
- return{
167
- formula_saas: gr.update(visible=False),
168
- }
169
-
170
- formula_saas_btn.select(
171
- submit_formula_diy,
172
- [formula_saas_btn],
173
- [formula_saas]
174
- )
175
-
176
  with gr.Row(visible=False) as input_saas_column:
177
  model_provider_inp = gr.Dropdown(model_provider, label="Model Provider")
178
  context_inp = gr.Dropdown(context, label="Context")
179
-
180
- with gr.Row(visible=False) as output_saas_column:
181
- out_2 = gr.Textbox(label="Cost/request")
182
- btn_2 = gr.Button("Compute the cost/request")
183
- btn_2.click(fn=calculate_tco_2, inputs=[model_provider_inp, context_inp], outputs=out_2)
184
-
185
  def submit(solution_selection):
186
- if solution_selection == "Home-made":
187
  return {
188
- see_formula_diy: gr.update(visible=True),
189
  title_column: gr.update(visible=True),
190
  text_diy_column: gr.update(visible=True),
191
  input_diy_column: gr.update(visible=True),
192
- output_diy_column: gr.update(visible=True),
193
- see_formula_saas: gr.update(visible=False),
194
  text_saas_column: gr.update(visible=False),
195
  input_saas_column: gr.update(visible=False),
196
- output_saas_column: gr.update(visible=False),
197
  }
198
  else:
199
  return {
200
- see_formula_diy: gr.update(visible=False),
201
  text_diy_column: gr.update(visible=False),
202
  input_diy_column: gr.update(visible=False),
203
- output_diy_column: gr.update(visible=False),
204
- see_formula_saas: gr.update(visible=True),
205
  title_column: gr.update(visible=True),
206
  text_saas_column: gr.update(visible=True),
207
  input_saas_column: gr.update(visible=True),
208
- output_saas_column: gr.update(visible=True),
209
  }
210
- submit_btn.click(
 
211
  submit,
212
  solution_selection,
213
- [see_formula_diy, see_formula_saas, text_diy_column, title_column, text_saas_column, inp, inp2, out, btn, model_provider_inp, context_inp, out_2, btn_2, input_diy_column, input_saas_column, output_diy_column, output_saas_column],
214
- )
215
 
216
  # gr.Divider(style="vertical", thickness=2, color="blue")
217
 
218
- with gr.Column(scale=2):
219
 
220
- solution_selection2 = gr.Dropdown(["SaaS", "Home-made"], label="Select a Solution")
221
- submit_btn2 = gr.Button("Submit")
222
 
223
  with gr.Row(visible=False) as title_column2:
224
  gr.Markdown(value=text2)
@@ -226,130 +182,60 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
226
  with gr.Row(visible=False) as text_diy_column2:
227
  gr.Markdown(description1)
228
 
229
- with gr.Row(visible=False) as see_formula_diy2:
230
- formula_diy_btn2 = gr.Checkbox(label="See formula", value=False)
231
- with gr.Row(visible=False) as formula_diy2:
232
- gr.Markdown(
233
- r"$ homemade\_cost\_per\_request = \frac{tokens\_per\_request \times VM\_cost\_per\_hour \times (1 - reduction)}{tokens\_per\_second \times 3600 \times maxed\_out \times used}$"
234
- )
235
-
236
- def submit_formula_diy(formula_diy_btn2):
237
- if formula_diy_btn2:
238
- return{
239
- formula_diy2: gr.update(visible=True),
240
- }
241
- else:
242
- return{
243
- formula_diy2: gr.update(visible=False),
244
- }
245
-
246
- formula_diy_btn2.select(
247
- submit_formula_diy,
248
- [formula_diy_btn2],
249
- [formula_diy2]
250
- )
251
-
252
  with gr.Row(visible=False) as input_diy_column2:
253
- inp_2 = gr.Dropdown(models, label="Select an AI Model")
254
- inp2_2 = gr.Dropdown(vm_rental_choice, label="Select a VM Rental Plan")
255
-
256
- with gr.Row(visible=False) as output_diy_column2:
257
- out2 = gr.Textbox(label="Cost/request")
258
- btn2 = gr.Button("Compute the cost/request")
259
- btn2.click(fn=calculate_tco, inputs=[inp_2, inp2_2], outputs=out2)
260
-
261
  with gr.Row(visible=False) as text_saas_column2:
262
  gr.Markdown(description2)
263
 
264
- with gr.Row(visible=False) as see_formula_saas2:
265
- formula_saas_btn2 = gr.Checkbox(label="See formula", value=False)
266
- with gr.Row(visible=False) as formula_saas2:
267
- gr.Markdown(
268
- r"$ saas\_cost\_per\_request = saas\_cost\_per\_token \times tokens\_per\_request$"
269
- )
270
-
271
- def submit_formula_diy2(formula_saas_btn2):
272
- if formula_saas_btn2:
273
- return{
274
- formula_saas2: gr.update(visible=True),
275
- }
276
- else:
277
- return{
278
- formula_saas2: gr.update(visible=False),
279
- }
280
-
281
- formula_saas_btn2.select(
282
- submit_formula_diy2,
283
- [formula_saas_btn2],
284
- [formula_saas2]
285
- )
286
-
287
  with gr.Row(visible=False) as input_saas_column2:
288
  model_provider_inp2 = gr.Dropdown(['OpenAI'], label="Model Provider")
289
  context_inp2 = gr.Dropdown(['4K context', '16K context'], label="Context")
290
-
291
- with gr.Row(visible=False) as output_saas_column2:
292
- out_2_2 = gr.Textbox(label="Cost/request")
293
- btn_2_2 = gr.Button("Compute the cost/request")
294
- btn_2_2.click(fn=calculate_tco_2, inputs=[model_provider_inp2, context_inp2], outputs=out_2_2)
295
 
296
- def submit(solution_selection2):
297
- if solution_selection2 == "Home-made":
298
  return {
299
- see_formula_diy2: gr.update(visible=True),
300
  title_column2: gr.update(visible=True),
301
  text_diy_column2: gr.update(visible=True),
302
  input_diy_column2: gr.update(visible=True),
303
- output_diy_column2: gr.update(visible=True),
304
- see_formula_saas2: gr.update(visible=False),
305
  text_saas_column2: gr.update(visible=False),
306
  input_saas_column2: gr.update(visible=False),
307
- output_saas_column2: gr.update(visible=False),
308
  }
309
  else:
310
  return {
311
- see_formula_diy2: gr.update(visible=False),
312
  text_diy_column2: gr.update(visible=False),
313
  input_diy_column2: gr.update(visible=False),
314
- output_diy_column2: gr.update(visible=False),
315
- see_formula_saas2: gr.update(visible=True),
316
  title_column2: gr.update(visible=True),
317
  text_saas_column2: gr.update(visible=True),
318
  input_saas_column2: gr.update(visible=True),
319
- output_saas_column2: gr.update(visible=True),
320
  }
321
- submit_btn2.click(
322
- submit,
323
- solution_selection2,
324
- [see_formula_diy2, see_formula_saas2, title_column2, text_diy_column2, text_saas_column2, inp_2, inp2_2, out2, btn2, model_provider_inp2, context_inp2, out_2_2, btn_2_2, input_diy_column2, input_saas_column2, output_diy_column2, output_saas_column2],
325
- )
326
 
327
- gr.Markdown(value=text3)
328
- gr.Markdown(description3)
329
- error_box = gr.Textbox(label="Error", visible=False)
330
- with gr.Row():
331
- cost_text1_inp = gr.Textbox(label="Cost/request for the first solution", placeholder="Enter cost/request for the first solution")
332
- cost_text2_inp = gr.Textbox(label="Cost/request for the second solution",placeholder="Enter cost/request for the second solution")
333
-
334
- btn_compare = gr.Button("Compare")
335
-
336
- with gr.Row(visible=False) as output:
337
- out_compare = gr.Textbox()
338
 
339
- def submit2(cost_text1_inp, cost_text2_inp):
340
- if len(cost_text1_inp) == 0:
341
- return {error_box: gr.update(value="Enter cost of solution 1", visible=True)}
342
- if len(cost_text2_inp) == 0:
343
- return {error_box: gr.update(value="Enter cost of solution 2", visible=True)}
344
- return {
345
- output: gr.update(visible=True),
346
- out_compare: compare(cost_text1_inp, cost_text2_inp),
347
- }
348
-
349
- btn_compare.click(
350
- submit2,
351
- inputs=[cost_text1_inp, cost_text2_inp],
352
- outputs=[out_compare, output]
353
- )
354
-
 
 
 
355
  demo.launch()
 
1
  import gradio as gr
2
+ import pandas as pd
3
 
4
  text = "<h1 style='text-align: center; color: blue; font-size: 30px;'>TCO Comparison Calculator"
5
  text1 = "<h1 style='text-align: center; color: blue; font-size: 20px;'>First solution"
6
  text2 = "<h1 style='text-align: center; color: blue; font-size: 20px;'>Second solution"
7
  text3 = "<h1 style='text-align: center; color: blue; font-size: 25px;'>Comparison"
8
+ text4 = "<h1 style='text-align: center; color: blue; font-size: 25px;'>Results"
9
 
10
+ diy_value = 0
11
+ saas_value = 0
12
+
13
+ def calculate_tco(model_choice, vm_rental_choice, out_diy):
14
  VM_cost_per_hour=3.6730 #at Azure for the basic pay as you go option
15
  maxed_out = 0.8 #percentage of time the VM is maxed out
16
  used = 0.5 #percentage of time the VM is used
 
36
 
37
  homemade_cost_per_token = VM_cost_per_hour * (1 - reduction) / (tokens_per_second * 3600 * maxed_out * used)
38
  homemade_cost_per_request = tokens_per_request * homemade_cost_per_token
39
+ out_diy = homemade_cost_per_token
40
+ return out_diy
41
 
42
+ def calculate_tco_2(model_provider, context, out_saas):
 
 
 
43
  tokens_per_request = 64
44
 
45
  if model_provider == "OpenAI":
 
49
  elif context == "16K context" :
50
  saas_cost_per_token = 0.0007
51
  saas_cost_per_request = saas_cost_per_token * tokens_per_request
52
+ out_saas = saas_cost_per_token
53
+ return out_saas
54
 
55
  def extract_cost_from_text(text):
56
  try:
 
79
  except ValueError as e:
80
  return f"Error: {str(e)}"
81
 
82
+ def update_plot(diy_value, saas_value):
83
+ data = pd.DataFrame(
84
+ {
85
+ "Solution": ["Home-made", "SaaS"],
86
+ "Cost/token ($)": [diy_value, saas_value],
87
+ }
88
+ )
89
+ return gr.BarPlot.update(data, x="Solution", y="Cost/token ($)")
90
+
91
  description=f"""
92
  <p>In this demo application, we help you compare different solutions for your AI incorporation plans, such as open-source or SaaS.</p>
93
+ <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/request accordingly to them. Eventually, you can compare both solutions to evaluate which one best suits your needs, in the short or long term.</p>
94
  """
95
  description1=f"""
96
+ <p>This interface provides you with the cost per request you get using the open-source solution, based on the model you choose to use and how long you're planning to use it.</p>
97
  <p>The selected prices for a Virtual Machine rental come from Azure's VM rental plans, which can offer reductions for long-term reserved usage.</p>
98
+ <p>To compute this cost per requets, some adjustments were chosen: the VM is an A100 40GB, supposedly maxed out at 80% and utilized 50% of the time in a full day. Plus, the number of tokens per request was set to 64.</p>
99
  <p>To see the formula used to compute the cost/request, check the box just below!</p>
100
  """
101
  description2=f"""
102
+ <p>This interface provides you with the cost per request resulting from the AI model provider you choose and the number of tokens you select for context, which the model will take into account when processing input texts.</p>
103
+ <p>To compute this cost per request, some adjustments were chosen: the number of tokens per request was set to 64.</p>
104
  <p>To see the formula used to compute the cost/request, check the box just below!</p>
105
  """
106
  description3=f"""
107
+ <p>This interface compares the cost per request for the two solutions you selected and gives you an insight of whether a solution is more valuable in the long term.</p>
108
  """
109
 
110
  models = ["Llama-2-7B", "Llama-2-13B", "Llama-2-70B"]
 
112
  model_provider = ["OpenAI"]
113
  context = ["4K context", "16K context"]
114
  error_box = gr.Textbox(label="Error", visible=False)
 
 
115
 
116
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
117
  gr.Markdown(value=text)
118
  gr.Markdown(value=description)
119
 
120
+ out_diy = gr.State(value=0)
121
+ out_saas = gr.State(value=0)
122
+ out_diy2 = gr.State(value=0)
123
+ out_saas2 = gr.State(value=0)
124
+
125
  with gr.Row():
126
+ with gr.Column():
127
 
128
+ solution_selection = gr.Dropdown(["SaaS", "Open-source"], label="Select a Solution")
 
129
 
130
  with gr.Row(visible=False) as title_column:
131
  gr.Markdown(value=text1)
 
133
  with gr.Row(visible=False) as text_diy_column:
134
  gr.Markdown(description1)
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  with gr.Row(visible=False) as input_diy_column:
137
+ model_inp = gr.Dropdown(models, label="Select an AI Model")
138
+ rental_plan_inp = gr.Dropdown(vm_rental_choice, label="Select a VM Rental Plan")
139
+ rental_plan_inp.change(fn=calculate_tco, inputs=[model_inp, rental_plan_inp, out_diy], outputs=out_diy)
 
 
 
 
140
 
141
  with gr.Row(visible=False) as text_saas_column:
142
  gr.Markdown(description2)
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  with gr.Row(visible=False) as input_saas_column:
145
  model_provider_inp = gr.Dropdown(model_provider, label="Model Provider")
146
  context_inp = gr.Dropdown(context, label="Context")
147
+ context_inp.change(fn=calculate_tco_2, inputs=[model_provider_inp, context_inp, out_saas], outputs=out_saas)
148
+
 
 
 
 
149
  def submit(solution_selection):
150
+ if solution_selection == "Open-source":
151
  return {
 
152
  title_column: gr.update(visible=True),
153
  text_diy_column: gr.update(visible=True),
154
  input_diy_column: gr.update(visible=True),
 
 
155
  text_saas_column: gr.update(visible=False),
156
  input_saas_column: gr.update(visible=False),
 
157
  }
158
  else:
159
  return {
 
160
  text_diy_column: gr.update(visible=False),
161
  input_diy_column: gr.update(visible=False),
 
 
162
  title_column: gr.update(visible=True),
163
  text_saas_column: gr.update(visible=True),
164
  input_saas_column: gr.update(visible=True),
 
165
  }
166
+
167
+ solution_selection.change(
168
  submit,
169
  solution_selection,
170
+ [out_saas, text_diy_column, title_column, text_saas_column, model_inp, rental_plan_inp, model_provider_inp, context_inp, input_diy_column, input_saas_column],
171
+ )
172
 
173
  # gr.Divider(style="vertical", thickness=2, color="blue")
174
 
175
+ with gr.Column():
176
 
177
+ solution_selection2 = gr.Dropdown(["SaaS", "Open-source"], label="Select a Solution")
 
178
 
179
  with gr.Row(visible=False) as title_column2:
180
  gr.Markdown(value=text2)
 
182
  with gr.Row(visible=False) as text_diy_column2:
183
  gr.Markdown(description1)
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  with gr.Row(visible=False) as input_diy_column2:
186
+ model_inp2 = gr.Dropdown(models, label="Select an AI Model")
187
+ rental_plan_inp2 = gr.Dropdown(vm_rental_choice, label="Select a VM Rental Plan")
188
+ rental_plan_inp2.change(fn=calculate_tco, inputs=[model_inp2, rental_plan_inp2, out_diy2], outputs=out_diy2)
189
+
 
 
 
 
190
  with gr.Row(visible=False) as text_saas_column2:
191
  gr.Markdown(description2)
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  with gr.Row(visible=False) as input_saas_column2:
194
  model_provider_inp2 = gr.Dropdown(['OpenAI'], label="Model Provider")
195
  context_inp2 = gr.Dropdown(['4K context', '16K context'], label="Context")
196
+ context_inp2.change(fn=calculate_tco_2, inputs=[model_provider_inp2, context_inp2, out_saas2], outputs=out_saas2)
 
 
 
 
197
 
198
+ def submit2(solution_selection2):
199
+ if solution_selection2 == "Open-source":
200
  return {
 
201
  title_column2: gr.update(visible=True),
202
  text_diy_column2: gr.update(visible=True),
203
  input_diy_column2: gr.update(visible=True),
 
 
204
  text_saas_column2: gr.update(visible=False),
205
  input_saas_column2: gr.update(visible=False),
 
206
  }
207
  else:
208
  return {
 
209
  text_diy_column2: gr.update(visible=False),
210
  input_diy_column2: gr.update(visible=False),
 
 
211
  title_column2: gr.update(visible=True),
212
  text_saas_column2: gr.update(visible=True),
213
  input_saas_column2: gr.update(visible=True),
 
214
  }
 
 
 
 
 
215
 
216
+ solution_selection2.change(
217
+ submit2,
218
+ solution_selection2,
219
+ [out_diy2, out_saas2, title_column2, text_diy_column2, text_saas_column2, model_inp2, rental_plan_inp2, model_provider_inp2, context_inp2, input_diy_column2, input_saas_column2],
220
+ )
 
 
 
 
 
 
221
 
222
+ with gr.Row():
223
+ with gr.Column():
224
+
225
+ with gr.Row():
226
+ gr.Markdown(text3)
227
+
228
+ with gr.Row():
229
+ plot = gr.BarPlot(title="Comparison", x_title="Solution", y_title="Cost/token ($)", interactive=True, width=500)
230
+ if solution_selection=="Open-source":
231
+ context_inp2.change(fn=update_plot, inputs=[out_diy, out_saas2], outputs=plot)
232
+ model_provider_inp2.change(fn=update_plot, inputs=[out_diy, out_saas2], outputs=plot)
233
+ rental_plan_inp.change(fn=update_plot, inputs=[out_diy, out_saas2], outputs=plot)
234
+ model_inp.change(fn=update_plot, inputs=[out_diy, out_saas2], outputs=plot)
235
+ else:
236
+ rental_plan_inp2.change(fn=update_plot, inputs=[out_diy2, out_saas], outputs=plot)
237
+ context_inp.change(fn=update_plot, inputs=[out_diy2, out_saas], outputs=plot)
238
+ model_provider_inp.change(fn=update_plot, inputs=[out_diy2, out_saas], outputs=plot)
239
+ model_inp2.change(fn=update_plot, inputs=[out_diy2, out_saas], outputs=plot)
240
+
241
  demo.launch()