Spaces:
Sleeping
Sleeping
Create crew.py
Browse files- agents/crew.py +48 -0
agents/crew.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Crew, Task
|
| 2 |
+
|
| 3 |
+
from agents.planner_agent import create_planner_agent
|
| 4 |
+
from agents.researcher_agent import create_researcher_agent
|
| 5 |
+
from agents.developer_agent import create_developer_agent
|
| 6 |
+
from agents.critic_agent import create_critic_agent
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def build_crew(vector_db):
|
| 10 |
+
planner = create_planner_agent()
|
| 11 |
+
researcher = create_researcher_agent(vector_db)
|
| 12 |
+
developer = create_developer_agent()
|
| 13 |
+
critic = create_critic_agent()
|
| 14 |
+
|
| 15 |
+
planning_task = Task(
|
| 16 |
+
description="Analyze the user query and create a solution plan.",
|
| 17 |
+
expected_output="Structured execution plan",
|
| 18 |
+
agent=planner,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
research_task = Task(
|
| 22 |
+
description="Retrieve relevant code snippets and documentation.",
|
| 23 |
+
expected_output="Relevant code context",
|
| 24 |
+
agent=researcher,
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
development_task = Task(
|
| 28 |
+
description="Generate or debug code based on findings.",
|
| 29 |
+
expected_output="Working code solution",
|
| 30 |
+
agent=developer,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
review_task = Task(
|
| 34 |
+
description="Review and improve the generated solution.",
|
| 35 |
+
expected_output="Optimized final response",
|
| 36 |
+
agent=critic,
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
return Crew(
|
| 40 |
+
agents=[planner, researcher, developer, critic],
|
| 41 |
+
tasks=[
|
| 42 |
+
planning_task,
|
| 43 |
+
research_task,
|
| 44 |
+
development_task,
|
| 45 |
+
review_task,
|
| 46 |
+
],
|
| 47 |
+
verbose=True,
|
| 48 |
+
)
|