atz21 commited on
Commit
751e0c1
ยท
verified ยท
1 Parent(s): 31f0335

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -3
app.py CHANGED
@@ -168,7 +168,9 @@ def generate_test(total_marks, topic_name, level):
168
  - **Topic Code**
169
  - **Maximum Marks**
170
  7. Display the full question content exactly as it appears in 'QP Content'.
171
- 8. Use the provided **TOPICS LIST** to identify relevant topic codes.
 
 
172
 
173
  **TOPICS LIST:**
174
  ---
@@ -181,6 +183,7 @@ def generate_test(total_marks, topic_name, level):
181
  ---
182
 
183
  Now, create the test based on the user's request, making sure to use the **latest available questions** first.
 
184
  """
185
 
186
  try:
@@ -189,6 +192,20 @@ def generate_test(total_marks, topic_name, level):
189
  except Exception as e:
190
  return f"An error occurred while communicating with the AI model: {e}"
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  # --- Gradio Interface ---
193
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
194
  gr.Markdown("# ๐Ÿ“ IB Mathematics Test Generator (Latest Question Priority)")
@@ -212,10 +229,16 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
212
  generate_button = gr.Button("Generate Test", variant="primary")
213
 
214
  with gr.Column(scale=3):
215
- output_markdown = gr.Markdown(label="Generated Test Paper")
 
 
 
 
 
 
216
 
217
  generate_button.click(
218
- fn=generate_test,
219
  inputs=[total_marks_input, topic_input, level_input],
220
  outputs=output_markdown
221
  )
 
168
  - **Topic Code**
169
  - **Maximum Marks**
170
  7. Display the full question content exactly as it appears in 'QP Content'.
171
+ 8. **IMPORTANT**: Keep all LaTeX mathematical expressions in their original LaTeX format using $ for inline math (e.g., $x^2$) and $$ for display math (e.g., $$\\frac{{a}}{{b}}$$). Do NOT convert LaTeX to plain text.
172
+ 9. Use proper markdown formatting with headers (##, ###), bullet points, and numbered lists for better readability.
173
+ 10. Use the provided **TOPICS LIST** to identify relevant topic codes.
174
 
175
  **TOPICS LIST:**
176
  ---
 
183
  ---
184
 
185
  Now, create the test based on the user's request, making sure to use the **latest available questions** first.
186
+ Ensure all mathematical notation remains in LaTeX format for proper rendering.
187
  """
188
 
189
  try:
 
192
  except Exception as e:
193
  return f"An error occurred while communicating with the AI model: {e}"
194
 
195
+ # --- Wrapper function for processing state ---
196
+ def generate_test_with_processing(total_marks, topic_name, level):
197
+ """
198
+ Wrapper function that shows processing message before generating test.
199
+ """
200
+ # This will be shown while processing
201
+ yield "## ๐Ÿ”„ Processing...\n\nGenerating your test paper. Please wait..."
202
+
203
+ # Generate the actual test
204
+ result = generate_test(total_marks, topic_name, level)
205
+
206
+ # Return the final result
207
+ yield result
208
+
209
  # --- Gradio Interface ---
210
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
211
  gr.Markdown("# ๐Ÿ“ IB Mathematics Test Generator (Latest Question Priority)")
 
229
  generate_button = gr.Button("Generate Test", variant="primary")
230
 
231
  with gr.Column(scale=3):
232
+ output_markdown = gr.Markdown(
233
+ label="Generated Test Paper",
234
+ latex_delimiters=[
235
+ {"left": "$$", "right": "$$", "display": True},
236
+ {"left": "$", "right": "$", "display": False}
237
+ ]
238
+ )
239
 
240
  generate_button.click(
241
+ fn=generate_test_with_processing,
242
  inputs=[total_marks_input, topic_input, level_input],
243
  outputs=output_markdown
244
  )