Terry Zhuo
commited on
Commit
·
3a99615
1
Parent(s):
e2e46b9
add next and prev
Browse files
app.py
CHANGED
@@ -490,6 +490,8 @@ with main_block as demo:
|
|
490 |
# show_solution = gr.Checkbox(label="Show Solution")
|
491 |
show_test = gr.Checkbox(label="Show Test Cases")
|
492 |
update_button = gr.Button("Update")
|
|
|
|
|
493 |
|
494 |
task_id_output = gr.Textbox(label="Task ID")
|
495 |
code_completion = gr.Code(language="python", label="Code Completion")
|
@@ -502,7 +504,16 @@ with main_block as demo:
|
|
502 |
inputs=[search_input, index_slider, show_test],
|
503 |
outputs=[task_id_output, code_completion, nl_instruction, test_cases, count_output, index_slider]
|
504 |
)
|
505 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
# Initial load
|
507 |
demo.load(
|
508 |
update_display,
|
|
|
490 |
# show_solution = gr.Checkbox(label="Show Solution")
|
491 |
show_test = gr.Checkbox(label="Show Test Cases")
|
492 |
update_button = gr.Button("Update")
|
493 |
+
next_button = gr.Button("Next")
|
494 |
+
prev_button = gr.Button("Prev")
|
495 |
|
496 |
task_id_output = gr.Textbox(label="Task ID")
|
497 |
code_completion = gr.Code(language="python", label="Code Completion")
|
|
|
504 |
inputs=[search_input, index_slider, show_test],
|
505 |
outputs=[task_id_output, code_completion, nl_instruction, test_cases, count_output, index_slider]
|
506 |
)
|
507 |
+
next_button.click(
|
508 |
+
update_display,
|
509 |
+
inputs=[search_input, gr.Number(value=index_slider.value + 1), show_test],
|
510 |
+
outputs=[task_id_output, code_completion, nl_instruction, test_cases, count_output, index_slider]
|
511 |
+
)
|
512 |
+
prev_button.click(
|
513 |
+
update_display,
|
514 |
+
inputs=[search_input, gr.Number(value=index_slider.value - 1), show_test],
|
515 |
+
outputs=[task_id_output, code_completion, nl_instruction, test_cases, count_output, index_slider]
|
516 |
+
)
|
517 |
# Initial load
|
518 |
demo.load(
|
519 |
update_display,
|