-
-
Notifications
You must be signed in to change notification settings - Fork 984
Expand file tree
/
Copy pathrefactor_smoke_example.py
More file actions
69 lines (60 loc) · 1.56 KB
/
Copy pathrefactor_smoke_example.py
File metadata and controls
69 lines (60 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""Minimal example for `AgentRearrange`.
Exercises the list-based `self.agents` (post-refactor) with a flow that
mixes sequential and concurrent execution.
"""
from swarms import Agent
from swarms.structs.agent_rearrange import AgentRearrange
def main() -> None:
planner = Agent(
agent_name="Planner",
model_name="gpt-5.4",
max_loops=1,
print_on=False,
)
coder = Agent(
agent_name="Coder",
model_name="gpt-5.4",
max_loops=1,
print_on=False,
)
reviewer = Agent(
agent_name="Reviewer",
model_name="gpt-5.4",
max_loops=1,
print_on=False,
)
tester = Agent(
agent_name="Tester",
model_name="gpt-5.4",
max_loops=1,
print_on=False,
)
pipeline = AgentRearrange(
name="plan-code-review-test",
agents=[planner, coder, reviewer, tester],
flow="Planner -> Coder -> Reviewer, Tester",
max_loops=1,
)
# Mutation paths the refactor touched.
extra = Agent(
agent_name="Documenter",
model_name="gpt-5.4",
max_loops=1,
print_on=False,
)
pipeline.add_agent(extra)
print(
"agents after add:",
[a.agent_name for a in pipeline.agents],
)
pipeline.remove_agent("Documenter")
print(
"agents after remove:",
[a.agent_name for a in pipeline.agents],
)
result = pipeline.run(
"Build a Python function that validates an email address."
)
print("result:", result)
if __name__ == "__main__":
main()