rodrisouza commited on
Commit
a333bdc
·
verified ·
1 Parent(s): 3038992

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -26
app.py CHANGED
@@ -197,36 +197,37 @@ def save_comment_score(chat_responses, score, comment, story_name, user_name, sy
197
  # Create the chat interface using Gradio Blocks
198
  with gr.Blocks() as demo:
199
  gr.Markdown("# Chat with Model")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
- with gr.Tab("Context"):
202
- model_dropdown = gr.Dropdown(choices=list(models.keys()), label="Select Model", value=selected_model)
203
- user_dropdown = gr.Dropdown(choices=user_names, label="Select User Name")
204
- initial_story = stories[0]["title"] if stories else None
205
- story_dropdown = gr.Dropdown(choices=[story["title"] for story in stories], label="Select Story", value=initial_story)
206
- system_prompt_dropdown = gr.Dropdown(choices=system_prompts, label="Select System Prompt", value=system_prompts[0])
207
- send_story_button = gr.Button("Send Story")
208
-
209
- with gr.Tab("Chat"):
210
- selected_story_textbox = gr.Textbox(label="Selected Story", lines=10, interactive=False)
211
- with gr.Row():
212
- with gr.Column(scale=1):
213
- chatbot_input = gr.Textbox(placeholder="Type your message here...", label="User Input")
214
- send_message_button = gr.Button("Send")
215
- with gr.Column(scale=2):
216
- chatbot_output = gr.Chatbot(label="Chat History")
217
-
218
- with gr.Tab("Evaluation"):
219
- with gr.Row():
220
- with gr.Column(scale=1):
221
- score_input = gr.Slider(minimum=0, maximum=5, step=1, label="Score")
222
- comment_input = gr.Textbox(placeholder="Add a comment...", label="Comment")
223
- save_button = gr.Button("Save Score and Comment")
224
- data_table = gr.DataFrame(headers=["User Input", "Chat Response", "Score", "Comment"])
225
 
226
  chat_history_json = gr.JSON(value=[], visible=False)
 
227
 
228
- send_story_button.click(fn=send_selected_story, inputs=[story_dropdown, model_dropdown, system_prompt_dropdown], outputs=[chatbot_output, chat_history_json, data_table, selected_story_textbox, gr.JSON(value=0)])
229
- send_message_button.click(fn=interact, inputs=[chatbot_input, chat_history_json, gr.JSON(value=0)], outputs=[chatbot_input, chatbot_output, chat_history_json, gr.JSON(value=0)])
230
  save_button.click(fn=save_comment_score, inputs=[chatbot_output, score_input, comment_input, story_dropdown, user_dropdown, system_prompt_dropdown], outputs=[data_table, comment_input])
231
 
232
  demo.launch()
 
197
  # Create the chat interface using Gradio Blocks
198
  with gr.Blocks() as demo:
199
  gr.Markdown("# Chat with Model")
200
+
201
+ gr.Markdown("## Context")
202
+ model_dropdown = gr.Dropdown(choices=list(models.keys()), label="Select Model", value=selected_model)
203
+ user_dropdown = gr.Dropdown(choices=user_names, label="Select User Name")
204
+ initial_story = stories[0]["title"] if stories else None
205
+ story_dropdown = gr.Dropdown(choices=[story["title"] for story in stories], label="Select Story", value=initial_story)
206
+ system_prompt_dropdown = gr.Dropdown(choices=system_prompts, label="Select System Prompt", value=system_prompts[0])
207
+ send_story_button = gr.Button("Send Story")
208
+
209
+ gr.Markdown("## Chat")
210
+ selected_story_textbox = gr.Textbox(label="Selected Story", lines=10, interactive=False)
211
+ with gr.Row():
212
+ with gr.Column(scale=1):
213
+ chatbot_input = gr.Textbox(placeholder="Type your message here...", label="User Input")
214
+ send_message_button = gr.Button("Send")
215
+ with gr.Column(scale=2):
216
+ chatbot_output = gr.Chatbot(label="Chat History")
217
 
218
+ gr.Markdown("## Evaluation")
219
+ with gr.Row():
220
+ with gr.Column(scale=1):
221
+ score_input = gr.Slider(minimum=0, maximum=5, step=1, label="Score")
222
+ comment_input = gr.Textbox(placeholder="Add a comment...", label="Comment")
223
+ save_button = gr.Button("Save Score and Comment")
224
+ data_table = gr.DataFrame(headers=["User Input", "Chat Response", "Score", "Comment"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  chat_history_json = gr.JSON(value=[], visible=False)
227
+ interaction_counter_json = gr.JSON(value=0, visible=False)
228
 
229
+ send_story_button.click(fn=send_selected_story, inputs=[story_dropdown, model_dropdown, system_prompt_dropdown], outputs=[chatbot_output, chat_history_json, data_table, selected_story_textbox, interaction_counter_json])
230
+ send_message_button.click(fn=interact, inputs=[chatbot_input, chat_history_json, interaction_counter_json], outputs=[chatbot_input, chatbot_output, chat_history_json, interaction_counter_json])
231
  save_button.click(fn=save_comment_score, inputs=[chatbot_output, score_input, comment_input, story_dropdown, user_dropdown, system_prompt_dropdown], outputs=[data_table, comment_input])
232
 
233
  demo.launch()