Repository navigation
Conversation
916eb3a to
dff2541
Compare
|
Updated this PR to make Perplexity strictly opt-in instead of default — Exa remains the default backend. Force-pushed Changes vs. the previous revision:
To use Perplexity now: OPENCODE_ENABLE_PERPLEXITY=1 PERPLEXITY_API_KEY=pplx-... opencode |
Adds a Perplexity Search API backend for the `websearch` tool, opt-in via `OPENCODE_ENABLE_PERPLEXITY=1` with `PERPLEXITY_API_KEY` (or `PPLX_API_KEY`). Exa remains the default backend.
dff2541 to
837e85e
Compare
|
Rebased onto latest Upstream changed
I integrated Perplexity into that new architecture rather than fighting it:
PR is |
# Conflicts: # packages/core/src/flag/flag.ts # packages/opencode/src/tool/registry.ts # packages/opencode/src/tool/websearch.ts
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #
Type of change
What does this PR do?
The
websearchtool today calls Exa via the hosted MCP endpoint and is the only backend available. This PR adds the Perplexity Search API as a second, opt-in backend. Exa remains the default. Users who want to use Perplexity explicitly setOPENCODE_ENABLE_PERPLEXITY=1with aPERPLEXITY_API_KEY(orPPLX_API_KEY).Why: gating the existing tool behind a single proprietary backend shouldn't be the only option. Letting users pick keeps Exa first-class for people who already pay for it, and gives everyone else a way to plug in a different search provider without rewriting the tool.
How it works:
mcp-perplexity.tsmakes a direct REST call tohttps://api.perplexity.ai/search(Perplexity has no hosted MCP HTTP endpoint, only stdio, so the MCP-style naming is just for symmetry withmcp-exa.ts). SendsAuthorization: Bearer $PERPLEXITY_API_KEYandX-Pplx-Integration: opencode/<version>so usage is attributable on our side.websearch.tschooses the backend at runtime. Selection precedence:OPENCODE_ENABLE_EXA=1or provider isopencode-> Exa (default)OPENCODE_ENABLE_PERPLEXITY=1withPERPLEXITY_API_KEY(orPPLX_API_KEY) -> Perplexityflag.tsaddsOPENCODE_ENABLE_PERPLEXITY, which is strictly opt-in — setting just a Perplexity key does not enable it.registry.tsgating: surface the websearch tool when either backend is active, instead of only when Exa is active.providers.mdxadds Perplexity to the LLM provider listing (Agent API is OpenAI-compatible athttps://api.perplexity.ai).tools.mdxdocuments the dual websearch backends and the precedence rules.Existing Exa users see no behavior change. Users who want Perplexity must explicitly opt in with
OPENCODE_ENABLE_PERPLEXITY=1.This replaces the docs-only PR #24976, which was closed in favor of shipping docs + code together.
How did you verify your code works?
bun run typecheckpasses forpackages/opencodeandpackages/core.packages/opencode/test/tool/__snapshots__/parameters.test.ts.snapupdated and passing (thelivecrawlandtypeparameter descriptions changed since they're Exa-specific now).mcp-perplexity.callwith a realPERPLEXITY_API_KEYagainstapi.perplexity.ai/searchand confirmed the response parses, the integration header is sent, andcontextMaxCharacterstruncation works.mcp-exa.tshas no equivalent test pattern in this repo to mirror; happy to add one if a maintainer points to a preferred fixture style.Screenshots / recordings
N/A (CLI tool, no UI).
Checklist