Reliability improvements (#77)

* fixing identation for AgentTools
* updating gitignore to exclude quick test script
* startingprompt translation
* supporting individual task output
* adding agent to task output
* cutting new version
* Updating README example
This commit is contained in:
João Moura
2024-01-07 12:43:23 -03:00
committed by GitHub
parent 234a2c72b0
commit 7954f6b51c
11 changed files with 124 additions and 122 deletions

View File

@@ -5,6 +5,7 @@ from pydantic import UUID4, BaseModel, Field, field_validator, model_validator
from pydantic_core import PydanticCustomError
from crewai.agent import Agent
from crewai.tasks.task_output import TaskOutput
class Task(BaseModel):
@@ -19,6 +20,9 @@ class Task(BaseModel):
default_factory=list,
description="Tools the agent are limited to use for this task.",
)
output: Optional[TaskOutput] = Field(
description="Task output, it's final result.", default=None
)
id: UUID4 = Field(
default_factory=uuid.uuid4,
frozen=True,
@@ -46,9 +50,12 @@ class Task(BaseModel):
Output of the task.
"""
if self.agent:
return self.agent.execute_task(
result = self.agent.execute_task(
task=self.description, context=context, tools=self.tools
)
self.output = TaskOutput(description=self.description, result=result)
return result
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."