mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-04 00:32:36 +00:00
chore: apply linting fixes to crewai-tools
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import os
|
||||
from typing import Any, List, Optional, Type
|
||||
from typing import Any, Optional
|
||||
|
||||
from crewai.tools import BaseTool, EnvVar
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
try:
|
||||
@@ -18,53 +18,55 @@ class EXABaseToolSchema(BaseModel):
|
||||
search_query: str = Field(
|
||||
..., description="Mandatory search query you want to use to search the internet"
|
||||
)
|
||||
start_published_date: Optional[str] = Field(
|
||||
start_published_date: str | None = Field(
|
||||
None, description="Start date for the search"
|
||||
)
|
||||
end_published_date: Optional[str] = Field(
|
||||
None, description="End date for the search"
|
||||
)
|
||||
include_domains: Optional[list[str]] = Field(
|
||||
end_published_date: str | None = Field(None, description="End date for the search")
|
||||
include_domains: list[str] | None = Field(
|
||||
None, description="List of domains to include in the search"
|
||||
)
|
||||
|
||||
|
||||
class EXASearchTool(BaseTool):
|
||||
model_config = {"arbitrary_types_allowed": True}
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
name: str = "EXASearchTool"
|
||||
description: str = "Search the internet using Exa"
|
||||
args_schema: Type[BaseModel] = EXABaseToolSchema
|
||||
args_schema: type[BaseModel] = EXABaseToolSchema
|
||||
client: Optional["Exa"] = None
|
||||
content: Optional[bool] = False
|
||||
summary: Optional[bool] = False
|
||||
type: Optional[str] = "auto"
|
||||
package_dependencies: List[str] = ["exa_py"]
|
||||
api_key: Optional[str] = Field(
|
||||
content: bool | None = False
|
||||
summary: bool | None = False
|
||||
type: str | None = "auto"
|
||||
package_dependencies: list[str] = Field(default_factory=lambda: ["exa_py"])
|
||||
api_key: str | None = Field(
|
||||
default_factory=lambda: os.getenv("EXA_API_KEY"),
|
||||
description="API key for Exa services",
|
||||
json_schema_extra={"required": False},
|
||||
)
|
||||
base_url: Optional[str] = Field(
|
||||
base_url: str | None = Field(
|
||||
default_factory=lambda: os.getenv("EXA_BASE_URL"),
|
||||
description="API server url",
|
||||
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_BASE_URL",
|
||||
description="API url for the Exa services",
|
||||
required=False,
|
||||
),
|
||||
]
|
||||
env_vars: list[EnvVar] = Field(
|
||||
default_factory=lambda: [
|
||||
EnvVar(
|
||||
name="EXA_API_KEY",
|
||||
description="API key for Exa services",
|
||||
required=False,
|
||||
),
|
||||
EnvVar(
|
||||
name="EXA_BASE_URL",
|
||||
description="API url for the Exa services",
|
||||
required=False,
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
content: Optional[bool] = False,
|
||||
summary: Optional[bool] = False,
|
||||
type: Optional[str] = "auto",
|
||||
content: bool | None = False,
|
||||
summary: bool | None = False,
|
||||
type: str | None = "auto",
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(
|
||||
@@ -78,7 +80,7 @@ class EXASearchTool(BaseTool):
|
||||
):
|
||||
import subprocess
|
||||
|
||||
subprocess.run(["uv", "add", "exa_py"], check=True)
|
||||
subprocess.run(["uv", "add", "exa_py"], check=True) # noqa: S607
|
||||
|
||||
else:
|
||||
raise ImportError(
|
||||
@@ -95,9 +97,9 @@ class EXASearchTool(BaseTool):
|
||||
def _run(
|
||||
self,
|
||||
search_query: str,
|
||||
start_published_date: Optional[str] = None,
|
||||
end_published_date: Optional[str] = None,
|
||||
include_domains: Optional[list[str]] = None,
|
||||
start_published_date: str | None = None,
|
||||
end_published_date: str | None = None,
|
||||
include_domains: list[str] | None = None,
|
||||
) -> Any:
|
||||
if self.client is None:
|
||||
raise ValueError("Client not initialized")
|
||||
|
||||
Reference in New Issue
Block a user