Spaces:
Sleeping
Sleeping
File size: 2,258 Bytes
afdc734 60fc0c5 02cfaf6 60fc0c5 02cfaf6 60fc0c5 594e96c afdc734 60fc0c5 afdc734 60fc0c5 02cfaf6 60fc0c5 02cfaf6 60fc0c5 afdc734 60fc0c5 02cfaf6 60fc0c5 02cfaf6 60fc0c5 |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
from functions import *
scores_parameters, authors, p_conversation = get_main_data()
with gr.Blocks() as app:
msg_history = gr.State() # Messages with the format used by OpenAI
waiting_time = gr.State([]) # Seconds needed to get each answer
prompt_conversation = gr.State(p_conversation)
summary = gr.State('')
num_interactions = gr.State(0)
cost = gr.State([])
with gr.Tab('Test Chats'):
with gr.Row():
author = gr.Dropdown(authors, value=authors[0], label='Author', interactive=True)
chat_btn = gr.Button(value='Start chat')
# ------------------------------------- Chat -------------------------------------------
chatbot = gr.Chatbot(label='Chat', visible=False)
message = gr.Textbox(label='Message', visible=False)
# ------------------------------------- Result's tab ---------------------------------------
with gr.Tab('Save results'):
with gr.Row(visible=False) as scores_row:
with gr.Column(scale=75):
with gr.Row():
scores = [
gr.Radio(choices=['Aprovado', 'No aprovado', 'No aplica'], label=parameter)
for parameter in scores_parameters
]
with gr.Column(scale=25):
opinion_box = gr.Textbox(label='Opinion')
scores_btn = gr.Button(value='Send scores')
scores_box = gr.Textbox(label='Status', interactive=False)
# -------------------------------------- Actions -----------------------------------------
chat_btn.click(
innit_bot, [prompt_conversation], [msg_history]
).then(
make_noninteractive, None, [author]
).then(
make_visible, None, [chatbot, message, scores_row]
)
message.submit(
get_answer,
[message, msg_history, chatbot, waiting_time, num_interactions, summary, cost],
[message, msg_history, chatbot, waiting_time, num_interactions, summary, cost]
)
scores_btn.click(
save_scores,
[author, chatbot, waiting_time, opinion_box, cost] + scores,
scores_box
)
app.launch(debug=True, auth=(os.environ.get('USERNAME'), os.environ.get('PASSWORD')))
|