Spaces:
Runtime error
Runtime error
liujch1998
commited on
Commit
β’
0ef49e6
1
Parent(s):
6c09b42
WIP
Browse files
app.py
CHANGED
@@ -92,7 +92,7 @@ def predict(statement, do_save=True):
|
|
92 |
print('Commit URL:', commit_url)
|
93 |
print(output_raw)
|
94 |
print()
|
95 |
-
return output, output_raw, gr.update(
|
96 |
|
97 |
def record_feedback(output_raw, feedback, do_save=True):
|
98 |
if do_save:
|
@@ -105,7 +105,7 @@ def record_feedback(output_raw, feedback, do_save=True):
|
|
105 |
print('Commit URL:', commit_url)
|
106 |
print(output_raw)
|
107 |
print()
|
108 |
-
return gr.update(
|
109 |
def record_feedback_agree(output_raw, do_save=True):
|
110 |
return record_feedback(output_raw, 'agree', do_save)
|
111 |
def record_feedback_disagree(output_raw, do_save=True):
|
@@ -212,18 +212,20 @@ with gr.Blocks() as demo:
|
|
212 |
with gr.Row():
|
213 |
feedback_agree = gr.Button(value='π Agree', variant='secondary', visible=False)
|
214 |
feedback_disagree = gr.Button(value='π Disagree', variant='secondary', visible=False)
|
215 |
-
feedback_ack = gr.Markdown(value='
|
216 |
with gr.Row():
|
217 |
gr.Examples(
|
218 |
examples=examples,
|
219 |
-
inputs=[statement],
|
220 |
-
cache_examples=False,
|
221 |
fn=predict,
|
|
|
222 |
outputs=[output, output_raw, statement, submit, feedback_agree, feedback_disagree, feedback_ack],
|
|
|
|
|
|
|
223 |
)
|
224 |
-
submit.click(predict, inputs=[statement, do_save], outputs=[output, output_raw,
|
225 |
# statement.submit(predict, inputs=[statement], outputs=[output, output_raw])
|
226 |
-
feedback_agree.click(record_feedback_agree, inputs=[output_raw, do_save], outputs=[
|
227 |
-
feedback_disagree.click(record_feedback_disagree, inputs=[output_raw, do_save], outputs=[
|
228 |
|
229 |
demo.queue(concurrency_count=16).launch(debug=True)
|
|
|
92 |
print('Commit URL:', commit_url)
|
93 |
print(output_raw)
|
94 |
print()
|
95 |
+
return output, output_raw, gr.update(visible=False), gr.update(visible=True), gr.update(visible=True), gr.update(value='Please provide your feedback before trying out another statement.')
|
96 |
|
97 |
def record_feedback(output_raw, feedback, do_save=True):
|
98 |
if do_save:
|
|
|
105 |
print('Commit URL:', commit_url)
|
106 |
print(output_raw)
|
107 |
print()
|
108 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(value='Thanks for your feedback! Now you can enter another statement.')
|
109 |
def record_feedback_agree(output_raw, do_save=True):
|
110 |
return record_feedback(output_raw, 'agree', do_save)
|
111 |
def record_feedback_disagree(output_raw, do_save=True):
|
|
|
212 |
with gr.Row():
|
213 |
feedback_agree = gr.Button(value='π Agree', variant='secondary', visible=False)
|
214 |
feedback_disagree = gr.Button(value='π Disagree', variant='secondary', visible=False)
|
215 |
+
feedback_ack = gr.Markdown(value='', visible=True, interactive=False)
|
216 |
with gr.Row():
|
217 |
gr.Examples(
|
218 |
examples=examples,
|
|
|
|
|
219 |
fn=predict,
|
220 |
+
inputs=[statement],
|
221 |
outputs=[output, output_raw, statement, submit, feedback_agree, feedback_disagree, feedback_ack],
|
222 |
+
examples_per_page=100,
|
223 |
+
cache_examples=False,
|
224 |
+
run_on_click=False, # If we want this to be True, I suspect we need to enable the statement.submit()
|
225 |
)
|
226 |
+
submit.click(predict, inputs=[statement, do_save], outputs=[output, output_raw, submit, feedback_agree, feedback_disagree, feedback_ack])
|
227 |
# statement.submit(predict, inputs=[statement], outputs=[output, output_raw])
|
228 |
+
feedback_agree.click(record_feedback_agree, inputs=[output_raw, do_save], outputs=[submit, feedback_agree, feedback_disagree, feedback_ack])
|
229 |
+
feedback_disagree.click(record_feedback_disagree, inputs=[output_raw, do_save], outputs=[submit, feedback_agree, feedback_disagree, feedback_ack])
|
230 |
|
231 |
demo.queue(concurrency_count=16).launch(debug=True)
|