import gradio as gr from utils import * with gr.Blocks(gr.themes.Soft(primary_hue=gr.themes.colors.slate, secondary_hue=gr.themes.colors.purple)) as demo: with gr.Row(): with gr.Column(scale=1, variant = 'panel'): chatbot = gr.Chatbot([[None, "Hello, ask me anything about aviation"]], elem_id="chatbot", label='Chatbox', height=600) txt = gr.Textbox(label= "Question", placeholder="Enter your question and press enter ") with gr.Row(): with gr.Column(scale=1): submit_btn = gr.Button('Submit',variant='primary', size = 'sm') with gr.Column(scale=1): clear_btn = gr.Button('Clear',variant='stop',size = 'sm') txt.submit(add_text, [chatbot, txt], [chatbot, txt]).then( bot, [chatbot], chatbot) submit_btn.click(add_text, [chatbot, txt], [chatbot, txt]).then( bot, [chatbot], chatbot).then( clear_cuda_cache, None, None ) clear_btn.click(lambda: None, None, chatbot, queue=False) if __name__ == '__main__': # demo.queue(concurrency_count=3) demo.launch(server_name="0.0.0.0", server_port=7860, show_api=False)