mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 21:28:10 +00:00
feat: support str for paths
This commit is contained in:
@@ -215,11 +215,19 @@ class BaseAgent(BaseModel, ABC, metaclass=AgentMeta):
|
||||
"If not set, falls back to crew memory."
|
||||
),
|
||||
)
|
||||
skills: list[Path | Skill] | None = Field(
|
||||
skills: list[str | Path | Skill] | None = Field(
|
||||
default=None,
|
||||
description="Agent Skills. Accepts Paths for discovery or pre-loaded Skill objects.",
|
||||
description="Agent Skills. Accepts paths (str or Path) for discovery or pre-loaded Skill objects.",
|
||||
)
|
||||
|
||||
@field_validator("skills", mode="before")
|
||||
@classmethod
|
||||
def coerce_skill_paths(cls, v: list[Any] | None) -> list[Path | Skill] | None:
|
||||
"""Coerce string entries to Path objects."""
|
||||
if not v:
|
||||
return v
|
||||
return [Path(item) if isinstance(item, str) else item for item in v]
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def process_model_config(cls, values: Any) -> dict[str, Any]:
|
||||
|
||||
@@ -292,10 +292,19 @@ class Crew(FlowTrackable, BaseModel):
|
||||
default=None,
|
||||
description="Knowledge for the crew.",
|
||||
)
|
||||
skills: list[Path] | None = Field(
|
||||
skills: list[str | Path] | None = Field(
|
||||
default=None,
|
||||
description="Skill search paths applied to all agents in the crew.",
|
||||
)
|
||||
|
||||
@field_validator("skills", mode="before")
|
||||
@classmethod
|
||||
def coerce_skill_paths(cls, v: list[Any] | None) -> list[Path] | None:
|
||||
"""Coerce string entries to Path objects."""
|
||||
if not v:
|
||||
return v
|
||||
return [Path(item) if isinstance(item, str) else item for item in v]
|
||||
|
||||
security_config: SecurityConfig = Field(
|
||||
default_factory=SecurityConfig,
|
||||
description="Security configuration for the crew, including fingerprinting.",
|
||||
|
||||
Reference in New Issue
Block a user