from src.config.settings import MODEL_ID, MODEL_OPTIONS from src.utils.helpers import bot, user import gradio as gr def gradio_interface() -> gr.Blocks: # Components image_prompt_component = gr.Image( type="pil", label="Input Image (Optional: Figure/Graph)" ) chatbot_component = gr.Chatbot( label="Chatbot", ) text_prompt_component = gr.Textbox( placeholder="Type your question here...", label="Ask", lines=3 ) run_button_component = gr.Button("Submit") temperature_component = gr.Slider( minimum=0, maximum=1.0, value=0.4, step=0.05, label="Creativity (Temperature)", info="Controls the randomness of the response. Higher values result in more creative answers." ) max_output_tokens_component = gr.Slider( minimum=1, maximum=2048, value=1024, step=1, label="Response Length (Token Limit)", info="Sets the maximum number of tokens in the output response." ) model_name_component = gr.Dropdown( choices=MODEL_OPTIONS, value=MODEL_ID, label="Model Selection", info="Choose the Gemini model to use for generation." ) stop_sequences_component = gr.Textbox( label="Stop Sequences (Optional)", placeholder="Enter stop sequences, e.g., STOP, END", info="Specify sequences to stop the generation." ) top_k_component = gr.Slider( minimum=1, maximum=40, value=32, step=1, label="Top-K Sampling", info="Limits token selection to the top K most probable tokens. Lower values produce conservative outputs." ) top_p_component = gr.Slider( minimum=0, maximum=1, value=1, step=0.01, label="Top-P Sampling", info="Limits token selection to tokens with a cumulative probability up to P. Lower values produce conservative outputs." ) example_scenarios = [ "Describe Multimodal AI", "What are the differences between multi-agent LLMs and multi-agent systems", "Why is it difficult to integrate multimodality in a prompt", ] example_images = [["research/ex1.png"], ["research/ex2.png"]] # Gradio Interface user_inputs = [text_prompt_component, chatbot_component] bot_inputs = [ model_name_component, image_prompt_component, temperature_component, max_output_tokens_component, stop_sequences_component, top_k_component, top_p_component, chatbot_component, ] with gr.Blocks() as app: gr.Markdown("