Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudotensor committed Apr 10, 2023
1 parent 426c27a commit 86013d3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def go_gradio(**kwargs):
)
with gr.Row():
clear = gr.Button("Clear")
stop_btn = gr.Button(value="Stop")
flag_btn = gr.Button("Flag")
else:
text_output = gr.Textbox(lines=5, label="Output")
Expand Down Expand Up @@ -396,7 +397,7 @@ def go_gradio(**kwargs):
)
if not kwargs['chat']:
submit = gr.Button("Submit")
submit.click(fun, inputs=inputs_list, outputs=text_output)
click_event = submit.click(fun, inputs=inputs_list, outputs=text_output)

# examples after submit or any other buttons for chat or no chat
if kwargs['examples'] is not None and kwargs['show_examples']:
Expand Down Expand Up @@ -441,7 +442,7 @@ def bot(*args):
yield history
return

instruction.submit(user,
click_event = instruction.submit(user,
inputs_list + [text_output], # matching user() inputs
[instruction, text_output], queue=stream_output).then(
bot, inputs_list + [text_output], text_output
Expand All @@ -451,6 +452,9 @@ def bot(*args):
# callback for logging flagged input/output
callback.setup(inputs_list + [text_output], "flagged_data_points")
flag_btn.click(lambda *args: callback.flag(args), inputs_list + [text_output], None, preprocess=False)
# don't pass text_output, don't want to clear output, just stop it
# FIXME: have to click once to stop output and second time to stop GPUs going
stop_btn.click(lambda: None, None, None, cancels=[click_event, click_event], queue=False)

demo.queue(concurrency_count=1)
favicon_path = "h2o-logo.svg"
Expand Down

0 comments on commit 86013d3

Please sign in to comment.