mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 16:48:30 +00:00
fix: use json_schema_extra instead of deprecated Field extra args (#417)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from typing import Any, Optional, Type, List
|
||||
from pydantic import BaseModel, Field
|
||||
from crewai.tools import BaseTool, EnvVar
|
||||
import os
|
||||
from typing import Any, List, Optional, Type
|
||||
|
||||
from crewai.tools import BaseTool, EnvVar
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
try:
|
||||
from exa_py import Exa
|
||||
@@ -38,10 +39,14 @@ class EXASearchTool(BaseTool):
|
||||
type: Optional[str] = "auto"
|
||||
package_dependencies: List[str] = ["exa_py"]
|
||||
api_key: Optional[str] = Field(
|
||||
default_factory=lambda: os.getenv("EXA_API_KEY"), description="API key for Exa services", required=False
|
||||
default_factory=lambda: os.getenv("EXA_API_KEY"),
|
||||
description="API key for Exa services",
|
||||
json_schema_extra={"required": False},
|
||||
)
|
||||
env_vars: List[EnvVar] = [
|
||||
EnvVar(name="EXA_API_KEY", description="API key for Exa services", required=False),
|
||||
EnvVar(
|
||||
name="EXA_API_KEY", description="API key for Exa services", required=False
|
||||
),
|
||||
]
|
||||
|
||||
def __init__(
|
||||
|
||||
10
tests/tools/test_import_without_warnings.py
Normal file
10
tests/tools/test_import_without_warnings.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import pytest
|
||||
from pydantic.warnings import PydanticDeprecatedSince20
|
||||
|
||||
|
||||
@pytest.mark.filterwarnings("error", category=PydanticDeprecatedSince20)
|
||||
def test_import_tools_without_pydantic_deprecation_warnings():
|
||||
# This test is to ensure that the import of crewai_tools does not raise any Pydantic deprecation warnings.
|
||||
import crewai_tools
|
||||
|
||||
assert crewai_tools
|
||||
Reference in New Issue
Block a user