Skip to content

feat(ai-perplexity): add Perplexity Search integration - #6204

Closed
jliounis wants to merge 2 commits into
Effect-TS:mainfrom
jliounis:feat/perplexity-search
Closed

jliounis wants to merge 2 commits into
Effect-TS:mainfrom
jliounis:feat/perplexity-search

Conversation

@jliounis

Copy link
Copy Markdown

Summary

Adds a new @effect/ai-perplexity package providing Effect bindings for the Perplexity Search API.

What's added

  • PerplexityClient — HTTP client wrapper that handles authentication and error mapping (platform HttpClient errors → @effect/ai AiError).
  • PerplexitySearch — service with a search(options) method that returns a typed SearchResponse (results: { title, url, snippet, date? }[]).
  • Supports the documented Search API request fields: max_results, max_tokens_per_page, search_domain_filter, search_recency_filter, search_after_date_filter, search_before_date_filter.
  • Validates that search_domain_filter does not mix allow- and deny-list entries (the API does not accept that), failing fast with AiError.MalformedInput if it does.
  • API key is read from PERPLEXITY_API_KEY, falling back to PPLX_API_KEY, via Config.redacted. A custom URL can be supplied via PERPLEXITY_API_URL or programmatically.
  • Includes a PerplexityConfig tag and withClientTransform helper, mirroring the pattern used by @effect/ai-anthropic.

Tests

10 unit tests in packages/ai/perplexity/test/PerplexitySearch.test.ts, all using a mocked HttpClient (HttpClient.make) so no network calls are made:

  • request body construction (camelCase → snake_case mapping, optional fields)
  • allowlist / denylist domain filter handling, including the mixed-mode rejection
  • success decoding into SearchResponse
  • non-2xx → AiError.HttpResponseError
  • malformed JSON body → AiError.MalformedOutput
  • header / URL / method assertions on the captured request

Run with:

pnpm --filter @effect/ai-perplexity test
pnpm --filter @effect/ai-perplexity check
pnpm --filter @effect/ai-perplexity build

All three pass locally.

Docs

  • packages/ai/perplexity/README.md documents installation, authentication, basic usage, available options, and the domain-filter caveat.
  • Includes a changeset (@effect/ai-perplexity minor) describing the addition.

References

Adds a new @effect/ai-perplexity package providing Effect bindings for
the Perplexity Search API. Exposes a PerplexitySearch service with a
typed search method (returns {title, url, snippet, date?}) plus support
for max_results, search_domain_filter (allow- or deny-list, validated to
not mix), search_recency_filter, and date-range filters.

Reads the API key from PERPLEXITY_API_KEY (with PPLX_API_KEY as a
fallback) via Config.redacted.

Includes unit tests (10 cases) covering body shape, filter forwarding,
mixed-domain rejection, success decoding, HTTP errors, and malformed
response handling.
@jliounis
jliounis requested a review from IMax153 as a code owner April 29, 2026 23:16
@changeset-bot

changeset-bot Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 078c05b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/ai-perplexity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jliounis

Copy link
Copy Markdown
Author

Friendly bump — changeset is present, typecheck/lint/build are clean. Happy to address any feedback on the @effect/ai-perplexity package (modeled after @effect/ai-anthropic). Let me know if you'd like changes.

@IMax153

IMax153 commented May 18, 2026

Copy link
Copy Markdown
Member

Hi @jliounis - apologies but Effect v3 is on a feature freeze now that Effect v4 is in beta.

If you'd like to see this functionality added, please open up a PR against the (v4 repo)[https://github.com/Effect-TS/effect-smol].

@fubhy

fubhy commented Jul 9, 2026

Copy link
Copy Markdown
Member

Closing per maintainer guidance above: Effect v3 is feature-frozen, and new integrations should target the v4 repo instead. Thanks for the contribution.

@fubhy fubhy closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants