Spaces:
Runtime error
Runtime error
liujch1998
commited on
Commit
β’
3cd31d8
1
Parent(s):
ea1fca9
Add more feedback buttons
Browse files
app.py
CHANGED
@@ -167,6 +167,8 @@ def predict(statements, do_saves):
|
|
167 |
[gr.update(visible=False) for _ in statements], \
|
168 |
[gr.update(visible=True) for _ in statements], \
|
169 |
[gr.update(visible=True) for _ in statements], \
|
|
|
|
|
170 |
[gr.update(value='Please share your feedback before trying out another statement.') for _ in statements]
|
171 |
|
172 |
def record_feedback(output_raws, feedback, do_saves):
|
@@ -183,6 +185,8 @@ def record_feedback(output_raws, feedback, do_saves):
|
|
183 |
print()
|
184 |
lock.release()
|
185 |
return [gr.update(visible=True) for _ in output_raws], \
|
|
|
|
|
186 |
[gr.update(visible=False) for _ in output_raws], \
|
187 |
[gr.update(visible=False) for _ in output_raws], \
|
188 |
[gr.update(value='Thanks for sharing your feedback! You can now enter another statement.') for _ in output_raws]
|
@@ -190,6 +194,10 @@ def record_feedback_agree(output_raws, do_saves):
|
|
190 |
return record_feedback(output_raws, 'agree', do_saves)
|
191 |
def record_feedback_disagree(output_raws, do_saves):
|
192 |
return record_feedback(output_raws, 'disagree', do_saves)
|
|
|
|
|
|
|
|
|
193 |
|
194 |
def push():
|
195 |
global repo, lock
|
@@ -299,7 +307,7 @@ with gr.Blocks() as demo:
|
|
299 |
|
300 |
Type a commonsense statement in the box below and click the submit button to see Vera's prediction on its correctness. You can try both correct and incorrect statements. If you are looking for inspiration, try the examples at the bottom of the page!
|
301 |
|
302 |
-
We
|
303 |
|
304 |
β οΈ **Intended Use**: Vera is a research prototype and may make mistakes. Do not use for making critical decisions. It is intended to predict the correctness of commonsense statements, and may be unreliable when taking input out of this scope.
|
305 |
|
@@ -319,8 +327,11 @@ with gr.Blocks() as demo:
|
|
319 |
output_raw = gr.JSON(visible=False)
|
320 |
with gr.Row():
|
321 |
feedback_agree = gr.Button(value='π Agree', variant='secondary', visible=False)
|
|
|
322 |
feedback_disagree = gr.Button(value='π Disagree', variant='secondary', visible=False)
|
|
|
323 |
feedback_ack = gr.Markdown(value='', visible=True, interactive=False)
|
|
|
324 |
with gr.Row():
|
325 |
gr.Examples(
|
326 |
examples=examples,
|
@@ -331,10 +342,12 @@ with gr.Blocks() as demo:
|
|
331 |
cache_examples=False,
|
332 |
run_on_click=False, # If we want this to be True, I suspect we need to enable the statement.submit()
|
333 |
)
|
334 |
-
submit.click(predict, inputs=[statement, do_save], outputs=[output, output_raw, submit, feedback_agree, feedback_disagree, feedback_ack], batch=True, max_batch_size=16)
|
335 |
# statement.submit(predict, inputs=[statement], outputs=[output, output_raw])
|
336 |
-
feedback_agree.click(record_feedback_agree, inputs=[output_raw, do_save], outputs=[submit, feedback_agree, feedback_disagree, feedback_ack], batch=True, max_batch_size=16)
|
337 |
-
|
|
|
|
|
338 |
|
339 |
demo.load(push, inputs=None, outputs=None, every=60) # Push to git every 60 seconds
|
340 |
|
|
|
167 |
[gr.update(visible=False) for _ in statements], \
|
168 |
[gr.update(visible=True) for _ in statements], \
|
169 |
[gr.update(visible=True) for _ in statements], \
|
170 |
+
[gr.update(visible=True) for _ in statements], \
|
171 |
+
[gr.update(visible=True) for _ in statements], \
|
172 |
[gr.update(value='Please share your feedback before trying out another statement.') for _ in statements]
|
173 |
|
174 |
def record_feedback(output_raws, feedback, do_saves):
|
|
|
185 |
print()
|
186 |
lock.release()
|
187 |
return [gr.update(visible=True) for _ in output_raws], \
|
188 |
+
[gr.update(visible=False) for _ in output_raws], \
|
189 |
+
[gr.update(visible=False) for _ in output_raws], \
|
190 |
[gr.update(visible=False) for _ in output_raws], \
|
191 |
[gr.update(visible=False) for _ in output_raws], \
|
192 |
[gr.update(value='Thanks for sharing your feedback! You can now enter another statement.') for _ in output_raws]
|
|
|
194 |
return record_feedback(output_raws, 'agree', do_saves)
|
195 |
def record_feedback_disagree(output_raws, do_saves):
|
196 |
return record_feedback(output_raws, 'disagree', do_saves)
|
197 |
+
def record_feedback_uncertain(output_raws, do_saves):
|
198 |
+
return record_feedback(output_raws, 'uncertain', do_saves)
|
199 |
+
def record_feedback_outofscope(output_raws, do_saves):
|
200 |
+
return record_feedback(output_raws, 'outofscope', do_saves)
|
201 |
|
202 |
def push():
|
203 |
global repo, lock
|
|
|
307 |
|
308 |
Type a commonsense statement in the box below and click the submit button to see Vera's prediction on its correctness. You can try both correct and incorrect statements. If you are looking for inspiration, try the examples at the bottom of the page!
|
309 |
|
310 |
+
We'd love your feedback! Please indicate whether you agree or disagree with Vera's prediction (and don't mind the percentage numbers).
|
311 |
|
312 |
β οΈ **Intended Use**: Vera is a research prototype and may make mistakes. Do not use for making critical decisions. It is intended to predict the correctness of commonsense statements, and may be unreliable when taking input out of this scope.
|
313 |
|
|
|
327 |
output_raw = gr.JSON(visible=False)
|
328 |
with gr.Row():
|
329 |
feedback_agree = gr.Button(value='π Agree', variant='secondary', visible=False)
|
330 |
+
feedback_uncertain = gr.Button(value='π€ Uncertain', variant='secondary', visible=False)
|
331 |
feedback_disagree = gr.Button(value='π Disagree', variant='secondary', visible=False)
|
332 |
+
feedback_outofscope = gr.Button(value='π« This is not a statement about commonsense', variant='stop', visible=False)
|
333 |
feedback_ack = gr.Markdown(value='', visible=True, interactive=False)
|
334 |
+
gr.Markdown('\n---\n')
|
335 |
with gr.Row():
|
336 |
gr.Examples(
|
337 |
examples=examples,
|
|
|
342 |
cache_examples=False,
|
343 |
run_on_click=False, # If we want this to be True, I suspect we need to enable the statement.submit()
|
344 |
)
|
345 |
+
submit.click(predict, inputs=[statement, do_save], outputs=[output, output_raw, submit, feedback_agree, feedback_uncertain, feedback_disagree, feedback_outofscope, feedback_ack], batch=True, max_batch_size=16)
|
346 |
# statement.submit(predict, inputs=[statement], outputs=[output, output_raw])
|
347 |
+
feedback_agree.click(record_feedback_agree, inputs=[output_raw, do_save], outputs=[submit, feedback_agree, feedback_uncertain, feedback_disagree, feedback_outofscope, feedback_ack], batch=True, max_batch_size=16)
|
348 |
+
feedback_uncertain.click(record_feedback_uncertain, inputs=[output_raw, do_save], outputs=[submit, feedback_agree, feedback_uncertain, feedback_disagree, feedback_outofscope, feedback_ack], batch=True, max_batch_size=16)
|
349 |
+
feedback_disagree.click(record_feedback_disagree, inputs=[output_raw, do_save], outputs=[submit, feedback_agree, feedback_uncertain, feedback_disagree, feedback_outofscope, feedback_ack], batch=True, max_batch_size=16)
|
350 |
+
feedback_outofscope.click(record_feedback_outofscope, inputs=[output_raw, do_save], outputs=[submit, feedback_agree, feedback_uncertain, feedback_disagree, feedback_outofscope, feedback_ack], batch=True, max_batch_size=16)
|
351 |
|
352 |
demo.load(push, inputs=None, outputs=None, every=60) # Push to git every 60 seconds
|
353 |
|