import gradio as gr from specific_ui import create_specific_ui from agentic_ui import create_agentic_ui def create_main_ui(): """Creates the main UI with toggle functionality.""" with gr.Blocks() as demo: # Toggle button to switch between UIs toggle_button = gr.Radio( choices=["Specific UI", "Agentic UI"], label="Select UI Mode", value="Specific UI" ) # Specific UI components specific_ui, input_api_key, model_dropdown = create_specific_ui() # Agentic UI components agentic_ui = create_agentic_ui(input_api_key, model_dropdown) # Toggle between UIs def toggle_ui(mode): if mode == "Specific UI": return [gr.Column.update(visible=True), gr.Column.update(visible=False)] else: return [gr.Column.update(visible=False), gr.Column.update(visible=True)] toggle_button.change( fn=toggle_ui, inputs=toggle_button, outputs=[specific_ui, agentic_ui] ) return demo