joshuarauh commited on
Commit
8545288
·
verified ·
1 Parent(s): 8c94fd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
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
- # Get the captured output
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