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(country, starting_point, query, sustainable, model, 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, sustainable, model, output, generate_text) return app if __name__ == "__main__": app = create_ui() app.launch(show_api=False)