Add Perplexity integration package#3262
Conversation
Adds a new integration package providing a `PerplexityWebSearch` component that wraps the Perplexity Search API, returning Haystack Documents built from search result snippets, titles and URLs. Mirrors the existing Tavily websearch integration in layout, lint and test conventions. Signed-off-by: james-pplx <james-pplx@users.noreply.github.com>
|
|
|
@jliounis thanks for opening the PR! It's looking in good shape. I'll be able to give it more in depth review next week. If by then you could sign the CLA agreement #3262 (comment) that would be greatly appreciated. |
There was a problem hiding this comment.
This file is auto generated so please remove from this PR. Will be created after this PR is merged.
| def __init__( | ||
| self, | ||
| api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"), |
There was a problem hiding this comment.
We like to enforce keyword only in newly added components
| def __init__( | |
| self, | |
| api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"), | |
| def __init__( | |
| self, | |
| *, | |
| api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"), |
| expected_type = "haystack_integrations.components.websearch.perplexity.perplexity_websearch.PerplexityWebSearch" | ||
| assert data["type"] == expected_type | ||
| assert data["init_parameters"]["top_k"] == 5 | ||
| assert data["init_parameters"]["search_params"] == {"country": "US"} |
There was a problem hiding this comment.
Let's also add an assert to check the api_key was properly serialized
Summary
Adds a new
perplexity-haystackintegration package providing aPerplexityWebSearchcomponent that wraps the Perplexity Search API. Each search result is returned as a HaystackDocumentcarrying the snippet content plus title/url/date metadata.The package layout mirrors the existing
tavily-haystackintegration line-for-line — samepyproject.tomlstructure, samesrc/haystack_integrations/components/websearch/<provider>/layout, same hatch test/lint scripts, same CI workflow shape.httpx(sync + async) — no third-party Perplexity SDK dependencyPERPLEXITY_API_KEYenv var orSecretconstructor argumentX-Pplx-Integration: haystack/<package-version>attribution header on every requesthttpx.MockTransport) covering serialization, request shaping, header attribution, error paths and async behaviourTesting
hatch run test:unit— 17 passedhatch run test:unit-cov-retry— 95% line coveragehatch run fmt-checkhatch run test:types(mypy clean)