Files
deepseek-harness/packages/web/web-search-perplexity
Dudu-0223 0a595aea78 test(web): cover the config-present branch of exa/perplexity apply
The numResults (exa) and searchRecency (perplexity) conditional spreads
in apply() were only exercised on their absent side, leaving the 100%
per-file branch gate red. Add plugin-registration tests that pass those
config fields and assert they reach the request body.
2026-07-03 17:03:54 +08:00
..

@deepseek-ai/dsh-web-search-perplexity

A Perplexity-backed WebSearchProvider for the harness web capability seam (ctx.web). It calls Perplexity's OpenAI-compatible POST /chat/completions endpoint and maps the generated answer plus citations into the seam's normalized WebSearchResult.

This is an implementation package: it registers a provider into ctx.web, it does not own the key and it does not register a model-facing tool. Like @deepseek-ai/dsh-llm-deepseek, it is a function/namespace plugin (inject: ['web']). The OpenAI-compatible wire shape is a provider-private detail — it does not make this provider depend on ctx.llm.

Config

Key Default Meaning
apiKey $PERPLEXITY_API_KEY Perplexity API key. Empty/absent → provider status() reports missing-credential.
baseURL https://api.perplexity.ai Endpoint base; /chat/completions is appended. An unparseable value makes status() report misconfigured.
model sonar Search model name.
maxTokens 1024 Upper bound on generated answer tokens (max_tokens). Must be a positive integer.
searchRecency (unset) Recency window sent as search_recency_filter: day, week, month, or year. Unset sends no filter.
- id: web-search-perplexity
  name: '@deepseek-ai/dsh-web-search-perplexity'
  config:
    apiKey: !!js process.env.PERPLEXITY_API_KEY

Mapping

contentchoices[0].message.content (the generated answer). sources[] prefers the structured search_results[] (url, title, snippet, publishedAtdate), falling back to the URL-only citations[] array only when search_results is absent — those sources carry just a url, which is why title/snippet/publishedAt are optional on the seam. Provider failures surface as WebError WEB_PROVIDER_ERROR; an aborted request surfaces as WEB_ABORTED. Perplexity has no result-count control, so maxResults is enforced by the seam (truncating sources[] and setting truncated).