Skip to content

feat(perplexity): refresh Web and Search integrations - #7687

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.49from
backryun:refresh-Perplexity
Jul 19, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.49from
backryun:refresh-Perplexity

Conversation

@backryun

Copy link
Copy Markdown
Contributor

This patch was created at the request of @bestagi.

Summary

  • refresh the Perplexity Web curated catalog and internal model mappings
  • add current GPT-5.6 Terra, GPT-5.6 Sol, and Grok 4.5 variants
  • remove the retired pplx-gpt and pplx-gpt-5.4 aliases
  • align Perplexity Search request options with the current Search API
  • keep /v1/models limited to API key validation so Agent API models are not imported into the curated Sonar catalog

Why

Perplexity's Web model catalog and Search API have changed, while /v1/models now exposes the broader Agent API catalog. The provider integrations needed to reflect the current upstream contracts without mixing Agent models into OmniRoute's curated Sonar provider.

Impact

The dashboard advertises the current Perplexity Web models, supported Search API filters are forwarded and validated, and the Sonar provider continues to expose only its curated models while retaining reliable API key validation.

Validation

  • 225 Perplexity and search regression tests passed
  • 102 focused tests passed after the final API-reference review
  • npm run typecheck:core
  • lint-staged, ESLint, and repository commit checks passed

@backryun
backryun marked this pull request as ready for review July 18, 2026 14:45
@backryun
backryun requested a review from diegosouzapw as a code owner July 18, 2026 14:45

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Perplexity provider configuration to use testKeyModelsUrl for API key validation, preventing incorrect catalog discovery. It also updates the model mappings for the Perplexity Web executor (adding GPT-5.6 Terra, GPT-5.6 Sol, and Grok 4.5) and introduces structured validation for Perplexity-specific search options using Zod. The review feedback suggests improving robustness by normalizing locale strings (e.g., en-US) to their 2-letter ISO 639-1 codes, and refactoring buildPerplexityRequest to spread options first to avoid overwriting manually assigned properties with undefined values.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread open-sse/handlers/search.ts Outdated
Comment on lines +284 to +290
if (
params.language &&
!parsed.data.search_language_filter &&
!/^[A-Za-z]{2}$/.test(params.language)
) {
return { error: "Perplexity Search language must be a two-letter ISO 639-1 code" };
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve robustness and user experience, we should normalize standard locale strings (e.g., en-US or zh-CN) to their 2-letter ISO 639-1 language codes instead of failing with a 400 Bad Request error. We can split/slice the language string to extract the primary language code.

  if (params.language && !parsed.data.search_language_filter) {
    const langCode = params.language.split(/[-_]/)[0].toLowerCase();
    if (!/^[a-z]{2}$/.test(langCode)) {
      return { error: "Perplexity Search language must be a two-letter ISO 639-1 code" };
    }
  }

Comment thread open-sse/handlers/search.ts Outdated
Comment on lines +383 to +395
const options = parsePerplexitySearchOptions(params).options ?? {};
const body: Record<string, unknown> = { query: params.query, max_results: params.maxResults };
if (params.country) body.country = params.country;
if (params.language) body.search_language_filter = [params.language];
if (params.country) body.country = params.country.toUpperCase();
if (options.search_language_filter) {
body.search_language_filter = options.search_language_filter;
} else if (params.language) {
body.search_language_filter = [params.language.toLowerCase()];
}
if (params.domainFilter?.length) body.search_domain_filter = params.domainFilter;
if (params.timeRange && params.timeRange !== "any" && !options.search_recency_filter) {
body.search_recency_filter = params.timeRange;
}
Object.assign(body, options);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using Object.assign(body, options) at the end can accidentally overwrite manually assigned properties (like search_language_filter or search_recency_filter) with undefined if those keys exist in the parsed options object. Additionally, we should normalize params.language to its 2-letter code to match the validation logic. Spreading options first and then applying overrides is a safer and cleaner pattern.

  const options = parsePerplexitySearchOptions(params).options ?? {};
  const body: Record<string, unknown> = {
    query: params.query,
    max_results: params.maxResults,
    ...options,
  };
  if (params.country) body.country = params.country.toUpperCase();
  if (params.language && !body.search_language_filter) {
    body.search_language_filter = [params.language.split(/[-_]/)[0].toLowerCase()];
  }
  if (params.domainFilter?.length) body.search_domain_filter = params.domainFilter;
  if (params.timeRange && params.timeRange !== "any" && !body.search_recency_filter) {
    body.search_recency_filter = params.timeRange;
  }

@backryun
backryun force-pushed the refresh-Perplexity branch 9 times, most recently from d30561b to 1b7bac7 Compare July 19, 2026 06:43
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Reviewed and validated in an isolated probe worktree off release/v3.8.49. Traced through the -165 deletions specifically: buildPerplexityRequest was moved (not dropped) into the new perplexitySearch.ts and extended with Zod validation, the two removed inline tests were replaced by equivalent-or-broader coverage, and the retired pplx-gpt/pplx-gpt-5.4 ids leave no dangling references anywhere in the tree. Ran the full touched-test set (99/99 pass), typecheck:core clean, ESLint clean. The testKeyModelsUrl split is a clean fix for the stated Agent-API-catalog-leak problem and is backward compatible for every other provider. Two small nits for a follow-up, not blockers: (1) tests/unit/search-handler-perplexity-options.test.ts has a // @ts-nocheck at the top that could be removed now that the module is typed; (2) consider adding a changelog.d/features fragment for this refresh. Approving for merge.

@backryun
backryun force-pushed the refresh-Perplexity branch from 1b7bac7 to ff2b9bb Compare July 19, 2026 07:25
@backryun

Copy link
Copy Markdown
Contributor Author

Reviewed and validated in an isolated probe worktree off release/v3.8.49. Traced through the -165 deletions specifically: buildPerplexityRequest was moved (not dropped) into the new perplexitySearch.ts and extended with Zod validation, the two removed inline tests were replaced by equivalent-or-broader coverage, and the retired pplx-gpt/pplx-gpt-5.4 ids leave no dangling references anywhere in the tree. Ran the full touched-test set (99/99 pass), typecheck:core clean, ESLint clean. The testKeyModelsUrl split is a clean fix for the stated Agent-API-catalog-leak problem and is backward compatible for every other provider. Two small nits for a follow-up, not blockers: (1) tests/unit/search-handler-perplexity-options.test.ts has a // @ts-nocheck at the top that could be removed now that the module is typed; (2) consider adding a changelog.d/features fragment for this refresh. Approving for merge.

I've made the amendments based on the two points you mentioned. You may go ahead and merge the changes.

@backryun
backryun force-pushed the refresh-Perplexity branch 7 times, most recently from 04fe0a7 to 505e8c3 Compare July 19, 2026 17:09
@backryun
backryun force-pushed the refresh-Perplexity branch from 505e8c3 to ed15ab3 Compare July 19, 2026 17:29
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @backryun! Perplexity Web/Search refresh — curated catalog updated, retired models dropped, search handler + registry aligned, with unit coverage across the mappings. Validated in local merge-train @ c5997d6b2 (FAST gates green: static + changed tests + vitest). The stale per-PR CI reds were the shared base-red on the release tip, not this PR.

@diegosouzapw
diegosouzapw merged commit 649e5d0 into cheaper-inference:release/v3.8.49 Jul 19, 2026
4 of 5 checks passed
@backryun
backryun deleted the refresh-Perplexity branch July 19, 2026 17:41
@diegosouzapw diegosouzapw mentioned this pull request Jul 23, 2026
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 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.

2 participants