mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-07 15:18:29 +00:00
Merge branch 'main' of github.com:crewAIInc/crewAI-tools into fix/optional-dependencies
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from typing import Any, Dict, Optional, Type
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field, PrivateAttr
|
||||
|
||||
|
||||
try:
|
||||
@@ -29,7 +29,7 @@ class FirecrawlCrawlWebsiteTool(BaseTool):
|
||||
description: str = "Crawl webpages using Firecrawl and return the contents"
|
||||
args_schema: Type[BaseModel] = FirecrawlCrawlWebsiteToolSchema
|
||||
api_key: Optional[str] = None
|
||||
firecrawl: Optional["FirecrawlApp"] = None
|
||||
_firecrawl: Optional["FirecrawlApp"] = PrivateAttr(None)
|
||||
|
||||
def __init__(self, api_key: Optional[str] = None, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@@ -74,7 +74,7 @@ class FirecrawlCrawlWebsiteTool(BaseTool):
|
||||
"crawlerOptions": crawler_options,
|
||||
"timeout": timeout,
|
||||
}
|
||||
return self.firecrawl.crawl_url(url, options)
|
||||
return self._firecrawl.crawl_url(url, options)
|
||||
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Any, Optional, Type
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field, PrivateAttr
|
||||
|
||||
try:
|
||||
from firecrawl import FirecrawlApp
|
||||
@@ -22,10 +22,10 @@ class FirecrawlScrapeWebsiteTool(BaseTool):
|
||||
arbitrary_types_allowed=True, validate_assignment=True, frozen=False
|
||||
)
|
||||
name: str = "Firecrawl web scrape tool"
|
||||
description: str = "Scrape webpages url using Firecrawl and return the contents"
|
||||
description: str = "Scrape webpages using Firecrawl and return the contents"
|
||||
args_schema: Type[BaseModel] = FirecrawlScrapeWebsiteToolSchema
|
||||
api_key: Optional[str] = None
|
||||
firecrawl: Optional["FirecrawlApp"] = None # Updated to use TYPE_CHECKING
|
||||
_firecrawl: Optional["FirecrawlApp"] = PrivateAttr(None)
|
||||
|
||||
def __init__(self, api_key: Optional[str] = None, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@@ -48,7 +48,7 @@ class FirecrawlScrapeWebsiteTool(BaseTool):
|
||||
"`firecrawl-py` package not found, please run `uv add firecrawl-py`"
|
||||
)
|
||||
|
||||
self.firecrawl = FirecrawlApp(api_key=api_key)
|
||||
self._firecrawl = FirecrawlApp(api_key=api_key)
|
||||
|
||||
def _run(
|
||||
self,
|
||||
@@ -64,7 +64,7 @@ class FirecrawlScrapeWebsiteTool(BaseTool):
|
||||
"waitFor": 0,
|
||||
"timeout": timeout,
|
||||
}
|
||||
return self.firecrawl.scrape_url(url, options)
|
||||
return self._firecrawl.scrape_url(url, options)
|
||||
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Any, Dict, Optional, Type
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
from pydantic import BaseModel, ConfigDict, Field, PrivateAttr
|
||||
|
||||
# Type checking import
|
||||
try:
|
||||
@@ -32,6 +32,9 @@ class FirecrawlSearchToolSchema(BaseModel):
|
||||
|
||||
|
||||
class FirecrawlSearchTool(BaseTool):
|
||||
model_config = ConfigDict(
|
||||
arbitrary_types_allowed=True, validate_assignment=True, frozen=False
|
||||
)
|
||||
model_config = ConfigDict(
|
||||
arbitrary_types_allowed=True, validate_assignment=True, frozen=False
|
||||
)
|
||||
@@ -39,7 +42,7 @@ class FirecrawlSearchTool(BaseTool):
|
||||
description: str = "Search webpages using Firecrawl and return the results"
|
||||
args_schema: Type[BaseModel] = FirecrawlSearchToolSchema
|
||||
api_key: Optional[str] = None
|
||||
firecrawl: Optional["FirecrawlApp"] = None
|
||||
_firecrawl: Optional["FirecrawlApp"] = PrivateAttr(None)
|
||||
|
||||
def __init__(self, api_key: Optional[str] = None, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@@ -86,7 +89,6 @@ class FirecrawlSearchTool(BaseTool):
|
||||
raise RuntimeError("FirecrawlApp not properly initialized")
|
||||
|
||||
options = {
|
||||
"query": query,
|
||||
"limit": limit,
|
||||
"tbs": tbs,
|
||||
"lang": lang,
|
||||
|
||||
Reference in New Issue
Block a user