Skip to content

Add optional Claude polish of transcripts - #12

Open
ichen27 wants to merge 1 commit into
fix/paste-at-cursorfrom
feat/claude-polish
Open

ichen27 wants to merge 1 commit into
fix/paste-at-cursorfrom
feat/claude-polish

Conversation

@ichen27

@ichen27 ichen27 commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Stacked on #11; retarget to main after it merges.

Problem

Rule-based cleanup can't fix grammar or punctuation, or resolve self-corrections like "meet at 3, no wait, 4". This adds an optional LLM pass for that.

Change

  • Settings → Transcription → Polish with Claude, off by default. It needs your own Anthropic API key, stored in Keychain under a separate account from the service token, and takes a model ID (default claude-opus-5-5).
  • After cleanup, the transcript text and vocabulary are sent to the Anthropic Messages API (POST /v1/messages, anthropic-version: 2026-10-21) over raw HTTP, since there's no official Swift SDK. The request uses output_config.effort: low and server-side refusal fallback (fallbacks: "default" with beta server-side-fallback-2026-07-01). Audio and screen content are never sent.
  • The transcript is wrapped in <transcript> tags with instructions to edit, never answer.
  • The cleaned text is kept, with the reason shown in the status, if any of these happen:
    • an HTTP error, or no reply within 8 s,
    • stop_reason of refusal or max_tokens,
    • a reply that no longer reads as the same dictation: large length change, mostly new words, or a dictated question that came back as an answer.
  • History stores the final inserted text.

Validation

  • Core checks cover the encoded request (model, effort, fallback, tags, vocabulary, no sampling parameters), response parsing (thinking blocks skipped, refusal and truncation rejected) and the plausibility guard. All native scripts and the distribution check pass.
  • Not verified: there are no Anthropic credentials on the build host, so no live request was sent. Do a manual run with a key before relying on it.

Risks

  • Opus at low effort adds roughly 1–3 s or more per dictation, which works against the latency fix. claude-haiku-5-5 is faster; set it in the model field.
  • The plausibility guard is a heuristic. A short answer that reuses most of the question's words could still get through.

Off by default. After rule-based cleanup, send the transcript text and
vocabulary to the Anthropic Messages API (claude-opus-5-5, low effort,
server-side refusal fallback) with the user's key from Keychain to fix grammar,
punctuation and self-corrections. Timeouts, errors, refusals, truncation and
replies that no longer read as the same dictation (such as an answer to a
dictated question) keep the cleaned text, and the status says why.
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.

1 participant