Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,11 +83,19 @@ def retrieve_and_generate_quiz(question_difficulty, topic):
|
|
| 83 |
documents_str = '\n'.join(documents)
|
| 84 |
quiz_data = generate_quiz_data(question_difficulty, topic, documents_str)
|
| 85 |
if not quiz_data or not quiz_data.items:
|
| 86 |
-
return "Error: Failed to generate quiz."
|
| 87 |
|
| 88 |
-
#
|
| 89 |
-
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
with gr.Blocks(title="Quiz Generator Test") as QUIZBOT:
|
| 93 |
with gr.Row():
|
|
@@ -97,7 +105,7 @@ with gr.Blocks(title="Quiz Generator Test") as QUIZBOT:
|
|
| 97 |
difficulty_radio = gr.Radio(["easy", "average", "hard"], label="How difficult should the quiz be?")
|
| 98 |
|
| 99 |
generate_quiz_btn = gr.Button("Generate Quiz")
|
| 100 |
-
quiz_output = gr.
|
| 101 |
|
| 102 |
# Register the click event without @ decorator
|
| 103 |
generate_quiz_btn.click(
|
|
|
|
| 83 |
documents_str = '\n'.join(documents)
|
| 84 |
quiz_data = generate_quiz_data(question_difficulty, topic, documents_str)
|
| 85 |
if not quiz_data or not quiz_data.items:
|
| 86 |
+
return gr.update(value="Error: Failed to generate quiz.", visible=True)
|
| 87 |
|
| 88 |
+
# Generate HTML for questions and choices
|
| 89 |
+
html_content = "<div style='font-family: Arial, sans-serif; padding: 10px;'>"
|
| 90 |
+
for i, item in enumerate(quiz_data.items[:10], 1):
|
| 91 |
+
html_content += f"<h3>Question {i}: {item.question}</h3>"
|
| 92 |
+
html_content += "<ul style='list-style-type: none;'>"
|
| 93 |
+
for j, choice in enumerate(item.choices, 1):
|
| 94 |
+
html_content += f"<li>C{j}: {choice}</li>"
|
| 95 |
+
html_content += "</ul>"
|
| 96 |
+
html_content += "</div>"
|
| 97 |
+
|
| 98 |
+
return gr.update(value=html_content, visible=True)
|
| 99 |
|
| 100 |
with gr.Blocks(title="Quiz Generator Test") as QUIZBOT:
|
| 101 |
with gr.Row():
|
|
|
|
| 105 |
difficulty_radio = gr.Radio(["easy", "average", "hard"], label="How difficult should the quiz be?")
|
| 106 |
|
| 107 |
generate_quiz_btn = gr.Button("Generate Quiz")
|
| 108 |
+
quiz_output = gr.HTML(visible=False)
|
| 109 |
|
| 110 |
# Register the click event without @ decorator
|
| 111 |
generate_quiz_btn.click(
|