mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
feat: cleanup Pydantic warning
A several warnings were addressed following by https://docs.pydantic.dev/2.10/migration
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from typing import TYPE_CHECKING, Any, Type
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from patronus import Client, EvaluationResult
|
||||
@@ -40,8 +40,7 @@ class PatronusLocalEvaluatorTool(BaseTool):
|
||||
evaluator: str
|
||||
evaluated_model_gold_answer: str
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -2,12 +2,11 @@ from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
|
||||
class Adapter(BaseModel, ABC):
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
@abstractmethod
|
||||
def query(self, question: str) -> str:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import os
|
||||
from typing import Any, Optional, Type, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, Optional, Type
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field, validator, ConfigDict
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
# Type checking import
|
||||
if TYPE_CHECKING:
|
||||
@@ -31,7 +31,7 @@ class ScrapegraphScrapeToolSchema(FixedScrapegraphScrapeToolSchema):
|
||||
description="Prompt to guide the extraction of content",
|
||||
)
|
||||
|
||||
@validator("website_url")
|
||||
@field_validator("website_url")
|
||||
def validate_url(cls, v):
|
||||
"""Validate URL format"""
|
||||
try:
|
||||
|
||||
@@ -4,7 +4,7 @@ from typing import Any, Optional, Type
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field, validator
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
|
||||
class FixedSeleniumScrapingToolSchema(BaseModel):
|
||||
@@ -23,7 +23,7 @@ class SeleniumScrapingToolSchema(FixedSeleniumScrapingToolSchema):
|
||||
description="Mandatory css reference for element to scrape from the website",
|
||||
)
|
||||
|
||||
@validator("website_url")
|
||||
@field_validator("website_url")
|
||||
def validate_website_url(cls, v):
|
||||
if not v:
|
||||
raise ValueError("Website URL cannot be empty")
|
||||
|
||||
@@ -4,7 +4,7 @@ from typing import Optional, Type
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from openai import OpenAI
|
||||
from pydantic import BaseModel, validator
|
||||
from pydantic import BaseModel, field_validator
|
||||
|
||||
|
||||
class ImagePromptSchema(BaseModel):
|
||||
@@ -12,7 +12,7 @@ class ImagePromptSchema(BaseModel):
|
||||
|
||||
image_path_url: str = "The image path or URL."
|
||||
|
||||
@validator("image_path_url")
|
||||
@field_validator("image_path_url")
|
||||
def validate_image_path_url(cls, v: str) -> str:
|
||||
if v.startswith("http"):
|
||||
return v
|
||||
|
||||
Reference in New Issue
Block a user