from dotenv import load_dotenv load_dotenv() import os import utils import gradio as gr with gr.Blocks() as app: with gr.Row() as selection: model = gr.Dropdown(choices=[model for model in utils.MODELS], label='Select Model') start_button = gr.Button(value='Start Test') restart_button = gr.Button(value='Restart Test', visible=False) with gr.Column(visible=False) as testing: name_model = gr.Markdown() chatbot = gr.Chatbot(label='Chatbot') message = gr.Text(label='Enter your message') # Init the chatbot start_button.click( utils.start_chat, model, [selection, restart_button, testing, name_model] ) # Select again the model restart_button.click( utils.restart_chat, None, [selection, restart_button, testing, chatbot, message] ) # Send the messages and get an answer message.submit( utils.get_answer, [chatbot, message, model], [chatbot, message] ) app.queue() app.launch(debug=True, auth=(os.environ.get('SPACE_USERNAME'), os.environ.get('SPACE_PASSWORD')))