Spaces:
Sleeping
Sleeping
Yu Chen commited on
Commit Β·
a6d1360
1
Parent(s): 4cf415d
rm unrelated code
Browse files- exam_maker/components/chat.py +13 -32
- problem_example/{chapter_details.csv β paragraph_details.csv} +0 -0
- problem_example/{chapter_structure.csv β paragraph_structure.csv} +0 -0
- problem_example/{chapter_summary.csv β paragraph_summary.csv} +0 -0
- prompt/{chapter_details.jinja β paragraph_details.jinja} +0 -0
- prompt/{chapter_structure.jinja β paragraph_structure.jinja} +0 -0
- prompt/{chapter_summary.jinja β paragraph_summary.jinja} +0 -0
exam_maker/components/chat.py
CHANGED
|
@@ -57,9 +57,9 @@ class Chat:
|
|
| 57 |
"word_comprehension": 0,
|
| 58 |
"grammatical_structure": 1,
|
| 59 |
"textual_inference": 2,
|
| 60 |
-
"
|
| 61 |
-
"
|
| 62 |
-
"
|
| 63 |
}
|
| 64 |
|
| 65 |
# For generating question
|
|
@@ -69,18 +69,12 @@ class Chat:
|
|
| 69 |
label="Question Type",
|
| 70 |
render=False
|
| 71 |
)
|
| 72 |
-
|
| 73 |
-
# self.difficulty_dropdown = gr.Dropdown(
|
| 74 |
-
# choices=["lower", "same", "higher"],
|
| 75 |
-
# value="same",
|
| 76 |
-
# label="Difficulty Level",
|
| 77 |
-
# render=False
|
| 78 |
-
# )
|
| 79 |
|
| 80 |
self.generate_question_button = gr.Button("Generate Question", render=False)
|
| 81 |
|
| 82 |
# For updating question
|
| 83 |
-
self.
|
| 84 |
choices=[], # Initialize with empty choices
|
| 85 |
label="Rewrite Question",
|
| 86 |
render=False
|
|
@@ -92,13 +86,7 @@ class Chat:
|
|
| 92 |
render=False
|
| 93 |
)
|
| 94 |
|
| 95 |
-
self.
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
# Keep the old buttons for reference but don't render them
|
| 99 |
-
# self.button1 = gr.Button("word_comprehension", elem_id="button1", visible=False, render=False)
|
| 100 |
-
# self.button2 = gr.Button("grammatical_structure", elem_id="button2", visible=False, render=False)
|
| 101 |
-
# self.button3 = gr.Button("textual_inference", elem_id="button3", visible=False, render=False)
|
| 102 |
|
| 103 |
self.submit_button = gr.Button("η’ηθι‘", elem_id="submit_button", render=False)
|
| 104 |
|
|
@@ -439,10 +427,9 @@ class Chat:
|
|
| 439 |
with gr.Row():
|
| 440 |
|
| 441 |
self.question_type_dropdown.render()
|
| 442 |
-
# self.difficulty_dropdown.render()
|
| 443 |
|
| 444 |
with gr.Row():
|
| 445 |
-
self.
|
| 446 |
self.update_question_dropdown.render()
|
| 447 |
|
| 448 |
self.prompt_preview = gr.Textbox(
|
|
@@ -456,7 +443,7 @@ class Chat:
|
|
| 456 |
)
|
| 457 |
|
| 458 |
self.generate_question_button.render()
|
| 459 |
-
self.
|
| 460 |
self.spinner.render()
|
| 461 |
|
| 462 |
# Right column
|
|
@@ -502,12 +489,6 @@ class Chat:
|
|
| 502 |
outputs=[self.prompt_preview]
|
| 503 |
)
|
| 504 |
|
| 505 |
-
# self.difficulty_dropdown.change(
|
| 506 |
-
# fn=self.update_prompt_preview,
|
| 507 |
-
# inputs=[self.question_type_dropdown, self.textbox],
|
| 508 |
-
# outputs=[self.prompt_preview]
|
| 509 |
-
# )
|
| 510 |
-
|
| 511 |
self.generate_question_button.click(
|
| 512 |
fn=lambda: gr.update(visible=True), # Show spinner
|
| 513 |
outputs=self.spinner,
|
|
@@ -520,7 +501,7 @@ class Chat:
|
|
| 520 |
).then(
|
| 521 |
fn=self._get_problem_choices,
|
| 522 |
inputs=[self.problem_list],
|
| 523 |
-
outputs=[self.
|
| 524 |
).then(
|
| 525 |
fn=lambda: gr.update(visible=False), # Hide spinner
|
| 526 |
outputs=self.spinner,
|
|
@@ -528,7 +509,7 @@ class Chat:
|
|
| 528 |
)
|
| 529 |
|
| 530 |
# Event handler for updating question
|
| 531 |
-
self.
|
| 532 |
fn=None, # No preview update for now, or a dedicated one
|
| 533 |
inputs=None,
|
| 534 |
outputs=None
|
|
@@ -546,18 +527,18 @@ class Chat:
|
|
| 546 |
# outputs=[self.prompt_preview]
|
| 547 |
)
|
| 548 |
|
| 549 |
-
self.
|
| 550 |
fn=lambda: gr.update(visible=True), # Show spinner
|
| 551 |
outputs=self.spinner,
|
| 552 |
show_progress=False,
|
| 553 |
).then(
|
| 554 |
fn=self.update_one_problem,
|
| 555 |
-
inputs=[self.
|
| 556 |
outputs=self.problem_list,
|
| 557 |
).then(
|
| 558 |
fn=self._get_problem_choices, # Update choices after modifying problem list
|
| 559 |
inputs=[self.problem_list],
|
| 560 |
-
outputs=[self.
|
| 561 |
).then(
|
| 562 |
fn=lambda: gr.update(visible=False), # Hide spinner
|
| 563 |
outputs=self.spinner,
|
|
|
|
| 57 |
"word_comprehension": 0,
|
| 58 |
"grammatical_structure": 1,
|
| 59 |
"textual_inference": 2,
|
| 60 |
+
"paragraph_summary": 3,
|
| 61 |
+
"paragraph_details": 4,
|
| 62 |
+
"paragraph_structure": 5
|
| 63 |
}
|
| 64 |
|
| 65 |
# For generating question
|
|
|
|
| 69 |
label="Question Type",
|
| 70 |
render=False
|
| 71 |
)
|
| 72 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
self.generate_question_button = gr.Button("Generate Question", render=False)
|
| 75 |
|
| 76 |
# For updating question
|
| 77 |
+
self.rewrite_question_dropdown = gr.Dropdown(
|
| 78 |
choices=[], # Initialize with empty choices
|
| 79 |
label="Rewrite Question",
|
| 80 |
render=False
|
|
|
|
| 86 |
render=False
|
| 87 |
)
|
| 88 |
|
| 89 |
+
self.rewrite_question_confirm_button = gr.Button("Update Question", render=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
self.submit_button = gr.Button("η’ηθι‘", elem_id="submit_button", render=False)
|
| 92 |
|
|
|
|
| 427 |
with gr.Row():
|
| 428 |
|
| 429 |
self.question_type_dropdown.render()
|
|
|
|
| 430 |
|
| 431 |
with gr.Row():
|
| 432 |
+
self.rewrite_question_dropdown.render()
|
| 433 |
self.update_question_dropdown.render()
|
| 434 |
|
| 435 |
self.prompt_preview = gr.Textbox(
|
|
|
|
| 443 |
)
|
| 444 |
|
| 445 |
self.generate_question_button.render()
|
| 446 |
+
self.rewrite_question_confirm_button.render()
|
| 447 |
self.spinner.render()
|
| 448 |
|
| 449 |
# Right column
|
|
|
|
| 489 |
outputs=[self.prompt_preview]
|
| 490 |
)
|
| 491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
self.generate_question_button.click(
|
| 493 |
fn=lambda: gr.update(visible=True), # Show spinner
|
| 494 |
outputs=self.spinner,
|
|
|
|
| 501 |
).then(
|
| 502 |
fn=self._get_problem_choices,
|
| 503 |
inputs=[self.problem_list],
|
| 504 |
+
outputs=[self.rewrite_question_dropdown]
|
| 505 |
).then(
|
| 506 |
fn=lambda: gr.update(visible=False), # Hide spinner
|
| 507 |
outputs=self.spinner,
|
|
|
|
| 509 |
)
|
| 510 |
|
| 511 |
# Event handler for updating question
|
| 512 |
+
self.rewrite_question_dropdown.change(
|
| 513 |
fn=None, # No preview update for now, or a dedicated one
|
| 514 |
inputs=None,
|
| 515 |
outputs=None
|
|
|
|
| 527 |
# outputs=[self.prompt_preview]
|
| 528 |
)
|
| 529 |
|
| 530 |
+
self.rewrite_question_confirm_button.click(
|
| 531 |
fn=lambda: gr.update(visible=True), # Show spinner
|
| 532 |
outputs=self.spinner,
|
| 533 |
show_progress=False,
|
| 534 |
).then(
|
| 535 |
fn=self.update_one_problem,
|
| 536 |
+
inputs=[self.rewrite_question_dropdown, self.update_question_dropdown, self.textbox, self.problem_list],
|
| 537 |
outputs=self.problem_list,
|
| 538 |
).then(
|
| 539 |
fn=self._get_problem_choices, # Update choices after modifying problem list
|
| 540 |
inputs=[self.problem_list],
|
| 541 |
+
outputs=[self.rewrite_question_dropdown]
|
| 542 |
).then(
|
| 543 |
fn=lambda: gr.update(visible=False), # Hide spinner
|
| 544 |
outputs=self.spinner,
|
problem_example/{chapter_details.csv β paragraph_details.csv}
RENAMED
|
File without changes
|
problem_example/{chapter_structure.csv β paragraph_structure.csv}
RENAMED
|
File without changes
|
problem_example/{chapter_summary.csv β paragraph_summary.csv}
RENAMED
|
File without changes
|
prompt/{chapter_details.jinja β paragraph_details.jinja}
RENAMED
|
File without changes
|
prompt/{chapter_structure.jinja β paragraph_structure.jinja}
RENAMED
|
File without changes
|
prompt/{chapter_summary.jinja β paragraph_summary.jinja}
RENAMED
|
File without changes
|