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. |
…, assert api_key serialization
|
Thanks @sjrl! Addressed all three:
|
|
Following the audit of OpenAI-compatible providers in this repo, I've extended this PR to add:
All three components carry the same I also opened deepset-ai/haystack-integrations#478 to add a catalog entry on haystack.deepset.ai/integrations once this lands. |
…atible, default openai/gpt-5.4)
|
Switched
Embedders and |
|
Looking good! A few more comments
|
Add @pytest.mark.integration-guarded end-to-end tests (sync + async) for: - PerplexityChatGenerator - PerplexityDocumentEmbedder - PerplexityTextEmbedder PerplexityWebSearch integration tests already exist. All integration tests are skipped unless PERPLEXITY_API_KEY is set so they won't impact regular unit-test CI runs.
7a5374d to
1d3268e
Compare
|
@sjrl can you PTAL again?
@sjrl can you PTAL again? |
|
Thanks for the review @sjrl — both addressed in the latest push (HEAD now
Happy to amend further if you'd like different assertions or model coverage in the live tests. |
|
I was able to partially run the integration tests locally with our own api key. The web search and the chat generator tests passed but the embedder ones failed currently. Could you double check that they pass for you? |
|
Also please take a look at my comments starting here #3262 (comment) it looks those haven't been addressed yet. |
…view) Drop installation/usage code samples — code examples will live in the dedicated docs page that deepset will publish post-merge. Mirrors the mistral integration README layout.
|
Done — README trimmed in |
1 similar comment
|
Done — README trimmed in |
- embedders: fix api_base_url default to include /v1 (was hitting https://api.perplexity.ai/embeddings -> 404; correct endpoint is https://api.perplexity.ai/v1/embeddings). This is why the embedder integration tests failed for sjrl. - embedders: add explicit from_dict classmethod on both PerplexityDocumentEmbedder and PerplexityTextEmbedder for correct typing (r3224097561, r3224106489). - chat generator: use generate_qualified_class_name() instead of hardcoded class path in to_dict (r3224126336); drop redundant data['type'] override in from_dict (r3224130257); drop unused module-level path constants (r3224143875). - websearch: drop unreachable 'client failed to initialize' RuntimeError branches in run / run_async — warm_up always runs first (r3224158183, r3224160907). - websearch: tighten return-type hint on run / run_async to dict[str, list[Document] | list[str]] (r3224178510, r3224179725). - tests: bump api_base_url assertions in embedder unit tests to /v1; drop obsolete 'raises_runtime_error_when_warm_up_fails' websearch tests; update chat-generator to_dict assertion to the fully-qualified module path produced by generate_qualified_class_name.
|
Thanks for catching that and for running the live tests @sjrl — both fixed in Embedder integration test failures: root cause + fixThe embedders defaulted to The OpenAI SDK appends Inline review comments
All 42 unit tests pass locally; integration tests should now succeed end-to-end against a live |
|
@sjrl are we good now? |
|
Please fix the typing issues https://github.com/deepset-ai/haystack-core-integrations/actions/runs/25751675459/job/75629349722?pr=3262#step:7:87 Fine to just have type ignore on the affected lines |
sjrl
left a comment
There was a problem hiding this comment.
Looks good! Just need a fix for the typing issue
After removing the redundant 'if self._client is None: raise RuntimeError' blocks, mypy can no longer narrow the type since warm_up()'s side effect is invisible to it. Add # type: ignore[union-attr] on the .post() calls in run / run_async (per sjrl review).
|
Fixed in |
|
@sjrl can you please merge? And can we please add this one? |
|
@sjrl We now need an integration PR too :) deepset-ai/haystack-integrations#478 |
Summary
Adds a new
perplexity-haystackintegration package with Perplexity-backed Haystack components:PerplexityWebSearchfor sync and async Search API calls that return HaystackDocumentobjects with search result metadataPerplexityChatGeneratorfor chat completion generation, including streaming, tools, response formats, request customization, serialization, and attribution headersPerplexityTextEmbedderandPerplexityDocumentEmbedderfor embedding text and documents with supported Perplexity embedding modelsTesting
hatch run fmthatch run fmt-checkhatch run test:typeshatch run test:unit— 49 passed, 2 deselected