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