Spaces:
Runtime error
Runtime error
File size: 1,082 Bytes
5d345b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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')))
|