Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -368,14 +368,14 @@ def extract_and_run_sympy_code(response_text):
|
|
368 |
try:
|
369 |
# Execute the code and capture all output in one redirect_stdout block
|
370 |
with redirect_stdout(output_buffer):
|
371 |
-
# First print a header
|
372 |
print("SymPy Calculation Results:")
|
373 |
print("-" * 25)
|
374 |
|
375 |
# Execute the code
|
376 |
exec(sympy_code, globals_dict, local_vars)
|
377 |
|
378 |
-
# Print all variables created
|
|
|
379 |
for var_name, value in local_vars.items():
|
380 |
if (not var_name.startswith('__') and
|
381 |
not hasattr(value, '__module__')):
|
@@ -391,8 +391,7 @@ def extract_and_run_sympy_code(response_text):
|
|
391 |
logger.error(f"Other error during execution: {str(e)}")
|
392 |
return f"Error executing SymPy code: {str(e)}"
|
393 |
|
394 |
-
|
395 |
-
result = output_buffer.getvalue()
|
396 |
logger.debug(f"Final output:\n{result}")
|
397 |
return result
|
398 |
|
|
|
368 |
try:
|
369 |
# Execute the code and capture all output in one redirect_stdout block
|
370 |
with redirect_stdout(output_buffer):
|
|
|
371 |
print("SymPy Calculation Results:")
|
372 |
print("-" * 25)
|
373 |
|
374 |
# Execute the code
|
375 |
exec(sympy_code, globals_dict, local_vars)
|
376 |
|
377 |
+
# Print all variables that were created
|
378 |
+
print("\nFinal Values:")
|
379 |
for var_name, value in local_vars.items():
|
380 |
if (not var_name.startswith('__') and
|
381 |
not hasattr(value, '__module__')):
|
|
|
391 |
logger.error(f"Other error during execution: {str(e)}")
|
392 |
return f"Error executing SymPy code: {str(e)}"
|
393 |
|
394 |
+
result = output_buffer.getvalue().strip()
|
|
|
395 |
logger.debug(f"Final output:\n{result}")
|
396 |
return result
|
397 |
|