Refractoring (#88)

Co-authored-by: João Moura <joaomdmoura@gmail.com>
This commit is contained in:
SashaXser
2024-01-10 07:04:13 +04:00
committed by GitHub
parent ae385eca06
commit f6de0928c4
6 changed files with 16 additions and 28 deletions

View File

@@ -49,14 +49,13 @@ class Task(BaseModel):
Returns:
Output of the task.
"""
if self.agent:
result = self.agent.execute_task(
task=self.description, context=context, tools=self.tools
)
self.output = TaskOutput(description=self.description, result=result)
return result
else:
if not self.agent:
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."
)
result = self.agent.execute_task(
task=self.description, context=context, tools=self.tools
)
self.output = TaskOutput(description=self.description, result=result)
return result