File size: 1,494 Bytes
4b722ec
ac20456
 
8842640
 
 
 
 
4b722ec
 
 
ac20456
8842640
 
 
 
 
 
 
ec79175
8842640
 
 
 
 
 
 
c45b1d2
8842640
 
 
 
 
 
ac20456
 
4b722ec
 
ac20456
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
import sys

from src.ui.components.actions import generate_text, clear
from src.ui.components.inputs import main_component
from src.ui.components.static import load_buttons, load_examples, model_settings
from src.ui.setup import load_html_from_file
from src.text_generation.vertexai_setup import initialize_vertexai_params
sys.path.append("./src")


def create_ui():
    initialize_vertexai_params()
    # Path to HTML file
    html_file_path = 'src/ui/templates/intro.html'

    # Create the Gradio HTML component
    html_content = load_html_from_file(html_file_path)

    with gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.green, secondary_hue=gr.themes.colors.blue)) as app:
        gr.HTML(html_content)
        country, starting_point, query, sustainable, model = main_component()
        output = gr.Textbox(label="Generated Results", lines=4)
        max_new_tokens, temperature = model_settings()

        # Load the buttons for the interface
        load_buttons(query, model,
                     sustainable, country, starting_point,
                     max_new_tokens, temperature,
                     output,
                     generate_text_fn=generate_text,
                     clear_fn=clear)
        # Load the examples for the interface
        # load_examples(country, starting_point, query, model, sustainable, output, generate_text)
    return app


if __name__ == "__main__":
    app = create_ui()
    app.launch(show_api=False)