Spaces:
Configuration error
Configuration error
oremaz
commited on
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -431,13 +431,13 @@ def execute_python_code(code: str) -> str:
|
|
| 431 |
"concurrent": __import__("concurrent"),
|
| 432 |
}
|
| 433 |
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
|
| 442 |
except Exception as e:
|
| 443 |
return f"Code execution failed: {str(e)}"
|
|
|
|
| 431 |
"concurrent": __import__("concurrent"),
|
| 432 |
}
|
| 433 |
|
| 434 |
+
exec_locals = {}
|
| 435 |
+
exec(code, safe_globals, exec_locals)
|
| 436 |
+
|
| 437 |
+
if 'result' in exec_locals:
|
| 438 |
+
return str(exec_locals['result'])
|
| 439 |
+
else:
|
| 440 |
+
return "Code executed successfully"
|
| 441 |
|
| 442 |
except Exception as e:
|
| 443 |
return f"Code execution failed: {str(e)}"
|