Skip to content

Add Perplexity websearch component#11231

Open
james-pplx wants to merge 1 commit intodeepset-ai:mainfrom
james-pplx:add-perplexity-search
Open

Add Perplexity websearch component#11231
james-pplx wants to merge 1 commit intodeepset-ai:mainfrom
james-pplx:add-perplexity-search

Conversation

@james-pplx
Copy link
Copy Markdown

Summary

Adds a PerplexityWebSearch component that uses the Perplexity Search API to retrieve web results, mirroring the existing SearchApiWebSearch and SerperDevWebSearch components.

  • Sync (run) and async (run_async) interfaces, both returning documents and links.
  • API key via Secret.from_env_var("PERPLEXITY_API_KEY").
  • top_k maps to the API's max_results (1–20).
  • search_params exposes 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, and max_tokens_per_page.
  • Outgoing requests include 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

  • Unit tests in test/components/websearch/test_perplexity.py cover serialization, top_k slicing, 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 without PERPLEXITY_API_KEY.
  • ruff check and ruff format --check pass on changed files.
  • Existing test/components/websearch/ suite still passes (49 passed, 6 skipped).
  • Release note added under releasenotes/notes/.

Related

Companion PR adding perplexity-haystack as a dedicated package in deepset-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.

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 james-pplx requested a review from a team as a code owner April 30, 2026 15:16
@james-pplx james-pplx requested review from davidsbatista and removed request for a team April 30, 2026 15:16
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

@james-pplx is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants