mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
* sort imports * update --------- Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> Co-authored-by: Eduardo Chiarotti <dudumelgaco@hotmail.com>
31 lines
863 B
Python
31 lines
863 B
Python
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from crewai.tools.agent_tools.base_agent_tools import BaseAgentTool
|
|
|
|
|
|
class DelegateWorkToolSchema(BaseModel):
|
|
task: str = Field(..., description="The task to delegate")
|
|
context: str = Field(..., description="The context for the task")
|
|
coworker: str = Field(
|
|
..., description="The role/name of the coworker to delegate to"
|
|
)
|
|
|
|
|
|
class DelegateWorkTool(BaseAgentTool):
|
|
"""Tool for delegating work to coworkers"""
|
|
|
|
name: str = "Delegate work to coworker"
|
|
args_schema: type[BaseModel] = DelegateWorkToolSchema
|
|
|
|
def _run(
|
|
self,
|
|
task: str,
|
|
context: str,
|
|
coworker: Optional[str] = None,
|
|
**kwargs,
|
|
) -> str:
|
|
coworker = self._get_coworker(coworker, **kwargs)
|
|
return self._execute(coworker, task, context)
|