import gradio as gr import asyncio from endpoints.text import text_query from endpoints.image import image_query from endpoints.video import video_query def setup_ui(): with gr.Blocks() as ui: gr.Markdown( """ # Multimodal Query Interface Submit text, image, or video queries and get insights powered by APIs. """ ) # Tabbed layout with gr.Tabs(): # Text Query Tab with gr.Tab("Text Query"): gr.Markdown("### Submit a Text Query") with gr.Row(): text_input = gr.Textbox(label="Your Question", placeholder="Type your question here...") text_button = gr.Button("Submit") text_output = gr.Textbox(label="Response", interactive=False) text_button.click( fn=lambda q: asyncio.run(text_query(q)), inputs=[text_input], outputs=[text_output] ) # Image Query Tab with gr.Tab("Image Query"): gr.Markdown("### Submit an Image Query") with gr.Row(): image_input = gr.File(label="Upload Image") image_question_input = gr.Textbox(label="Your Question", placeholder="Type your question here...") image_button = gr.Button("Submit") image_output = gr.Textbox(label="Response", interactive=False) image_button.click( fn=lambda img, q: asyncio.run(image_query(img, q)), inputs=[image_input, image_question_input], outputs=[image_output] ) # Video Query Tab with gr.Tab("Video Query"): gr.Markdown("### Submit a Video Query") with gr.Row(): video_input = gr.File(label="Upload Video") video_question_input = gr.Textbox(label="Your Question", placeholder="Type your question here...") video_button = gr.Button("Submit") video_output = gr.Textbox(label="Response", interactive=False) video_button.click( fn=lambda vid, q: asyncio.run(video_query(vid, q)), inputs=[video_input, video_question_input], outputs=[video_output] ) return ui if __name__ == "__main__": ui = setup_ui() ui.launch(server_name="0.0.0.0", server_port=7860)