Leonydis137 commited on
Commit
8bbd177
·
verified ·
1 Parent(s): dffea45

Update agents/executor.py

Browse files
Files changed (1) hide show
  1. agents/executor.py +11 -13
agents/executor.py CHANGED
@@ -1,21 +1,19 @@
1
  import subprocess
2
 
3
  def execute_step(step):
4
- step_lower = step.lower()
5
- if "html" in step_lower:
6
- return "<html><body>Hello Multi-Agent World!</body></html>"
7
- elif "calculate" in step_lower:
8
  try:
9
- expression = step_lower.replace("calculate", "").strip()
10
- return str(eval(expression))
11
  except:
12
- return "Calculation error."
13
- elif "python" in step_lower or "code" in step_lower:
14
  try:
15
- code = step.split("```python")[1].split("```")[0] if "```python" in step else step
16
- result = subprocess.check_output(["python3", "-c", code], stderr=subprocess.STDOUT, timeout=5)
17
- return result.decode()
18
  except Exception as e:
19
- return f"Error running Python code: {e}"
20
  else:
21
- return f"No defined execution path for: {step}"
 
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."