Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -346,14 +346,14 @@ def extract_and_run_sympy_code(response_text):
|
|
| 346 |
logger.debug(f"Code after removing imports:\n{sympy_code}")
|
| 347 |
|
| 348 |
# Create globals dict with all SymPy symbols
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
|
|
|
| 353 |
|
| 354 |
-
# Add
|
| 355 |
-
for name in dir(sympy)
|
| 356 |
-
globals_dict[name] = getattr(sympy, name)
|
| 357 |
|
| 358 |
# Create locals dict to store variables
|
| 359 |
local_vars = {}
|
|
@@ -380,7 +380,7 @@ def extract_and_run_sympy_code(response_text):
|
|
| 380 |
import traceback
|
| 381 |
logger.error(f"Full traceback:\n{traceback.format_exc()}")
|
| 382 |
return f"Error executing SymPy code: {str(e)}"
|
| 383 |
-
|
| 384 |
|
| 385 |
# Create Gradio interface
|
| 386 |
with gr.Blocks() as interface:
|
|
|
|
| 346 |
logger.debug(f"Code after removing imports:\n{sympy_code}")
|
| 347 |
|
| 348 |
# Create globals dict with all SymPy symbols
|
| 349 |
+
import sys
|
| 350 |
+
globals_dict = {}
|
| 351 |
+
|
| 352 |
+
# Add built-ins
|
| 353 |
+
globals_dict['__builtins__'] = __builtins__
|
| 354 |
|
| 355 |
+
# Add sympy itself by loading it from sys.modules
|
| 356 |
+
globals_dict.update({name: value for name, value in globals().items() if name in dir(sys.modules['sympy'])})
|
|
|
|
| 357 |
|
| 358 |
# Create locals dict to store variables
|
| 359 |
local_vars = {}
|
|
|
|
| 380 |
import traceback
|
| 381 |
logger.error(f"Full traceback:\n{traceback.format_exc()}")
|
| 382 |
return f"Error executing SymPy code: {str(e)}"
|
| 383 |
+
|
| 384 |
|
| 385 |
# Create Gradio interface
|
| 386 |
with gr.Blocks() as interface:
|