Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -332,6 +332,11 @@ def extract_and_run_sympy_code(response_text):
|
|
| 332 |
|
| 333 |
sympy_code = response_text[code_start:code_end].strip()
|
| 334 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
# Create a string buffer to capture print output
|
| 336 |
import io
|
| 337 |
import sys
|
|
@@ -362,7 +367,7 @@ def extract_and_run_sympy_code(response_text):
|
|
| 362 |
|
| 363 |
except Exception as e:
|
| 364 |
return f"Error executing SymPy code: {str(e)}"
|
| 365 |
-
|
| 366 |
# Create Gradio interface
|
| 367 |
with gr.Blocks() as interface:
|
| 368 |
gr.Markdown("# Advanced Mathematics Question Generator")
|
|
|
|
| 332 |
|
| 333 |
sympy_code = response_text[code_start:code_end].strip()
|
| 334 |
|
| 335 |
+
# Remove any sympy import lines since we've already imported everything
|
| 336 |
+
sympy_code = '\n'.join(line for line in sympy_code.split('\n')
|
| 337 |
+
if not line.strip().startswith('from sympy')
|
| 338 |
+
and not line.strip().startswith('import sympy'))
|
| 339 |
+
|
| 340 |
# Create a string buffer to capture print output
|
| 341 |
import io
|
| 342 |
import sys
|
|
|
|
| 367 |
|
| 368 |
except Exception as e:
|
| 369 |
return f"Error executing SymPy code: {str(e)}"
|
| 370 |
+
|
| 371 |
# Create Gradio interface
|
| 372 |
with gr.Blocks() as interface:
|
| 373 |
gr.Markdown("# Advanced Mathematics Question Generator")
|