knox revisou este gist . Ir para a revisão
1 file changed, 46 insertions
CrewAI-readme-8.py(arquivo criado)
@@ -0,0 +1,46 @@ | |||
1 | + | # src/my_project/crew.py | |
2 | + | from crewai import Agent, Crew, Process, Task | |
3 | + | from crewai.project import CrewBase, agent, crew, task | |
4 | + | from crewai_tools import SerperDevTool | |
5 | + | ||
6 | + | @CrewBase | |
7 | + | class LatestAiDevelopmentCrew(): | |
8 | + | """LatestAiDevelopment crew""" | |
9 | + | ||
10 | + | @agent | |
11 | + | def researcher(self) -> Agent: | |
12 | + | return Agent( | |
13 | + | config=self.agents_config['researcher'], | |
14 | + | verbose=True, | |
15 | + | tools=[SerperDevTool()] | |
16 | + | ) | |
17 | + | ||
18 | + | @agent | |
19 | + | def reporting_analyst(self) -> Agent: | |
20 | + | return Agent( | |
21 | + | config=self.agents_config['reporting_analyst'], | |
22 | + | verbose=True | |
23 | + | ) | |
24 | + | ||
25 | + | @task | |
26 | + | def research_task(self) -> Task: | |
27 | + | return Task( | |
28 | + | config=self.tasks_config['research_task'], | |
29 | + | ) | |
30 | + | ||
31 | + | @task | |
32 | + | def reporting_task(self) -> Task: | |
33 | + | return Task( | |
34 | + | config=self.tasks_config['reporting_task'], | |
35 | + | output_file='report.md' | |
36 | + | ) | |
37 | + | ||
38 | + | @crew | |
39 | + | def crew(self) -> Crew: | |
40 | + | """Creates the LatestAiDevelopment crew""" | |
41 | + | return Crew( | |
42 | + | agents=self.agents, # Automatically created by the @agent decorator | |
43 | + | tasks=self.tasks, # Automatically created by the @task decorator | |
44 | + | process=Process.sequential, | |
45 | + | verbose=True, | |
46 | + | ) |
Próximo
Anterior