5to9 commited on
Commit
31ba0a1
1 Parent(s): b0859e8

0.35 chatch exception

Browse files
Files changed (1) hide show
  1. app.py +29 -26
app.py CHANGED
@@ -190,32 +190,35 @@ arena_notes = """## Important Notes:
190
  """
191
 
192
  with gr.Blocks() as demo:
193
- with gr.Column():
194
- gr.HTML("<center><h1>🤖le Royale</h1></center>")
195
- gr.Markdown(arena_notes)
196
- system_prompt = gr.Textbox(lines=1, label="System Prompt", value="You are a helpful chatbot that adheres to the prompted request.", show_copy_button=True)
197
- with gr.Row(variant="panel"):
198
- with gr.Column(scale=1):
199
- submit_btn = gr.Button(value="Generate", variant="primary")
200
- clear_btn = gr.Button(value="Clear", variant="secondary")
201
- input_text = gr.Textbox(lines=1, label="Prompt", value="Write a Nike style ad headline about the shame of being second best.", scale=3, show_copy_button=True)
202
- with gr.Row(variant="panel"):
203
- with gr.Column():
204
- chatbot_a = gr.Chatbot(label="Model A", show_copy_button=True, height=500)
205
- with gr.Column():
206
- chatbot_b = gr.Chatbot(label="Model B", show_copy_button=True, height=500)
207
- with gr.Row(variant="panel"):
208
- better_bot = gr.Radio(["Bot A kicks ass!", "Bot B crushes it!", "It's a draw."], label="Rate the output!"),
209
- with gr.Accordion(label="Generation Configurations", open=False):
210
- max_new_tokens = gr.Slider(minimum=128, maximum=4096, value=2048, label="Max New Tokens", step=128)
211
- temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.7, label="Temperature", step=0.01)
212
- top_p = gr.Slider(minimum=0.0, maximum=1.0, value=1.0, label="Top-p", step=0.01)
213
- repetition_penalty = gr.Slider(minimum=0.1, maximum=2.0, value=1.1, label="Repetition Penalty", step=0.1)
214
-
215
- better_bot.select(reveal_bot, inputs=[better_bot, chatbot_a, chatbot_b], outputs=[chatbot_a, chatbot_b]) #fckp outputs=[chatbot_a, chatbot_b]
216
- input_text.submit(generate_both, inputs=[system_prompt, input_text, chatbot_a, chatbot_b, max_new_tokens, temperature, top_p, repetition_penalty], outputs=[chatbot_a, chatbot_b])
217
- submit_btn.click(generate_both, inputs=[system_prompt, input_text, chatbot_a, chatbot_b, max_new_tokens, temperature, top_p, repetition_penalty], outputs=[chatbot_a, chatbot_b])
218
- clear_btn.click(clear, outputs=[chatbot_a, chatbot_b])
 
 
 
219
 
220
  if __name__ == "__main__":
221
  demo.queue().launch()
 
190
  """
191
 
192
  with gr.Blocks() as demo:
193
+ try:
194
+ with gr.Column():
195
+ gr.HTML("<center><h1>🤖le Royale</h1></center>")
196
+ gr.Markdown(arena_notes)
197
+ system_prompt = gr.Textbox(lines=1, label="System Prompt", value="You are a helpful chatbot that adheres to the prompted request.", show_copy_button=True)
198
+ with gr.Row(variant="panel"):
199
+ with gr.Column(scale=1):
200
+ submit_btn = gr.Button(value="Generate", variant="primary")
201
+ clear_btn = gr.Button(value="Clear", variant="secondary")
202
+ input_text = gr.Textbox(lines=1, label="Prompt", value="Write a Nike style ad headline about the shame of being second best.", scale=3, show_copy_button=True)
203
+ with gr.Row(variant="panel"):
204
+ with gr.Column():
205
+ chatbot_a = gr.Chatbot(label="Model A", show_copy_button=True, height=500)
206
+ with gr.Column():
207
+ chatbot_b = gr.Chatbot(label="Model B", show_copy_button=True, height=500)
208
+ with gr.Row(variant="panel"):
209
+ better_bot = gr.Radio(["Bot A kicks ass!", "Bot B crushes it!", "It's a draw."], label="Rate the output!"),
210
+ with gr.Accordion(label="Generation Configurations", open=False):
211
+ max_new_tokens = gr.Slider(minimum=128, maximum=4096, value=2048, label="Max New Tokens", step=128)
212
+ temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.7, label="Temperature", step=0.01)
213
+ top_p = gr.Slider(minimum=0.0, maximum=1.0, value=1.0, label="Top-p", step=0.01)
214
+ repetition_penalty = gr.Slider(minimum=0.1, maximum=2.0, value=1.1, label="Repetition Penalty", step=0.1)
215
+
216
+ better_bot.select(reveal_bot, inputs=[better_bot, chatbot_a, chatbot_b], outputs=[chatbot_a, chatbot_b]) #fckp outputs=[chatbot_a, chatbot_b]
217
+ input_text.submit(generate_both, inputs=[system_prompt, input_text, chatbot_a, chatbot_b, max_new_tokens, temperature, top_p, repetition_penalty], outputs=[chatbot_a, chatbot_b])
218
+ submit_btn.click(generate_both, inputs=[system_prompt, input_text, chatbot_a, chatbot_b, max_new_tokens, temperature, top_p, repetition_penalty], outputs=[chatbot_a, chatbot_b])
219
+ clear_btn.click(clear, outputs=[chatbot_a, chatbot_b])
220
+ except Exception as e:
221
+ logging.error(f'{SPACER} Error: {e}, Traceback {traceback.format_exc()}')
222
 
223
  if __name__ == "__main__":
224
  demo.queue().launch()