mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 08:38:30 +00:00
Merge branch 'main' into fix/cli-create-provider-flag
This commit is contained in:
@@ -290,25 +290,18 @@ class Crew(BaseModel):
|
|||||||
else EntityMemory(crew=self, embedder_config=self.embedder)
|
else EntityMemory(crew=self, embedder_config=self.embedder)
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
self.memory_config and "user_memory" in self.memory_config and self.memory_config.get('provider') == 'mem0'
|
self.memory_config
|
||||||
|
and "user_memory" in self.memory_config
|
||||||
|
and self.memory_config.get("provider") == "mem0"
|
||||||
): # Check for user_memory in config
|
): # Check for user_memory in config
|
||||||
user_memory_config = self.memory_config["user_memory"]
|
user_memory_config = self.memory_config["user_memory"]
|
||||||
if isinstance(
|
if isinstance(
|
||||||
user_memory_config, dict
|
user_memory_config, dict
|
||||||
): # Check if it's a configuration dict
|
): # Check if it's a configuration dict
|
||||||
self._user_memory = UserMemory(
|
self._user_memory = UserMemory(crew=self)
|
||||||
crew=self
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
raise TypeError(
|
raise TypeError("user_memory must be a configuration dictionary")
|
||||||
"user_memory must be a configuration dictionary"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self._logger.log(
|
|
||||||
"warning",
|
|
||||||
"User memory initialization failed. For setup instructions, please refer to the memory documentation: https://docs.crewai.com/concepts/memory#integrating-mem0-for-enhanced-user-memory",
|
|
||||||
color="yellow"
|
|
||||||
)
|
|
||||||
self._user_memory = None # No user memory if not in config
|
self._user_memory = None # No user memory if not in config
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@@ -1159,7 +1152,7 @@ class Crew(BaseModel):
|
|||||||
def copy(self):
|
def copy(self):
|
||||||
"""
|
"""
|
||||||
Creates a deep copy of the Crew instance.
|
Creates a deep copy of the Crew instance.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Crew: A new instance with copied components
|
Crew: A new instance with copied components
|
||||||
"""
|
"""
|
||||||
@@ -1181,7 +1174,6 @@ class Crew(BaseModel):
|
|||||||
"knowledge",
|
"knowledge",
|
||||||
"manager_agent",
|
"manager_agent",
|
||||||
"manager_llm",
|
"manager_llm",
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cloned_agents = [agent.copy() for agent in self.agents]
|
cloned_agents = [agent.copy() for agent in self.agents]
|
||||||
|
|||||||
@@ -7,29 +7,27 @@ from pydantic import (
|
|||||||
BaseModel,
|
BaseModel,
|
||||||
ConfigDict,
|
ConfigDict,
|
||||||
Field,
|
Field,
|
||||||
PydanticDeprecatedSince20,
|
|
||||||
create_model,
|
create_model,
|
||||||
validator,
|
field_validator,
|
||||||
)
|
)
|
||||||
from pydantic import BaseModel as PydanticBaseModel
|
from pydantic import BaseModel as PydanticBaseModel
|
||||||
|
|
||||||
from crewai.tools.structured_tool import CrewStructuredTool
|
from crewai.tools.structured_tool import CrewStructuredTool
|
||||||
|
|
||||||
# Ignore all "PydanticDeprecatedSince20" warnings globally
|
|
||||||
warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20)
|
|
||||||
|
|
||||||
|
|
||||||
class BaseTool(BaseModel, ABC):
|
class BaseTool(BaseModel, ABC):
|
||||||
class _ArgsSchemaPlaceholder(PydanticBaseModel):
|
class _ArgsSchemaPlaceholder(PydanticBaseModel):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
model_config = ConfigDict()
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
"""The unique name of the tool that clearly communicates its purpose."""
|
"""The unique name of the tool that clearly communicates its purpose."""
|
||||||
description: str
|
description: str
|
||||||
"""Used to tell the model how/when/why to use the tool."""
|
"""Used to tell the model how/when/why to use the tool."""
|
||||||
args_schema: Type[PydanticBaseModel] = Field(default_factory=_ArgsSchemaPlaceholder)
|
args_schema: Type[PydanticBaseModel] = Field(
|
||||||
|
default_factory=_ArgsSchemaPlaceholder, validate_default=True
|
||||||
|
)
|
||||||
"""The schema for the arguments that the tool accepts."""
|
"""The schema for the arguments that the tool accepts."""
|
||||||
description_updated: bool = False
|
description_updated: bool = False
|
||||||
"""Flag to check if the description has been updated."""
|
"""Flag to check if the description has been updated."""
|
||||||
@@ -38,7 +36,8 @@ class BaseTool(BaseModel, ABC):
|
|||||||
result_as_answer: bool = False
|
result_as_answer: bool = False
|
||||||
"""Flag to check if the tool should be the final agent answer."""
|
"""Flag to check if the tool should be the final agent answer."""
|
||||||
|
|
||||||
@validator("args_schema", always=True, pre=True)
|
@field_validator("args_schema", mode="before")
|
||||||
|
@classmethod
|
||||||
def _default_args_schema(
|
def _default_args_schema(
|
||||||
cls, v: Type[PydanticBaseModel]
|
cls, v: Type[PydanticBaseModel]
|
||||||
) -> Type[PydanticBaseModel]:
|
) -> Type[PydanticBaseModel]:
|
||||||
|
|||||||
@@ -287,8 +287,9 @@ def generate_model_description(model: Type[BaseModel]) -> str:
|
|||||||
else:
|
else:
|
||||||
return str(field_type)
|
return str(field_type)
|
||||||
|
|
||||||
fields = model.__annotations__
|
fields = model.model_fields
|
||||||
field_descriptions = [
|
field_descriptions = [
|
||||||
f'"{name}": {describe_field(type_)}' for name, type_ in fields.items()
|
f'"{name}": {describe_field(field.annotation)}'
|
||||||
|
for name, field in fields.items()
|
||||||
]
|
]
|
||||||
return "{\n " + ",\n ".join(field_descriptions) + "\n}"
|
return "{\n " + ",\n ".join(field_descriptions) + "\n}"
|
||||||
|
|||||||
Reference in New Issue
Block a user