feat: add SearchApi tool (Google Search + Google Shopping)#6378
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds two SearchAPI-backed tools with a shared base class, exports them from the package, registers them in ChangesSearchAPI Google Search and Shopping Tools
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
lib/crewai-tools/tests/tools/searchapi_tool_test.py (1)
25-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a
_runtest forSearchApiGoogleShoppingTool.This file only exercises the Google Search request/response path. The Shopping tool is initialization-only here, so a regression in its
engine="google_shopping"params or omitted-field behavior would currently pass unnoticed.Also applies to: 36-60
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/crewai-tools/tests/tools/searchapi_tool_test.py` around lines 25 - 27, Add a `_run` test for SearchApiGoogleShoppingTool in searchapi_tool_test.py, since the current coverage only checks initialization and would miss regressions in the google_shopping engine parameters or omitted-field handling. Extend the test coverage around SearchApiGoogleShoppingTool by exercising its _run path with representative input and asserting the expected SearchApi request/response behavior, alongside the existing initialization check.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_base_tool.py`:
- Line 5: The SearchAPI tool is exposing api_key through the Pydantic model, so
it can leak via BaseTool serialization and repr paths. Update SearchApiBaseTool
to keep api_key out of model fields by moving it to a private attribute or
otherwise excluding it from model_dump/repr, and adjust any
initialization/access in the tool methods so the credential is still available
without being part of the public schema.
In
`@lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_search_tool.py`:
- Around line 45-46: Broaden the error handling in
searchapi_google_search_tool’s exception path so timeouts and connection issues
are also caught, not just HTTP errors. Update the failure handler in the
relevant search method to catch requests.RequestException and return a neutral,
non-diagnostic message instead of suggesting invalid parameters; keep the
response generic and consistent with the tool’s error handling.
---
Nitpick comments:
In `@lib/crewai-tools/tests/tools/searchapi_tool_test.py`:
- Around line 25-27: Add a `_run` test for SearchApiGoogleShoppingTool in
searchapi_tool_test.py, since the current coverage only checks initialization
and would miss regressions in the google_shopping engine parameters or
omitted-field handling. Extend the test coverage around
SearchApiGoogleShoppingTool by exercising its _run path with representative
input and asserting the expected SearchApi request/response behavior, alongside
the existing initialization check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e6b44b41-d464-4465-8317-deadf00f3132
📒 Files selected for processing (9)
lib/crewai-tools/src/crewai_tools/__init__.pylib/crewai-tools/src/crewai_tools/tools/__init__.pylib/crewai-tools/src/crewai_tools/tools/searchapi_tool/README.mdlib/crewai-tools/src/crewai_tools/tools/searchapi_tool/__init__.pylib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_base_tool.pylib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_search_tool.pylib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_shopping_tool.pylib/crewai-tools/tests/tools/searchapi_tool_test.pylib/crewai-tools/tool.specs.json
2d381db to
79e1b47
Compare
Summary by CodeRabbit
locationparameter.