Add Perplexity websearch component#11231
Open
james-pplx wants to merge 1 commit intodeepset-ai:mainfrom
Open
Conversation
Adds a `PerplexityWebSearch` component that uses the Perplexity Search API (https://api.perplexity.ai/search) to retrieve web results, mirroring the existing `SearchApiWebSearch` and `SerperDevWebSearch` components. The component supports both sync (`run`) and async (`run_async`) invocation, and exposes the API's optional filters (country, recency, domain, language, date filters, max_tokens_per_page) via a `search_params` dict. Outgoing requests include an `X-Pplx-Integration: haystack-core/<version>` header for attribution. Tests cover serialization, top_k slicing, the attribution header, search params propagation, timeouts, and error handling, mirroring the existing websearch test suites. Signed-off-by: James Liounis <james.liounis@perplexity.ai>
|
@james-pplx is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
|
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 a
PerplexityWebSearchcomponent that uses the Perplexity Search API to retrieve web results, mirroring the existingSearchApiWebSearchandSerperDevWebSearchcomponents.run) and async (run_async) interfaces, both returningdocumentsandlinks.Secret.from_env_var("PERPLEXITY_API_KEY").top_kmaps to the API'smax_results(1–20).search_paramsexposes optional filters:country,search_recency_filter,search_domain_filter,search_language_filter,last_updated_after_filter,last_updated_before_filter,search_after_date_filter,search_before_date_filter, andmax_tokens_per_page.X-Pplx-Integration: haystack-core/<version>for attribution.The component is implemented as a thin direct HTTP wrapper using
httpx(already a Haystack dependency), so no new third-party packages are introduced.Test plan
test/components/websearch/test_perplexity.pycover serialization,top_kslicing, attribution-header presence, search-params propagation, timeout handling, request errors, and bad response codes (sync + async). 17 unit tests pass; 2 integration tests are skipped withoutPERPLEXITY_API_KEY.ruff checkandruff format --checkpass on changed files.test/components/websearch/suite still passes (49 passed, 6 skipped).releasenotes/notes/.Related
Companion PR adding
perplexity-haystackas a dedicated package indeepset-ai/haystack-core-integrations(#3262) covers the integrations-package surface; this PR adds the component to Haystack core alongside the other built-in web search components.