Implement CrewAIBaseModel and Update to ConfigDict (#29)

New CrewAIBaseModel:

Base for Agent, Crew, Task.
Includes generated, frozen UUID.
Adds hashing capability
Migrate to ConfigDict:

Replaces class Config with model_config, see this deprecation note .
Benefits:
Adds auditing capability with frozen UUIDs.
This commit is contained in:
Greyson LaLonde
2023-12-30 19:52:04 -05:00
committed by GitHub
parent 469874d858
commit 1f0001b644
5 changed files with 35 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ import json
from typing import Any, Dict, List, Optional, Union
from pydantic import (
BaseModel,
ConfigDict,
Field,
InstanceOf,
Json,
@@ -13,17 +13,16 @@ from pydantic_core import PydanticCustomError
from crewai.agent import Agent
from crewai.agents import CacheHandler
from crewai.base.model import CrewAIBaseModel
from crewai.process import Process
from crewai.task import Task
from crewai.tools.agent_tools import AgentTools
class Crew(BaseModel):
class Crew(CrewAIBaseModel):
"""Class that represents a group of agents, how they should work together and their tasks."""
class Config:
arbitrary_types_allowed = True
model_config = ConfigDict(arbitrary_types_allowed=True)
tasks: List[Task] = Field(description="List of tasks", default_factory=list)
agents: List[Agent] = Field(
description="List of agents in this crew.", default_factory=list