Spaces:
Runtime error
Runtime error
Commit
·
b51a364
1
Parent(s):
7057057
add 'clear outputs' button
Browse files
app.py
CHANGED
|
@@ -179,20 +179,12 @@ start_work = """async() => {
|
|
| 179 |
window['chat_bot1'].children[1].setAttribute('style', 'border-bottom-right-radius:0;top:unset;bottom:0;padding-left:0.1rem');
|
| 180 |
load_conversation(window['chat_bot1'].children[2].children[0]);
|
| 181 |
window['chat_bot1'].children[2].scrollTop = window['chat_bot1'].children[2].scrollHeight;
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
window['chat_bot1'].children[2].addEventListener('mouseup', function(e) {
|
| 187 |
-
var now = new Date();
|
| 188 |
-
if (now - mousedown_last > 5 * 1000) {
|
| 189 |
-
if (confirm('Clear outputs?')==true) {
|
| 190 |
-
window['chat_bot1'].children[2].children[0].innerHTML = '';
|
| 191 |
-
save_conversation(window['chat_bot1'].children[2].children[0]);
|
| 192 |
-
}
|
| 193 |
}
|
| 194 |
-
|
| 195 |
-
})
|
| 196 |
|
| 197 |
window['prevPrompt'] = '';
|
| 198 |
window['doCheckPrompt'] = 0;
|
|
@@ -295,11 +287,19 @@ with gr.Blocks(title='Talk to chatGPT') as demo:
|
|
| 295 |
prompt_input1 = gr.Textbox(lines=4, label="prompt", visible=False)
|
| 296 |
chat_history = gr.Textbox(lines=4, label="prompt", visible=False)
|
| 297 |
chat_radio = gr.Radio(["Talk to chatGPT", "Text to Image"], elem_id="chat_radio",value="Talk to chatGPT", show_label=False)
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
api = gr.State(value=get_api())
|
| 304 |
submit_btn.click(fn=chat,
|
| 305 |
inputs=[api, prompt_input0, prompt_input1, chat_radio, chat_history],
|
|
|
|
| 179 |
window['chat_bot1'].children[1].setAttribute('style', 'border-bottom-right-radius:0;top:unset;bottom:0;padding-left:0.1rem');
|
| 180 |
load_conversation(window['chat_bot1'].children[2].children[0]);
|
| 181 |
window['chat_bot1'].children[2].scrollTop = window['chat_bot1'].children[2].scrollHeight;
|
| 182 |
+
window['gradioEl'].querySelectorAll('#clear-btn')[0].onclick = function(e){
|
| 183 |
+
if (confirm('Clear all outputs?')==true) {
|
| 184 |
+
window['chat_bot1'].children[2].children[0].innerHTML = '';
|
| 185 |
+
save_conversation(window['chat_bot1'].children[2].children[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
}
|
| 187 |
+
}
|
|
|
|
| 188 |
|
| 189 |
window['prevPrompt'] = '';
|
| 190 |
window['doCheckPrompt'] = 0;
|
|
|
|
| 287 |
prompt_input1 = gr.Textbox(lines=4, label="prompt", visible=False)
|
| 288 |
chat_history = gr.Textbox(lines=4, label="prompt", visible=False)
|
| 289 |
chat_radio = gr.Radio(["Talk to chatGPT", "Text to Image"], elem_id="chat_radio",value="Talk to chatGPT", show_label=False)
|
| 290 |
+
with gr.Row(elem_id="btns_row"):
|
| 291 |
+
with gr.Column(id="submit_col"):
|
| 292 |
+
submit_btn = gr.Button(value = "submit",elem_id="submit-btn").style(
|
| 293 |
+
margin=True,
|
| 294 |
+
rounded=(True, True, True, True),
|
| 295 |
+
width=100
|
| 296 |
+
)
|
| 297 |
+
with gr.Column(id="clear_col"):
|
| 298 |
+
clear_btn = gr.Button(value = "clear outputs", elem_id="clear-btn").style(
|
| 299 |
+
margin=True,
|
| 300 |
+
rounded=(True, True, True, True),
|
| 301 |
+
width=100
|
| 302 |
+
)
|
| 303 |
api = gr.State(value=get_api())
|
| 304 |
submit_btn.click(fn=chat,
|
| 305 |
inputs=[api, prompt_input0, prompt_input1, chat_radio, chat_history],
|