zqu2004 commited on
Commit
dce5482
1 Parent(s): 013b8fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -45,11 +45,14 @@ def respond(
45
  yield response
46
 
47
  def update_textbox(prompt):
48
- return gr.Textbox.update(value=prompt)
49
 
50
  with gr.Blocks() as demo:
51
  chatbot = gr.Chatbot()
52
- msg = gr.Textbox()
 
 
 
53
  clear = gr.ClearButton([msg, chatbot])
54
 
55
  with gr.Accordion("Advanced options", open=False):
@@ -58,9 +61,9 @@ with gr.Blocks() as demo:
58
  temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
59
  top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
60
 
61
- prompt_dropdown = gr.Dropdown(choices=prompts, label="Select a premade prompt")
62
  prompt_dropdown.change(update_textbox, inputs=[prompt_dropdown], outputs=[msg])
63
 
 
64
  msg.submit(respond, [msg, chatbot, system, max_tokens, temperature, top_p], chatbot)
65
  clear.click(lambda: None, None, chatbot, queue=False)
66
 
 
45
  yield response
46
 
47
  def update_textbox(prompt):
48
+ return prompt
49
 
50
  with gr.Blocks() as demo:
51
  chatbot = gr.Chatbot()
52
+ msg = gr.Textbox(label="Type your message or select a prompt")
53
+ with gr.Row():
54
+ prompt_dropdown = gr.Dropdown(choices=[""] + prompts, label="Select a premade prompt", value="")
55
+ submit = gr.Button("Submit")
56
  clear = gr.ClearButton([msg, chatbot])
57
 
58
  with gr.Accordion("Advanced options", open=False):
 
61
  temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
62
  top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
63
 
 
64
  prompt_dropdown.change(update_textbox, inputs=[prompt_dropdown], outputs=[msg])
65
 
66
+ submit.click(respond, [msg, chatbot, system, max_tokens, temperature, top_p], chatbot)
67
  msg.submit(respond, [msg, chatbot, system, max_tokens, temperature, top_p], chatbot)
68
  clear.click(lambda: None, None, chatbot, queue=False)
69