File size: 1,025 Bytes
e0e93c4
50f19fa
e0e93c4
50f19fa
 
 
73d3fc4
2d9906b
50f19fa
 
 
b3b6d77
2d9906b
50f19fa
 
 
73d3fc4
50f19fa
 
b3b6d77
50f19fa
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
import models

with gr.Blocks() as demo:
    Models: list[models.BaseTCOModel] = [models.OpenAIModel, models.OpenSourceLlama2Model]
    model_names = [Model().get_name() for Model in Models]
    with gr.Row():
        with gr.Column():
            page1 = models.ModelPage(Models)
            dropdown = gr.Dropdown(model_names, interactive=True)
            page1.render()

        with gr.Column():
            page2 = models.ModelPage(Models)
            dropdown2 = gr.Dropdown(model_names, interactive=True)
            page2.render()
            
    dropdown.change(page1.make_model_visible, inputs=dropdown, outputs=page1.get_all_components())
    dropdown2.change(page2.make_model_visible, inputs=dropdown2, outputs=page2.get_all_components())

    compute_tco_btn = gr.Button("Compute TCO")
    tco_output = gr.Text("Output: ")
    compute_tco_btn.click(page1.compute_cost_per_token, inputs=page1.get_all_components_for_cost_computing() + [dropdown], outputs=tco_output)

demo.launch(debug=True)