mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-06 09:28:34 +00:00
fix(anthropic): distinguish sampling restrictions
Reuse adaptive-only version thresholds where the capabilities align, while preserving Mythos Preview's supported manual thinking budgets.
This commit is contained in:
parent
5e0ef36cf2
commit
e971f6bb8f
@ -41,12 +41,7 @@ _ADAPTIVE_ONLY_MIN_VERSIONS = {
|
|||||||
"fable": (5, 0),
|
"fable": (5, 0),
|
||||||
"mythos": (5, 0),
|
"mythos": (5, 0),
|
||||||
}
|
}
|
||||||
_SAMPLING_DEPRECATED_MIN_VERSIONS = {
|
_SAMPLING_DEPRECATED_MODELS = {"claude-mythos-preview"}
|
||||||
"opus": (4, 7),
|
|
||||||
"sonnet": (5, 0),
|
|
||||||
"fable": (5, 0),
|
|
||||||
"mythos": (5, 0),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def _model_version_at_least(
|
def _model_version_at_least(
|
||||||
@ -596,8 +591,10 @@ class AnthropicProvider(LLMProvider):
|
|||||||
reasoning_effort_lower = reasoning_effort.lower() if reasoning_effort else None
|
reasoning_effort_lower = reasoning_effort.lower() if reasoning_effort else None
|
||||||
thinking_enabled = reasoning_effort_lower not in (None, "", "none")
|
thinking_enabled = reasoning_effort_lower not in (None, "", "none")
|
||||||
adaptive_only = _model_version_at_least(model_name, _ADAPTIVE_ONLY_MIN_VERSIONS)
|
adaptive_only = _model_version_at_least(model_name, _ADAPTIVE_ONLY_MIN_VERSIONS)
|
||||||
omit_temperature = _model_version_at_least(
|
# Mythos Preview rejects sampling parameters but still accepts manual
|
||||||
model_name, _SAMPLING_DEPRECATED_MIN_VERSIONS
|
# thinking budgets, so it is not part of the adaptive-only capability.
|
||||||
|
omit_temperature = (
|
||||||
|
adaptive_only or model_name.lower() in _SAMPLING_DEPRECATED_MODELS
|
||||||
)
|
)
|
||||||
|
|
||||||
kwargs: dict[str, Any] = {
|
kwargs: dict[str, Any] = {
|
||||||
|
|||||||
@ -147,6 +147,13 @@ def test_sonnet_5_omits_temperature_none() -> None:
|
|||||||
assert "thinking" not in kw
|
assert "thinking" not in kw
|
||||||
|
|
||||||
|
|
||||||
|
def test_mythos_preview_omits_temperature_but_keeps_manual_budget() -> None:
|
||||||
|
kw = _build(_make_provider("claude-mythos-preview"), "high", max_tokens=4096)
|
||||||
|
assert "temperature" not in kw
|
||||||
|
assert kw["thinking"] == {"type": "enabled", "budget_tokens": 8192}
|
||||||
|
assert "extra_body" not in kw
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("reasoning_effort", [None, "adaptive", "low", "medium", "high", "xhigh", "max"])
|
@pytest.mark.parametrize("reasoning_effort", [None, "adaptive", "low", "medium", "high", "xhigh", "max"])
|
||||||
def test_opus_5_omits_temperature(reasoning_effort: str | None) -> None:
|
def test_opus_5_omits_temperature(reasoning_effort: str | None) -> None:
|
||||||
kw = _build(_make_provider("claude-opus-5"), reasoning_effort)
|
kw = _build(_make_provider("claude-opus-5"), reasoning_effort)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user