studio: stop forwarding top_k to Anthropic
Claude 4.x (Opus / Sonnet / Haiku 4.x) returns 400 'top_k is deprecated for this model' on any request that includes top_k. It was always optional on the older 3.x line, so dropping it unconditionally for every Anthropic call is the simplest path — no per-model gate to maintain. - external_provider._stream_anthropic no longer adds top_k to the Messages body (kept on the method signature for API symmetry). - provider-capabilities sets anthropic.topK = false so the chat settings panel hides the Top K slider for Anthropic providers and chat-adapter does not send top_k in the external request.
This commit is contained in:
parent
eeed153e2f
commit
b5aa6ffd7d
2 changed files with 12 additions and 4 deletions
|
|
@ -276,8 +276,13 @@ class ExternalProviderClient:
|
||||||
# Anthropic rejects requests that set both temperature and top_p
|
# Anthropic rejects requests that set both temperature and top_p
|
||||||
"stream": True,
|
"stream": True,
|
||||||
}
|
}
|
||||||
if top_k is not None and top_k > 0:
|
# top_k is deprecated on Claude 4.x (Opus / Sonnet / Haiku 4.x return
|
||||||
body["top_k"] = top_k
|
# 400 with `top_k is deprecated for this model`). It was always
|
||||||
|
# optional on the older 3.x line too, so we just stop forwarding it
|
||||||
|
# for every Anthropic call rather than maintaining a per-model gate.
|
||||||
|
# ``top_k`` is still accepted on the method signature for API
|
||||||
|
# symmetry with the other stream methods.
|
||||||
|
del top_k
|
||||||
if system:
|
if system:
|
||||||
body["system"] = system
|
body["system"] = system
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,11 +75,14 @@ const PROVIDER_CAPABILITIES: Record<string, ProviderCapabilities> = {
|
||||||
repetitionPenalty: false,
|
repetitionPenalty: false,
|
||||||
presencePenalty: false,
|
presencePenalty: false,
|
||||||
},
|
},
|
||||||
// Anthropic's Messages API accepts top_k but not presence/frequency penalty.
|
// Anthropic's Messages API rejects presence/frequency penalty, and top_k
|
||||||
|
// is now deprecated across the Claude 4.x line (Opus / Sonnet / Haiku 4.x
|
||||||
|
// 400 with "top_k is deprecated for this model"). It was always optional
|
||||||
|
// on the older 3.x line, so we just drop it for every Anthropic call.
|
||||||
anthropic: {
|
anthropic: {
|
||||||
temperature: true,
|
temperature: true,
|
||||||
topP: true,
|
topP: true,
|
||||||
topK: true,
|
topK: false,
|
||||||
minP: false,
|
minP: false,
|
||||||
repetitionPenalty: false,
|
repetitionPenalty: false,
|
||||||
presencePenalty: false,
|
presencePenalty: false,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue