feat(tools): add Perplexity Search tool#5554
Open
james-pplx wants to merge 1 commit intogoogle:mainfrom
Open
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. |
Collaborator
|
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.