adding process and task modules

This commit is contained in:
Joao Moura
2023-11-05 14:21:35 -03:00
parent afd8ae40e0
commit ffd0444f11
2 changed files with 35 additions and 0 deletions

26
crewai/task.py Normal file
View File

@@ -0,0 +1,26 @@
from typing import List, Optional
from pydantic import BaseModel, Field, model_validator
from langchain.tools import Tool
from .agent import Agent
class Task(BaseModel):
"""
Class that represent a task to be executed.
"""
description: str = Field(description="Description of the actual task.")
agent: Optional[Agent] = Field(
description="Agent responsible for the task.",
default=None
)
tools: Optional[List[Tool]] = Field(
description="Tools the agent are limited to use for this task.",
default=[]
)
@model_validator(mode="after")
def _set_tools(self) -> None:
if self.agent:
self.tools = self.agent.tools