Skip to content

Summaries through OpenAI and Anthropic - #60

Merged
thesiti92 merged 8 commits into
mainfrom
feat/summary-providers
Oct 1, 2026
Merged

thesiti92 merged 8 commits into
mainfrom
feat/summary-providers

Conversation

@thesiti92

@thesiti92 thesiti92 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Adds openai and anthropic to the summarizer's existing provider option. openai also works with any OpenAI-compatible server set in endpoint, such as Ollama, LM Studio or OpenRouter. For devdotfast/whiteboard#788.

  • Config compatibility. No new keys. Existing configs keep working; Gemini keeps its URL, key header and env vars, but its request now uses the shared schema (below).
  • Keys. Each provider falls back to its own environment variable: GEMINI_API_KEY/GOOGLE_API_KEY, OPENAI_API_KEY or ANTHROPIC_API_KEY. openai with a custom endpoint may go without a key.
  • Endpoint. endpoint = "" now means the provider's default URL.
  • Structured outputs. All three providers constrain the answer with one schema, {"summaries": [{id, summary, pseudocode}]}: Gemini through responseJsonSchema (replacing responseSchema), OpenAI through response_format (json_schema, strict), Anthropic through output_config.format. OpenAI and Anthropic take only an object at the root, hence the wrapper. A compatible server that rejects the schema fails with its own error.
  • Answers. For servers that ignore the schema, the answer is read from the first JSON array of summaries in the model's text, so code fences, prose and <think> text around it are ignored.
  • Anthropic. Requests send no temperature, which current Claude models reject, and use a 4096 floor on max_tokens, since thinking tokens count against it.

plugin.wasm is rebuilt with cargo xtask build-plugins. Tested against a local HTTP server, and live against Gemini (gemini-3.8-flash), OpenAI (gpt-5-mini) and Anthropic (claude-haiku-4-5, claude-sonnet-5-5, claude-opus-5-5), including the old materialized prompt: cargo test and cargo xtask test-plugins both pass.

Keys now come from the provider's own variables, and an empty endpoint means the provider's default. Gemini requests are unchanged.
The provider-rejection tests now use an unknown provider, since openai is valid.
Current Claude models reject temperature, and their token limit also covers thinking, so it gets a 4096 floor. Answers are now read from the first JSON array of summaries, which skips lead-ins, trailing notes and reasoning that contain brackets.
Both take only an object at the root, so their answers are {"summaries": [...]}. A server that rejects the schema fails the request; one that ignores it is still parsed leniently.
Gemini now takes the same JSON Schema through responseJsonSchema, and the default prompt asks for the {"summaries": [...]} object.
default.toml repeated the old prompt, so configs without an explicit plugin order kept it. A test now checks that default.toml agrees with each plugin.toml.
@thesiti92
thesiti92 force-pushed the feat/summary-providers branch from bda7523 to e98557d Compare October 1, 2026 14:56
@thesiti92
thesiti92 merged commit 1fb42ca into main Oct 1, 2026
46 checks passed
@thesiti92 thesiti92 mentioned this pull request Oct 1, 2026
thesiti92 added a commit to devdotfast/whiteboard that referenced this pull request Oct 2, 2026
Closes #788. Bundles diffr 0.1.9 (devdotfast/diffr#60, #62 and #65).

**Settings → AI summaries**
- **Provider:** Gemini, OpenAI (also any OpenAI-compatible server) or
Anthropic. Switching resets the model to that provider's default.
- **Endpoint URL:** optional. Leave it empty for the provider's own API.
- **Prompt:** editable, showing whether it is the default or customized,
with "Reset to default". The description says diffr asks for structured
output where the provider supports it.
- **Test setup:** uses the draft provider, endpoint and prompt, so you
can try them before saving.
- **Keys:** switching providers clears a key saved for the previous one,
so a key is never sent to another vendor. Credentials are checked
against the chosen provider's environment variable.

**No duplicated defaults.** Provider ids, titles, default models,
endpoints, key variables and the keyless rule all come from `diffr
config schema`. A default changed in diffr, or a provider added there,
needs no change here.

**Server**
- Reads the default prompt from `diffr config schema`.
- Writes only settings that changed. diffr now drops values that equal
their defaults, so resetting the prompt removes it from the config file.

**Verified**
- Unit tests (19) and browser tests (10) pass.
- Against a local diffr build with the same code:
- switching provider clears the old key and keeps the config file
sparse;
  - resetting the prompt removes it from the file;
  - Test setup works through a keyless OpenAI-compatible server;
  - Test setup works live against Anthropic (`claude-sonnet-5-5`).
- Checked in an isolated dev Desktop; that check caught two UI fixes.
- `test:integration:diffr` (16) passes against the pinned 0.1.9 release.
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