Spaces:
Runtime error
Runtime error
Update agents/executor.py
Browse files- agents/executor.py +11 -13
agents/executor.py
CHANGED
@@ -1,21 +1,19 @@
|
|
1 |
import subprocess
|
2 |
|
3 |
def execute_step(step):
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
elif "calculate" in step_lower:
|
8 |
try:
|
9 |
-
expression =
|
10 |
-
return
|
11 |
except:
|
12 |
-
return "Calculation
|
13 |
-
elif "python" in
|
14 |
try:
|
15 |
-
code = step.split("```python")[1].split("```")[0]
|
16 |
-
|
17 |
-
return result.decode()
|
18 |
except Exception as e:
|
19 |
-
return f"
|
20 |
else:
|
21 |
-
return
|
|
|
1 |
import subprocess
|
2 |
|
3 |
def execute_step(step):
|
4 |
+
if "create html" in step.lower():
|
5 |
+
return "<html><body>Hello World</body></html>"
|
6 |
+
elif "calculate" in step.lower():
|
|
|
7 |
try:
|
8 |
+
expression = step.lower().replace("calculate", "").strip()
|
9 |
+
return eval(expression)
|
10 |
except:
|
11 |
+
return "Calculation failed."
|
12 |
+
elif "python" in step.lower():
|
13 |
try:
|
14 |
+
code = step.split("```python")[1].split("```")[0]
|
15 |
+
return subprocess.check_output(["python3", "-c", code], timeout=5).decode()
|
|
|
16 |
except Exception as e:
|
17 |
+
return f"Python execution failed: {e}"
|
18 |
else:
|
19 |
+
return "Unrecognized task."
|