feat(registry): expose generation defaults on selectable models
This commit is contained in:
@@ -171,6 +171,11 @@ class SelectableModel(BaseModel):
|
||||
name: str
|
||||
provider_name: str
|
||||
effective_capabilities: Capabilities
|
||||
# Registry-effective generation defaults (model value wins over the
|
||||
# provider default; both unset -> null). Lets chat UIs anchor their
|
||||
# temperature/top_p sliders without a registry read.
|
||||
default_temperature: float | None = None
|
||||
default_top_p: float | None = None
|
||||
|
||||
|
||||
class GetSelectableModelsResponse(BaseModel):
|
||||
@@ -855,6 +860,16 @@ class ModelRegistryHttpApi:
|
||||
name=model.name,
|
||||
provider_name=provider.name,
|
||||
effective_capabilities=item.effective_capabilities,
|
||||
default_temperature=(
|
||||
model.runtime.temperature
|
||||
if model.runtime.temperature is not None
|
||||
else provider.runtime.default_temperature
|
||||
),
|
||||
default_top_p=(
|
||||
model.runtime.top_p
|
||||
if model.runtime.top_p is not None
|
||||
else provider.runtime.default_top_p
|
||||
),
|
||||
)
|
||||
)
|
||||
return GetSelectableModelsResponse(models=models, defaults=registry.defaults)
|
||||
|
||||
@@ -1178,6 +1178,30 @@
|
||||
"SelectableModel": {
|
||||
"description": "One entry of the section 9.1 model selector response.",
|
||||
"properties": {
|
||||
"default_temperature": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"default": null,
|
||||
"title": "Default Temperature"
|
||||
},
|
||||
"default_top_p": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"default": null,
|
||||
"title": "Default Top P"
|
||||
},
|
||||
"effective_capabilities": {
|
||||
"$ref": "#/components/schemas/Capabilities"
|
||||
},
|
||||
|
||||
@@ -669,6 +669,14 @@ def test_get_models_returns_only_selectable(active_client, store):
|
||||
"vision": False,
|
||||
"structured_output": True,
|
||||
}
|
||||
# Generation defaults ride the catalog so the chat-bar sliders can show
|
||||
# the registry-effective values before any override (model value wins
|
||||
# over the provider default; qwen3 inherits nothing -> null).
|
||||
assert glm["default_temperature"] == 0.7
|
||||
assert glm["default_top_p"] == 0.95
|
||||
qwen = next(m for m in models if m["model_ref"]["model_key"] == "qwen3")
|
||||
assert qwen["default_temperature"] is None
|
||||
assert qwen["default_top_p"] is None
|
||||
# The selector echoes the registry defaults so clients can label the
|
||||
# `inherit` choice before the first turn.
|
||||
assert response.json()["defaults"]["primary"] == {
|
||||
|
||||
Reference in New Issue
Block a user