mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-15 11:08:33 +00:00
Remove model inheritance (#30)
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import uuid
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from pydantic import Field, model_validator
|
||||
from pydantic import UUID4, BaseModel, Field, field_validator, model_validator
|
||||
from pydantic_core import PydanticCustomError
|
||||
|
||||
from crewai.agent import Agent
|
||||
from crewai.base.model import CrewAIBaseModel
|
||||
|
||||
|
||||
class Task(CrewAIBaseModel):
|
||||
class Task(BaseModel):
|
||||
"""Class that represent a task to be executed."""
|
||||
|
||||
__hash__ = object.__hash__
|
||||
description: str = Field(description="Description of the actual task.")
|
||||
agent: Optional[Agent] = Field(
|
||||
description="Agent responsible for the task.", default=None
|
||||
@@ -17,6 +19,19 @@ class Task(CrewAIBaseModel):
|
||||
default_factory=list,
|
||||
description="Tools the agent are limited to use for this task.",
|
||||
)
|
||||
id: UUID4 = Field(
|
||||
default_factory=uuid.uuid4,
|
||||
frozen=True,
|
||||
description="Unique identifier for the object, not set by user.",
|
||||
)
|
||||
|
||||
@field_validator("id", mode="before")
|
||||
@classmethod
|
||||
def _deny_user_set_id(cls, v: Optional[UUID4]) -> None:
|
||||
if v:
|
||||
raise PydanticCustomError(
|
||||
"may_not_set_field", "This field is not to be set by the user.", {}
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def check_tools(self):
|
||||
|
||||
Reference in New Issue
Block a user