Repository navigation
Expand file tree
/
Copy pathexample_concurrent.py
More file actions
51 lines (43 loc) · 1.62 KB
/
Copy pathexample_concurrent.py
File metadata and controls
51 lines (43 loc) · 1.62 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
"""
Concurrent Multi-Agent Example
This example demonstrates concurrent execution using ConcurrentWorkflow,
where multiple agents work simultaneously on the same task and results are aggregated.
Use Case: Market analysis where multiple agents analyze different sectors in parallel.
"""
from swarms import Agent
from swarms.structs import ConcurrentWorkflow
# Create specialized agents for concurrent analysis
tech_analyst = Agent(
agent_name="Tech-Analyst",
agent_description="Expert in technology sector analysis",
model_name="gpt-5.4",
max_loops=1,
system_prompt="You are a technology sector analyst. Provide detailed analysis of tech market trends.",
)
finance_analyst = Agent(
agent_name="Finance-Analyst",
agent_description="Expert in financial sector analysis",
model_name="gpt-5.4",
max_loops=1,
system_prompt="You are a financial sector analyst. Provide detailed analysis of finance market trends.",
)
healthcare_analyst = Agent(
agent_name="Healthcare-Analyst",
agent_description="Expert in healthcare sector analysis",
model_name="gpt-5.4",
max_loops=1,
system_prompt="You are a healthcare sector analyst. Provide detailed analysis of healthcare market trends.",
)
# Build the concurrent workflow
workflow = ConcurrentWorkflow(
agents=[tech_analyst, finance_analyst, healthcare_analyst],
name="Market-Analysis-Workflow",
description="Concurrent analysis of technology, finance, and healthcare sectors.",
output_type="all",
autosave=True,
verbose=False,
)
out = workflow.run(
"Analyze the market for technology, finance, and healthcare sectors"
)
print(out)