Skip to content

Commit 04101ca

Browse files
committed
feat: Add claude-sonnet-4.5 support by model-gating top_p
Signed-off-by: Will Killian <[email protected]>
1 parent a6a8dca commit 04101ca

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

docs/source/extend/adding-an-llm-provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Some configuration parameters are only valid for certain models or may be depend
8989
- `ThinkingMixin`: adds a `thinking` field, with a default of `None` when supported by a model. If supported, the `thinking_system_prompt` property will return the system prompt to use for thinking.
9090

9191
:::{note}
92-
The built-in mixins may reject certain fields for models that do not support them (for example, GPT-5 models currently reject `temperature` and `top_p`). If a gated field is explicitly set on an unsupported model, validation will fail.
92+
The built-in mixins may reject certain fields for models that do not support them (for example, GPT-5 models currently reject `temperature` and `top_p`). Claude Sonnet 4.5 models currently reject `top_p`. If a gated field is explicitly set on an unsupported model, validation will fail.
9393
:::
9494

9595
#### TemperatureMixin

src/nat/data_models/top_p_mixin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ class TopPMixin(
2828
field_name="top_p",
2929
default_if_supported=1.0,
3030
keys=("model_name", "model", "azure_deployment"),
31-
unsupported=(re.compile(r"gpt-?5", re.IGNORECASE), ),
31+
unsupported=(
32+
re.compile(r"gpt-?5", re.IGNORECASE),
33+
re.compile(r"claude.?sonnet.?4.5", re.IGNORECASE),
34+
),
3235
):
3336
"""
34-
Mixin class for top-p configuration. Unsupported on models like gpt-5.
37+
Mixin class for top-p configuration. Unsupported on models like gpt-5 and claude-sonnet-4.5.
3538
3639
Attributes:
3740
top_p: Top-p for distribution sampling. Defaults to 1.0 when supported on the model.

tests/nat/data_models/test_top_p_mixin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ class TestConfig(TopPMixin): # type: ignore
5454
with pytest.raises(ValidationError, match=r"top_p is not supported for model_name: gpt-5o"):
5555
_ = TestConfig(model_name="gpt-5o", top_p=0.2)
5656

57+
with pytest.raises(ValidationError, match=r"top_p is not supported for model_name: claude-sonnet-4.5"):
58+
_ = TestConfig(model_name="claude-sonnet-4.5", top_p=0.2)
59+
60+
with pytest.raises(ValidationError, match=r"top_p is not supported for model_name: claude-sonnet-4-5"):
61+
_ = TestConfig(model_name="claude-sonnet-4-5", top_p=0.2)
62+
5763

5864
def test_top_p_none_when_unsupported_and_value_none():
5965

0 commit comments

Comments
 (0)