-
-
Notifications
You must be signed in to change notification settings - Fork 541
/
Copy pathhybrid_hiearchical_swarm.py
125 lines (108 loc) · 3.7 KB
/
hybrid_hiearchical_swarm.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
from swarms import Agent, SwarmRouter
from swarms.structs.hybrid_hiearchical_peer_swarm import (
HybridHierarchicalClusterSwarm,
)
# Core Legal Agent Definitions with short, simple prompts
litigation_agent = Agent(
agent_name="Litigator",
system_prompt="You handle lawsuits. Analyze facts, build arguments, and develop case strategy.",
model_name="gpt-4o-mini",
auto_generate_prompt=False,
max_loops=1,
)
corporate_agent = Agent(
agent_name="Corporate-Attorney",
system_prompt="You handle business law. Advise on corporate structure, governance, and transactions.",
model_name="gpt-4o-mini",
auto_generate_prompt=False,
max_loops=1,
)
ip_agent = Agent(
agent_name="IP-Attorney",
system_prompt="You protect intellectual property. Handle patents, trademarks, copyrights, and trade secrets.",
model_name="gpt-4o-mini",
auto_generate_prompt=False,
max_loops=1,
)
employment_agent = Agent(
agent_name="Employment-Attorney",
system_prompt="You handle workplace matters. Address hiring, termination, discrimination, and labor issues.",
model_name="gpt-4o-mini",
auto_generate_prompt=False,
max_loops=1,
)
paralegal_agent = Agent(
agent_name="Paralegal",
system_prompt="You assist attorneys. Conduct research, draft documents, and organize case files.",
model_name="gpt-4o-mini",
auto_generate_prompt=False,
max_loops=1,
)
doc_review_agent = Agent(
agent_name="Document-Reviewer",
system_prompt="You examine documents. Extract key information and identify relevant content.",
model_name="gpt-4o-mini",
auto_generate_prompt=False,
max_loops=1,
)
# Practice Area Swarm Routers
litigation_swarm = SwarmRouter(
name="litigation-practice",
description="Handle all aspects of litigation",
agents=[litigation_agent, paralegal_agent, doc_review_agent],
swarm_type="SequentialWorkflow",
)
corporate_swarm = SwarmRouter(
name="corporate-practice",
description="Handle business and corporate legal matters",
agents=[corporate_agent, paralegal_agent],
swarm_type="SequentialWorkflow",
)
ip_swarm = SwarmRouter(
name="ip-practice",
description="Handle intellectual property matters",
agents=[ip_agent, paralegal_agent],
swarm_type="SequentialWorkflow",
)
employment_swarm = SwarmRouter(
name="employment-practice",
description="Handle employment and labor law matters",
agents=[employment_agent, paralegal_agent],
swarm_type="SequentialWorkflow",
)
# Cross-functional Swarm Router
m_and_a_swarm = SwarmRouter(
name="mergers-acquisitions",
description="Handle mergers and acquisitions",
agents=[
corporate_agent,
ip_agent,
employment_agent,
doc_review_agent,
],
swarm_type="ConcurrentWorkflow",
)
dispute_swarm = SwarmRouter(
name="dispute-resolution",
description="Handle complex disputes requiring multiple specialties",
agents=[litigation_agent, corporate_agent, doc_review_agent],
swarm_type="ConcurrentWorkflow",
)
hybrid_hiearchical_swarm = HybridHierarchicalClusterSwarm(
name="hybrid-hiearchical-swarm",
description="A hybrid hiearchical swarm that uses a hybrid hiearchical peer model to solve complex tasks.",
swarms=[
litigation_swarm,
corporate_swarm,
ip_swarm,
employment_swarm,
m_and_a_swarm,
dispute_swarm,
],
max_loops=1,
router_agent_model_name="gpt-4o-mini",
)
if __name__ == "__main__":
hybrid_hiearchical_swarm.run(
"What are the most effective methods for filing a patent in the field of AI technology? Please provide a list of user-friendly platforms that facilitate the patent filing process, along with their website links."
)