Chad commited on
Commit ·
a1eb5aa
1
Parent(s): e4e5406
blawewd
Browse files
app.py
CHANGED
|
@@ -47,6 +47,7 @@ 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 |
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 |
|
|
@@ -143,7 +144,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 |
+
num_questions = int(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 |
|
|
|
|
| 144 |
|
| 145 |
quiz_button.click(
|
| 146 |
fn=generate_quiz,
|
| 147 |
+
inputs=[quiz_subject, quiz_num_questions, state],
|
| 148 |
outputs=[chatbot, state]
|
| 149 |
)
|
| 150 |
|