update textbox properties
Browse files
app.py
CHANGED
@@ -48,6 +48,8 @@ def predict(inputs, top_p, temperature, top_k, repetition_penalty, history=[]):
|
|
48 |
token_counter+=1
|
49 |
yield chat, history #{chatbot: chat, state: history} #[(partial_words, history)]
|
50 |
|
|
|
|
|
51 |
|
52 |
title = """<h1 align="center">Streaming your Chatbot output with Gradio</h1>"""
|
53 |
description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
|
@@ -77,10 +79,11 @@ with gr.Blocks(css = """#col_container {width: 700px; margin-left: auto; margin-
|
|
77 |
top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
|
78 |
repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
|
79 |
|
80 |
-
|
81 |
-
#inputs.submit(predict, [t,s], [c,s])
|
82 |
inputs.submit( predict, [inputs, top_p, temperature, top_k, repetition_penalty, state], [chatbot, state],)
|
83 |
b1.click( predict, [inputs, top_p, temperature, top_k, repetition_penalty, state], [chatbot, state],)
|
84 |
-
|
|
|
|
|
85 |
gr.Markdown(description)
|
86 |
demo.queue().launch(debug=True)
|
|
|
48 |
token_counter+=1
|
49 |
yield chat, history #{chatbot: chat, state: history} #[(partial_words, history)]
|
50 |
|
51 |
+
def reset_textbox():
|
52 |
+
return gr.update(value='')
|
53 |
|
54 |
title = """<h1 align="center">Streaming your Chatbot output with Gradio</h1>"""
|
55 |
description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
|
|
|
79 |
top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
|
80 |
repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
|
81 |
|
82 |
+
|
|
|
83 |
inputs.submit( predict, [inputs, top_p, temperature, top_k, repetition_penalty, state], [chatbot, state],)
|
84 |
b1.click( predict, [inputs, top_p, temperature, top_k, repetition_penalty, state], [chatbot, state],)
|
85 |
+
b1.click(reset_textbox, [], [inputs])
|
86 |
+
inputs.submit(reset_textbox, [], [inputs])
|
87 |
+
|
88 |
gr.Markdown(description)
|
89 |
demo.queue().launch(debug=True)
|