feat: support freshness parameter for Perplexity web_search provider (#15343)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 01aba2bfba
Co-authored-by: echoVic <16428813+echoVic@users.noreply.github.com>
Co-authored-by: sebslight <19554889+sebslight@users.noreply.github.com>
Reviewed-by: @sebslight
This commit is contained in:
青雲
2026-02-14 11:18:16 +08:00
committed by GitHub
parent 7f227fc8cc
commit 89fa93ed75
6 changed files with 69 additions and 18 deletions

View File

@@ -31,6 +31,7 @@ const {
isDirectPerplexityBaseUrl,
resolvePerplexityRequestModel,
normalizeFreshness,
freshnessToPerplexityRecency,
resolveGrokApiKey,
resolveGrokModel,
resolveGrokInlineCitations,
@@ -128,6 +129,24 @@ describe("web_search freshness normalization", () => {
});
});
describe("freshnessToPerplexityRecency", () => {
it("maps Brave shortcuts to Perplexity recency values", () => {
expect(freshnessToPerplexityRecency("pd")).toBe("day");
expect(freshnessToPerplexityRecency("pw")).toBe("week");
expect(freshnessToPerplexityRecency("pm")).toBe("month");
expect(freshnessToPerplexityRecency("py")).toBe("year");
});
it("returns undefined for date ranges (not supported by Perplexity)", () => {
expect(freshnessToPerplexityRecency("2024-01-01to2024-01-31")).toBeUndefined();
});
it("returns undefined for undefined/empty input", () => {
expect(freshnessToPerplexityRecency(undefined)).toBeUndefined();
expect(freshnessToPerplexityRecency("")).toBeUndefined();
});
});
describe("web_search grok config resolution", () => {
it("uses config apiKey when provided", () => {
expect(resolveGrokApiKey({ apiKey: "xai-test-key" })).toBe("xai-test-key");