mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 21:28:10 +00:00
refactor: remove redundant coerce_skill_paths validator
This commit is contained in:
@@ -31,7 +31,6 @@ from crewai.mcp.config import MCPServerConfig
|
||||
from crewai.rag.embeddings.types import EmbedderConfig
|
||||
from crewai.security.security_config import SecurityConfig
|
||||
from crewai.skills.models import Skill
|
||||
from crewai.skills.validation import coerce_skill_paths as _coerce_skill_paths
|
||||
from crewai.tools.base_tool import BaseTool, Tool
|
||||
from crewai.utilities.config import process_config
|
||||
from crewai.utilities.i18n import I18N, get_i18n
|
||||
@@ -222,12 +221,6 @@ class BaseAgent(BaseModel, ABC, metaclass=AgentMeta):
|
||||
min_length=1,
|
||||
)
|
||||
|
||||
@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."""
|
||||
return _coerce_skill_paths(v)
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def process_model_config(cls, values: Any) -> dict[str, Any]:
|
||||
|
||||
@@ -90,7 +90,6 @@ from crewai.rag.types import SearchResult
|
||||
from crewai.security.fingerprint import Fingerprint
|
||||
from crewai.security.security_config import SecurityConfig
|
||||
from crewai.skills.models import Skill
|
||||
from crewai.skills.validation import coerce_skill_paths as _coerce_skill_paths
|
||||
from crewai.task import Task
|
||||
from crewai.tasks.conditional_task import ConditionalTask
|
||||
from crewai.tasks.task_output import TaskOutput
|
||||
@@ -299,12 +298,6 @@ class Crew(FlowTrackable, BaseModel):
|
||||
description="Skill search paths or pre-loaded Skill objects applied to all agents in the crew.",
|
||||
)
|
||||
|
||||
@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, pass through Skill instances."""
|
||||
return _coerce_skill_paths(v)
|
||||
|
||||
security_config: SecurityConfig = Field(
|
||||
default_factory=SecurityConfig,
|
||||
description="Security configuration for the crew, including fingerprinting.",
|
||||
|
||||
@@ -7,7 +7,7 @@ from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
from typing import Any, Final
|
||||
from typing import Final
|
||||
|
||||
|
||||
MAX_SKILL_NAME_LENGTH: Final[int] = 64
|
||||
@@ -15,20 +15,6 @@ MIN_SKILL_NAME_LENGTH: Final[int] = 1
|
||||
SKILL_NAME_PATTERN: Final[re.Pattern[str]] = re.compile(r"^[a-z0-9]+(?:-[a-z0-9]+)*$")
|
||||
|
||||
|
||||
def coerce_skill_paths(v: list[Any] | None) -> list[Any] | None:
|
||||
"""Coerce string entries to Path objects, pass through other types.
|
||||
|
||||
Args:
|
||||
v: List of skill paths or Skill objects, or None.
|
||||
|
||||
Returns:
|
||||
The list with string entries converted to Path objects, or None.
|
||||
"""
|
||||
if not v:
|
||||
return v
|
||||
return [Path(item) if isinstance(item, str) else item for item in v]
|
||||
|
||||
|
||||
def validate_directory_name(skill_dir: Path, skill_name: str) -> None:
|
||||
"""Validate that a directory name matches the skill name.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user