from crewai import Agent, Crew, Task, Process
from crewai.project import CrewBase, agent, task, crew, tool, llm
from crewai.agents.agent_builder.base_agent import BaseAgent
from crewai.tools import BaseTool
from typing import List
@CrewBase
class YourCrewName:
"""Description of your crew"""
agents: List[BaseAgent]
tasks: List[Task]
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
@agent
def clown(self) -> Agent:
return Agent(
config=self.agents_config['clown'], # type: ignore[index]
verbose=True
)
@task
def joke_task(self) -> Task:
return Task(
config=self.tasks_config['joke_task'] # type: ignore[index]
)
#
# 👇👇👇
#
@tool
def JokerTool(self) -> BaseTool:
return JokerTool()
@crew
def crew(self) -> Crew:
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.sequential,
verbose=True,
)
See the technical discussion here.