mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-28 01:28:14 +00:00
Fixed type annotation in task (#3021)
* Added Union of List of Task, None, NotSpecified * Seems like a flaky test * Fixed run time issue * Fixed Linting issues * fix pydantic error * aesthetic changes --------- Co-authored-by: Lucas Gomide <lucaslg200@gmail.com>
This commit is contained in:
@@ -39,7 +39,7 @@ from crewai.tasks.output_format import OutputFormat
|
|||||||
from crewai.tasks.task_output import TaskOutput
|
from crewai.tasks.task_output import TaskOutput
|
||||||
from crewai.tools.base_tool import BaseTool
|
from crewai.tools.base_tool import BaseTool
|
||||||
from crewai.utilities.config import process_config
|
from crewai.utilities.config import process_config
|
||||||
from crewai.utilities.constants import NOT_SPECIFIED
|
from crewai.utilities.constants import NOT_SPECIFIED, _NotSpecified
|
||||||
from crewai.utilities.guardrail import process_guardrail, GuardrailResult
|
from crewai.utilities.guardrail import process_guardrail, GuardrailResult
|
||||||
from crewai.utilities.converter import Converter, convert_to_model
|
from crewai.utilities.converter import Converter, convert_to_model
|
||||||
from crewai.utilities.events import (
|
from crewai.utilities.events import (
|
||||||
@@ -95,9 +95,9 @@ class Task(BaseModel):
|
|||||||
agent: Optional[BaseAgent] = Field(
|
agent: Optional[BaseAgent] = Field(
|
||||||
description="Agent responsible for execution the task.", default=None
|
description="Agent responsible for execution the task.", default=None
|
||||||
)
|
)
|
||||||
context: Optional[List["Task"]] = Field(
|
context: Union[List["Task"], None, _NotSpecified] = Field(
|
||||||
description="Other tasks that will have their output used as context for this task.",
|
description="Other tasks that will have their output used as context for this task.",
|
||||||
default=NOT_SPECIFIED,
|
default=NOT_SPECIFIED
|
||||||
)
|
)
|
||||||
async_execution: Optional[bool] = Field(
|
async_execution: Optional[bool] = Field(
|
||||||
description="Whether the task should be executed asynchronously or not.",
|
description="Whether the task should be executed asynchronously or not.",
|
||||||
@@ -158,6 +158,9 @@ class Task(BaseModel):
|
|||||||
end_time: Optional[datetime.datetime] = Field(
|
end_time: Optional[datetime.datetime] = Field(
|
||||||
default=None, description="End time of the task execution"
|
default=None, description="End time of the task execution"
|
||||||
)
|
)
|
||||||
|
model_config = {
|
||||||
|
"arbitrary_types_allowed": True
|
||||||
|
}
|
||||||
|
|
||||||
@field_validator("guardrail")
|
@field_validator("guardrail")
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List, Union
|
||||||
|
from crewai.utilities.constants import _NotSpecified
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from crewai.task import Task
|
from crewai.task import Task
|
||||||
@@ -15,7 +15,7 @@ def aggregate_raw_outputs_from_task_outputs(task_outputs: List["TaskOutput"]) ->
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
def aggregate_raw_outputs_from_tasks(tasks: List["Task"]) -> str:
|
def aggregate_raw_outputs_from_tasks(tasks: Union[List["Task"],_NotSpecified]) -> str:
|
||||||
"""Generate string context from the tasks."""
|
"""Generate string context from the tasks."""
|
||||||
|
|
||||||
task_outputs = (
|
task_outputs = (
|
||||||
|
|||||||
Reference in New Issue
Block a user