Chad commited on
Commit ·
555123d
1
Parent(s): 28e2ddf
i didnt
Browse files
app.py
CHANGED
|
@@ -47,7 +47,6 @@ def generate_reply(user_input, chat_history):
|
|
| 47 |
def generate_quiz(subject, num_questions, chat_history):
|
| 48 |
"""Generate a history quiz with multiple-choice questions and append it to the chat."""
|
| 49 |
try:
|
| 50 |
-
num_questions = str(num_questions)
|
| 51 |
prompt = f"Generate {num_questions} multiple-choice history questions about {subject}. "
|
| 52 |
prompt += "For each question, provide the question text, four options labeled A, B, C, and D, and at the end of all questions, list the correct answers in the format: 'Correct Answers: X, Y, Z, ...'."
|
| 53 |
|
|
@@ -125,12 +124,13 @@ with gr.Blocks() as interface:
|
|
| 125 |
|
| 126 |
|
| 127 |
def update_ui(language):
|
| 128 |
-
|
| 129 |
-
|
|
|
|
| 130 |
lang_button.click(
|
| 131 |
fn=update_ui,
|
| 132 |
inputs=[language_state],
|
| 133 |
-
outputs=[language_state, title, lang_button, user_input, send_button, reset_button
|
| 134 |
)
|
| 135 |
|
| 136 |
send_button.click(
|
|
@@ -143,7 +143,7 @@ with gr.Blocks() as interface:
|
|
| 143 |
|
| 144 |
quiz_button.click(
|
| 145 |
fn=generate_quiz,
|
| 146 |
-
inputs=[quiz_subject, quiz_num_questions
|
| 147 |
outputs=[chatbot, state]
|
| 148 |
)
|
| 149 |
|
|
|
|
| 47 |
def generate_quiz(subject, num_questions, chat_history):
|
| 48 |
"""Generate a history quiz with multiple-choice questions and append it to the chat."""
|
| 49 |
try:
|
|
|
|
| 50 |
prompt = f"Generate {num_questions} multiple-choice history questions about {subject}. "
|
| 51 |
prompt += "For each question, provide the question text, four options labeled A, B, C, and D, and at the end of all questions, list the correct answers in the format: 'Correct Answers: X, Y, Z, ...'."
|
| 52 |
|
|
|
|
| 124 |
|
| 125 |
|
| 126 |
def update_ui(language):
|
| 127 |
+
new_language, new_title, new_button_text, new_placeholder, new_send_label, new_reset_label = toggle_language(language)
|
| 128 |
+
return new_language, new_title, new_button_text, gr.update(placeholder=new_placeholder, value=""), new_send_label, new_reset_label
|
| 129 |
+
|
| 130 |
lang_button.click(
|
| 131 |
fn=update_ui,
|
| 132 |
inputs=[language_state],
|
| 133 |
+
outputs=[language_state, title, lang_button, user_input, send_button, reset_button]
|
| 134 |
)
|
| 135 |
|
| 136 |
send_button.click(
|
|
|
|
| 143 |
|
| 144 |
quiz_button.click(
|
| 145 |
fn=generate_quiz,
|
| 146 |
+
inputs=[quiz_subject, quiz_num_questions],
|
| 147 |
outputs=[chatbot, state]
|
| 148 |
)
|
| 149 |
|