Terry Zhuo
commited on
Commit
·
bb1048a
1
Parent(s):
dba3ac5
update
Browse files
app.py
CHANGED
|
@@ -84,7 +84,7 @@ def filter_data(data, keyword):
|
|
| 84 |
return filtered_data
|
| 85 |
|
| 86 |
|
| 87 |
-
def update_display(search_keyword, index,
|
| 88 |
filtered_data = filter_data(DATA, search_keyword)
|
| 89 |
|
| 90 |
if not filtered_data:
|
|
@@ -96,14 +96,14 @@ def update_display(search_keyword, index, show_solution, show_test):
|
|
| 96 |
task_id = filtered_data[index]['task_id']
|
| 97 |
snippet1 = filtered_data[index]['complete_prompt']
|
| 98 |
snippet2 = filtered_data[index]['instruct_prompt']
|
| 99 |
-
snippet3 = filtered_data[index]['canonical_solution'] if show_solution else ""
|
| 100 |
snippet4 = filtered_data[index]['test'] if show_test else ""
|
| 101 |
|
| 102 |
return [
|
| 103 |
task_id,
|
| 104 |
snippet1,
|
| 105 |
snippet2,
|
| 106 |
-
snippet3,
|
| 107 |
snippet4,
|
| 108 |
len(filtered_data),
|
| 109 |
gr.update(maximum=max_index, value=index)
|
|
@@ -485,27 +485,27 @@ with main_block as demo:
|
|
| 485 |
search_input = gr.Textbox(label="Search by keyword")
|
| 486 |
count_output = gr.Number(label="Number of filtered items")
|
| 487 |
index_slider = gr.Slider(minimum=0, maximum=len(DATA)-1, step=1, label="Select Index")
|
| 488 |
-
show_solution = gr.Checkbox(label="Show Solution")
|
| 489 |
show_test = gr.Checkbox(label="Show Test Cases")
|
| 490 |
update_button = gr.Button("Update Display")
|
| 491 |
|
| 492 |
task_id_output = gr.Textbox(label="Task ID")
|
| 493 |
code_completion = gr.Code(language="python", label="Code Completion")
|
| 494 |
nl_instruction = gr.Code(language="python", label="Natural Language Instruction")
|
| 495 |
-
solution = gr.Code(language="python", label="Solution")
|
| 496 |
test_cases = gr.Code(language="python", label="Test Cases")
|
| 497 |
|
| 498 |
update_button.click(
|
| 499 |
update_display,
|
| 500 |
-
inputs=[search_input, index_slider,
|
| 501 |
-
outputs=[task_id_output, code_completion, nl_instruction,
|
| 502 |
)
|
| 503 |
|
| 504 |
# Initial load
|
| 505 |
demo.load(
|
| 506 |
update_display,
|
| 507 |
-
inputs=[search_input, index_slider,
|
| 508 |
-
outputs=[task_id_output, code_completion, nl_instruction,
|
| 509 |
)
|
| 510 |
|
| 511 |
with gr.TabItem("🚀 Request", id=4):
|
|
|
|
| 84 |
return filtered_data
|
| 85 |
|
| 86 |
|
| 87 |
+
def update_display(search_keyword, index, show_test):
|
| 88 |
filtered_data = filter_data(DATA, search_keyword)
|
| 89 |
|
| 90 |
if not filtered_data:
|
|
|
|
| 96 |
task_id = filtered_data[index]['task_id']
|
| 97 |
snippet1 = filtered_data[index]['complete_prompt']
|
| 98 |
snippet2 = filtered_data[index]['instruct_prompt']
|
| 99 |
+
# snippet3 = filtered_data[index]['canonical_solution'] if show_solution else ""
|
| 100 |
snippet4 = filtered_data[index]['test'] if show_test else ""
|
| 101 |
|
| 102 |
return [
|
| 103 |
task_id,
|
| 104 |
snippet1,
|
| 105 |
snippet2,
|
| 106 |
+
# snippet3,
|
| 107 |
snippet4,
|
| 108 |
len(filtered_data),
|
| 109 |
gr.update(maximum=max_index, value=index)
|
|
|
|
| 485 |
search_input = gr.Textbox(label="Search by keyword")
|
| 486 |
count_output = gr.Number(label="Number of filtered items")
|
| 487 |
index_slider = gr.Slider(minimum=0, maximum=len(DATA)-1, step=1, label="Select Index")
|
| 488 |
+
# show_solution = gr.Checkbox(label="Show Solution")
|
| 489 |
show_test = gr.Checkbox(label="Show Test Cases")
|
| 490 |
update_button = gr.Button("Update Display")
|
| 491 |
|
| 492 |
task_id_output = gr.Textbox(label="Task ID")
|
| 493 |
code_completion = gr.Code(language="python", label="Code Completion")
|
| 494 |
nl_instruction = gr.Code(language="python", label="Natural Language Instruction")
|
| 495 |
+
# solution = gr.Code(language="python", label="Solution")
|
| 496 |
test_cases = gr.Code(language="python", label="Test Cases")
|
| 497 |
|
| 498 |
update_button.click(
|
| 499 |
update_display,
|
| 500 |
+
inputs=[search_input, index_slider, show_test],
|
| 501 |
+
outputs=[task_id_output, code_completion, nl_instruction, test_cases, count_output, index_slider]
|
| 502 |
)
|
| 503 |
|
| 504 |
# Initial load
|
| 505 |
demo.load(
|
| 506 |
update_display,
|
| 507 |
+
inputs=[search_input, index_slider, show_test],
|
| 508 |
+
outputs=[task_id_output, code_completion, nl_instruction, test_cases, count_output, index_slider]
|
| 509 |
)
|
| 510 |
|
| 511 |
with gr.TabItem("🚀 Request", id=4):
|