feat(tools): add Perplexity Search tool#5554
Conversation
Add a new built-in tool, PerplexitySearchTool, that calls the Perplexity Search API (POST https://api.perplexity.ai/search) via httpx.AsyncClient. The tool wraps a single `query` argument for the model and lets developers pin server-side options (max_results, recency, domain filter, etc.) at construction time, mirroring the pattern of DiscoveryEngineSearchTool. Every outgoing request includes the X-Pplx-Integration header set to google-adk/<package-version> for attribution. The API key can be supplied via constructor or PERPLEXITY_API_KEY. - src/google/adk/tools/perplexity_search_tool.py: tool implementation - src/google/adk/tools/__init__.py: lazy export - tests/unittests/tools/test_perplexity_search_tool.py: 12 tests with a mocked httpx transport, including an assertion that the attribution header is sent - contributing/samples/perplexity_search_agent: example agent Docs: https://docs.perplexity.ai/api-reference/search-post Signed-off-by: james-pplx <james-pplx@users.noreply.github.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Response from ADK Triaging Agent Hello @james-pplx, thank you for creating this PR! To help us track and review this new feature, could you please create a GitHub issue and associate it with this PR? Thanks! |
Position PerplexitySearchTool as the recommended general-purpose web search tool when no GCP / Discovery Engine setup is available. Adds a short tip in the README quickstart and expands the class docstring to note when to prefer it over DiscoveryEngineSearchTool.
|
Hi @GeorgeWeale — once this lands, would you consider positioning The reasoning is mostly about onboarding friction: Rationale (more general):
I've pushed a tiny doc-only commit (1894da3) on this branch that adds a short tip in the README quickstart and a note in the class docstring positioning Perplexity as the no-config default; happy to revert that if you'd rather land it as a follow-up. Either way, thanks for reviewing! |
Summary
Adds
PerplexitySearchTool— a new built-in tool that performs web search via the Perplexity Search API (POST https://api.perplexity.ai/search).The tool follows the existing search-tool pattern in this repo (mirrors
DiscoveryEngineSearchTool/VertexAiSearchTool): it subclassesFunctionTool, exposes a singlequeryargument to the model, and lets developers pin server-side options (max_results,search_recency_filter,search_domain_filter, etc.) at construction time. HTTP calls go throughhttpx.AsyncClient, which is already in core deps — no new dependency is added.Every outgoing request includes an
X-Pplx-Integration: google-adk/<version>header for attribution. The API key can be supplied via constructor or thePERPLEXITY_API_KEYenvironment variable.API reference: https://docs.perplexity.ai/api-reference/search-post
Files
src/google/adk/tools/perplexity_search_tool.py— tool implementationsrc/google/adk/tools/__init__.py— lazy export entrytests/unittests/tools/test_perplexity_search_tool.py— 12 unit testscontributing/samples/perplexity_search_agent/— example agent (mirrorsgoogle_search_agentsample)Testing plan
tests/unittests/tools/test_perplexity_search_tool.py(12 tests, all passing locally withpytest).httpx.MockTransportso no live HTTP calls are made.X-Pplx-Integrationattribution header,Authorization: Bearerheader, request URL, request method, and the request body shape (with and without options).google.adk.tools.pyinkandisort(Google profile) clean.