mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Add support to delegate work
This commit is contained in:
@@ -22,17 +22,21 @@ class Task(BaseModel):
|
||||
|
||||
@root_validator(pre=False)
|
||||
def _set_tools(cls, values):
|
||||
if values.get('agent'):
|
||||
values['tools'] = values.get('agent.tools')
|
||||
if (values.get('agent')) and not (values.get('tools')):
|
||||
values['tools'] = values.get('agent').tools
|
||||
return values
|
||||
|
||||
def execute(self, context) -> str:
|
||||
def execute(self, context: str = None) -> str:
|
||||
"""
|
||||
Execute the task.
|
||||
Returns:
|
||||
output (str): Output of the task.
|
||||
"""
|
||||
if self.agent:
|
||||
return self.agent.execute_task(self.description, context)
|
||||
return self.agent.execute_task(
|
||||
task = self.description,
|
||||
context = context,
|
||||
tools = self.tools
|
||||
)
|
||||
else:
|
||||
raise Exception(f"The task '{self.description}' has no agent assigned, therefore it can't be executed directly and should be executed in a Crew using a specific process that support that, either consensual or hierarchical.")
|
||||
Reference in New Issue
Block a user