Repository navigation
feat(perplexity): refresh Web and Search integrations - #7687
Conversation
There was a problem hiding this comment.
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.
| 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" }; | ||
| } |
There was a problem hiding this comment.
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" };
}
}| 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); |
There was a problem hiding this comment.
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;
}d30561b to
1b7bac7
Compare
|
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 |
1b7bac7 to
ff2b9bb
Compare
I've made the amendments based on the two points you mentioned. You may go ahead and merge the changes. |
04fe0a7 to
505e8c3
Compare
505e8c3 to
ed15ab3
Compare
|
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. |
649e5d0
into
cheaper-inference:release/v3.8.49
Summary
pplx-gptandpplx-gpt-5.4aliases/v1/modelslimited to API key validation so Agent API models are not imported into the curated Sonar catalogWhy
Perplexity's Web model catalog and Search API have changed, while
/v1/modelsnow 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
npm run typecheck:core