Skip to content

fix(anthropic): omit unsupported sampling fields for Claude 5 - #6965

Open
feiiiiii5 wants to merge 1 commit into
ChatGPTNextWeb:mainfrom
feiiiiii5:fix/6918-claude5-sampling
Open

feiiiiii5 wants to merge 1 commit into
ChatGPTNextWeb:mainfrom
feiiiiii5:fix/6918-claude5-sampling

Conversation

@feiiiiii5

Copy link
Copy Markdown

💻 变更类型 | Change Type

  • fix

🔀 变更说明 | Description of Change

Claude 5 model IDs now omit temperature, top_p, and top_k from Anthropic Messages requests. The predicate matches claude-{fable,haiku,mythos,opus,sonnet}-5 with a version suffix or boundary, so Claude 3/4 and non-Anthropic behavior is unchanged.

Fixes #6918. This does not overlap open PRs #6891/#6765, which only omit top_p for Claude 4.

No cache, client, connection, long-lived object, timer, loop, or retained global state is added; the helper copies the local request body per call.

📝 补充信息 | Additional Information

Reproduction from #6918: a direct Anthropic request with claude-sonnet-5-5 succeeds, while NextChat's request with sampling fields is rejected. The current request builder always sends temperature, top_p, and a hard-coded top_k: 5.

Validation:

  • Base 1d3dc331512929a4b1d3e82354e72acce33b5c7a with the new Jest test: 1 suite failed with SyntaxError: The requested module '../app/client/platforms/anthropic' does not provide an export named 'isClaude5Model'; source restored byte-identically afterward.
  • This branch: focused yarn test:ci --runInBand test/anthropic-sampling-params.test.ts — 7 passed.
  • Full suite: yarn test:ci --runInBand — 37 suites, 181 tests passed.
  • yarn tsc --noEmit — passed; git diff --check — passed.
  • No paid API call, Docker deployment, or browser request capture was used; the evidence is the request-builder unit test and local checks.
  • The repository's lint-staged hook reformatted two long unrelated lines in anthropic.ts; no behavior outside this fix changed.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

[Bug] "Model not found" for virtually any Anthropic model

1 participant