Skip to content

Commit c5ea415

Browse files
chore(crewai-tools): drop self-explanatory comments
1 parent 1bac7d3 commit c5ea415

79 files changed

Lines changed: 59 additions & 614 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/crewai-tools/src/crewai_tools/adapters/crewai_rag_adapter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,10 @@ def add(self, *args: ContentItem, **kwargs: Unpack[AddDocumentParams]) -> None:
252252
if filename.startswith("."):
253253
continue
254254

255-
# Skip binary files based on extension
256255
file_ext = os.path.splitext(filename)[1].lower()
257256
if file_ext in binary_extensions:
258257
continue
259258

260-
# Skip __pycache__ directories
261259
if "__pycache__" in root:
262260
continue
263261

lib/crewai-tools/src/crewai_tools/adapters/enterprise_adapter.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def __init__(
4646

4747
schema_props, required = self._extract_schema_info(action_schema)
4848

49-
# Define field definitions for the model
5049
field_definitions = {}
5150
for param_name, param_details in schema_props.items():
5251
param_desc = param_details.get("description", "")
@@ -59,12 +58,10 @@ def __init__(
5958
except Exception:
6059
field_type = str
6160

62-
# Create field definition based on requirement
6361
field_definitions[param_name] = self._create_field_definition(
6462
field_type, is_required, param_desc
6563
)
6664

67-
# Create the model
6865
if field_definitions:
6966
try:
7067
args_schema = create_model( # type: ignore[call-overload]

lib/crewai-tools/src/crewai_tools/adapters/rag_adapter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def __init__(
1616
):
1717
super().__init__()
1818

19-
# Prepare embedding configuration
2019
embedding_config = {"api_key": embedding_api_key, **embedding_kwargs}
2120

2221
self._adapter = RAG(

lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
)
1515

1616

17-
# Load environment variables from .env file
1817
load_dotenv()
1918

2019

@@ -66,29 +65,24 @@ def __init__(
6665
self.enable_trace = enable_trace
6766
self.end_session = end_session
6867

69-
# Update the description if provided
7068
if description:
7169
self.description = description
7270

73-
# Validate parameters
7471
self._validate_parameters()
7572

7673
def _validate_parameters(self) -> None:
7774
"""Validate the parameters according to AWS API requirements."""
7875
try:
79-
# Validate agent_id
8076
if not self.agent_id:
8177
raise BedrockValidationError("agent_id cannot be empty")
8278
if not isinstance(self.agent_id, str):
8379
raise BedrockValidationError("agent_id must be a string")
8480

85-
# Validate agent_alias_id
8681
if not self.agent_alias_id:
8782
raise BedrockValidationError("agent_alias_id cannot be empty")
8883
if not isinstance(self.agent_alias_id, str):
8984
raise BedrockValidationError("agent_alias_id must be a string")
9085

91-
# Validate session_id if provided
9286
if self.session_id and not isinstance(self.session_id, str):
9387
raise BedrockValidationError("session_id must be a string")
9488

@@ -113,7 +107,6 @@ def _run(self, query: str) -> str:
113107
),
114108
)
115109

116-
# Format the prompt with current time
117110
current_utc = datetime.now(timezone.utc)
118111
prompt = f"""
119112
The current time is: {current_utc}
@@ -132,12 +125,9 @@ def _run(self, query: str) -> str:
132125
endSession=self.end_session,
133126
)
134127

135-
# Process the response
136128
completion = ""
137129

138-
# Check if response contains a completion field
139130
if "completion" in response:
140-
# Process streaming response format
141131
for event in response.get("completion", []):
142132
if "chunk" in event and "bytes" in event["chunk"]:
143133
chunk_bytes = event["chunk"]["bytes"]
@@ -161,7 +151,6 @@ def _run(self, query: str) -> str:
161151
"response_keys": list(response.keys()),
162152
}
163153

164-
# Add more debug info
165154
if "chunk" in response:
166155
debug_info["chunk_keys"] = list(response["chunk"].keys())
167156

lib/crewai-tools/src/crewai_tools/aws/bedrock/browser/browser_toolkit.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,8 @@ class NavigateTool(BrowserBaseTool):
135135
def _run(self, url: str, thread_id: str = "default", **kwargs: Any) -> str:
136136
"""Use the sync tool."""
137137
try:
138-
# Get page for this thread
139138
page = self.get_sync_page(thread_id)
140139

141-
# Validate URL scheme
142140
parsed_url = urlparse(url)
143141
if parsed_url.scheme not in ("http", "https"):
144142
raise ValueError("URL scheme must be 'http' or 'https'")
@@ -153,10 +151,8 @@ def _run(self, url: str, thread_id: str = "default", **kwargs: Any) -> str:
153151
async def _arun(self, url: str, thread_id: str = "default", **kwargs: Any) -> str:
154152
"""Use the async tool."""
155153
try:
156-
# Get page for this thread
157154
page = await self.get_async_page(thread_id)
158155

159-
# Validate URL scheme
160156
parsed_url = urlparse(url)
161157
if parsed_url.scheme not in ("http", "https"):
162158
raise ValueError("URL scheme must be 'http' or 'https'")
@@ -191,7 +187,6 @@ def _selector_effective(self, selector: str) -> str:
191187
def _run(self, selector: str, thread_id: str = "default", **kwargs: Any) -> str:
192188
"""Use the sync tool."""
193189
try:
194-
# Get the current page
195190
page = self.get_sync_page(thread_id)
196191

197192
# Click on the element
@@ -218,7 +213,6 @@ async def _arun(
218213
) -> str:
219214
"""Use the async tool."""
220215
try:
221-
# Get the current page
222216
page = await self.get_async_page(thread_id)
223217

224218
# Click on the element
@@ -251,7 +245,6 @@ class NavigateBackTool(BrowserBaseTool):
251245
def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
252246
"""Use the sync tool."""
253247
try:
254-
# Get the current page
255248
page = self.get_sync_page(thread_id)
256249

257250
# Navigate back
@@ -266,7 +259,6 @@ def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
266259
async def _arun(self, thread_id: str = "default", **kwargs: Any) -> str:
267260
"""Use the async tool."""
268261
try:
269-
# Get the current page
270262
page = await self.get_async_page(thread_id)
271263

272264
# Navigate back
@@ -289,7 +281,6 @@ class ExtractTextTool(BrowserBaseTool):
289281
def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
290282
"""Use the sync tool."""
291283
try:
292-
# Import BeautifulSoup
293284
try:
294285
from bs4 import BeautifulSoup
295286
except ImportError:
@@ -298,10 +289,8 @@ def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
298289
" Please install it with 'pip install beautifulsoup4'."
299290
)
300291

301-
# Get the current page
302292
page = self.get_sync_page(thread_id)
303293

304-
# Extract text
305294
content = page.content()
306295
soup = BeautifulSoup(content, "html.parser")
307296
return soup.get_text(separator="\n").strip()
@@ -311,7 +300,6 @@ def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
311300
async def _arun(self, thread_id: str = "default", **kwargs: Any) -> str:
312301
"""Use the async tool."""
313302
try:
314-
# Import BeautifulSoup
315303
try:
316304
from bs4 import BeautifulSoup
317305
except ImportError:
@@ -320,10 +308,8 @@ async def _arun(self, thread_id: str = "default", **kwargs: Any) -> str:
320308
" Please install it with 'pip install beautifulsoup4'."
321309
)
322310

323-
# Get the current page
324311
page = await self.get_async_page(thread_id)
325312

326-
# Extract text
327313
content = await page.content()
328314
soup = BeautifulSoup(content, "html.parser")
329315
return soup.get_text(separator="\n").strip()
@@ -341,7 +327,6 @@ class ExtractHyperlinksTool(BrowserBaseTool):
341327
def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
342328
"""Use the sync tool."""
343329
try:
344-
# Import BeautifulSoup
345330
try:
346331
from bs4 import BeautifulSoup, Tag
347332
except ImportError:
@@ -350,10 +335,8 @@ def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
350335
" Please install it with 'pip install beautifulsoup4'."
351336
)
352337

353-
# Get the current page
354338
page = self.get_sync_page(thread_id)
355339

356-
# Extract hyperlinks
357340
content = page.content()
358341
soup = BeautifulSoup(content, "html.parser")
359342
links = []
@@ -374,7 +357,6 @@ def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
374357
async def _arun(self, thread_id: str = "default", **kwargs: Any) -> str:
375358
"""Use the async tool."""
376359
try:
377-
# Import BeautifulSoup
378360
try:
379361
from bs4 import BeautifulSoup, Tag
380362
except ImportError:
@@ -383,10 +365,8 @@ async def _arun(self, thread_id: str = "default", **kwargs: Any) -> str:
383365
" Please install it with 'pip install beautifulsoup4'."
384366
)
385367

386-
# Get the current page
387368
page = await self.get_async_page(thread_id)
388369

389-
# Extract hyperlinks
390370
content = await page.content()
391371
soup = BeautifulSoup(content, "html.parser")
392372
links = []
@@ -415,10 +395,8 @@ class GetElementsTool(BrowserBaseTool):
415395
def _run(self, selector: str, thread_id: str = "default", **kwargs: Any) -> str:
416396
"""Use the sync tool."""
417397
try:
418-
# Get the current page
419398
page = self.get_sync_page(thread_id)
420399

421-
# Get elements
422400
elements = page.query_selector_all(selector)
423401
if not elements:
424402
return f"No elements found with selector '{selector}'"
@@ -437,10 +415,8 @@ async def _arun(
437415
) -> str:
438416
"""Use the async tool."""
439417
try:
440-
# Get the current page
441418
page = await self.get_async_page(thread_id)
442419

443-
# Get elements
444420
elements = await page.query_selector_all(selector)
445421
if not elements:
446422
return f"No elements found with selector '{selector}'"
@@ -465,10 +441,8 @@ class CurrentWebPageTool(BrowserBaseTool):
465441
def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
466442
"""Use the sync tool."""
467443
try:
468-
# Get the current page
469444
page = self.get_sync_page(thread_id)
470445

471-
# Get information
472446
url = page.url
473447
title = page.title()
474448
return f"URL: {url}\nTitle: {title}"
@@ -478,10 +452,8 @@ def _run(self, thread_id: str = "default", **kwargs: Any) -> str:
478452
async def _arun(self, thread_id: str = "default", **kwargs: Any) -> str:
479453
"""Use the async tool."""
480454
try:
481-
# Get the current page
482455
page = await self.get_async_page(thread_id)
483456

484-
# Get information
485457
url = page.url
486458
title = await page.title()
487459
return f"URL: {url}\nTitle: {title}"

0 commit comments

Comments
 (0)