feat(admin): expose model vision capability in admin meta view

This commit is contained in:
2026-11-25 11:52:37 +00:00
parent 0f6201da38
commit 9dfc663b38
3 changed files with 53 additions and 5 deletions
+2
View File
@@ -566,6 +566,7 @@ type adminModelMetaView struct {
ContextTokens *int `json:"contextTokens,omitempty"` ContextTokens *int `json:"contextTokens,omitempty"`
InputPerMTokUSD *float64 `json:"inputPerMTokUsd,omitempty"` InputPerMTokUSD *float64 `json:"inputPerMTokUsd,omitempty"`
OutputPerMTokUSD *float64 `json:"outputPerMTokUsd,omitempty"` OutputPerMTokUSD *float64 `json:"outputPerMTokUsd,omitempty"`
Vision *bool `json:"vision,omitempty"`
} }
// buildAdminModelMetaView converts resolveModelMeta's result into the // buildAdminModelMetaView converts resolveModelMeta's result into the
@@ -574,6 +575,7 @@ type adminModelMetaView struct {
// do this). // do this).
func buildAdminModelMetaView(meta resolvedModelMeta) adminModelMetaView { func buildAdminModelMetaView(meta resolvedModelMeta) adminModelMetaView {
var v adminModelMetaView var v adminModelMetaView
v.Vision = meta.Vision
if meta.ContextKnown { if meta.ContextKnown {
ctx := meta.ContextTokens ctx := meta.ContextTokens
v.ContextTokens = &ctx v.ContextTokens = &ctx
+18 -5
View File
@@ -34,6 +34,8 @@ const freeTierSuffix = ":free"
// field, since a free model's cost fields are legitimately zero AND // field, since a free model's cost fields are legitimately zero AND
// known (ModelMetaConfig.Free). // known (ModelMetaConfig.Free).
type resolvedModelMeta struct { type resolvedModelMeta struct {
// Vision is the operator's explicit modelMeta.vision; nil means unset.
Vision *bool
ContextTokens int ContextTokens int
InputCostPerMTokMicroUSD int64 InputCostPerMTokMicroUSD int64
OutputCostPerMTokMicroUSD int64 OutputCostPerMTokMicroUSD int64
@@ -71,6 +73,7 @@ type resolvedModelMeta struct {
// entry. // entry.
func resolveModelMeta(provider, model string, cfg map[string]*ModelMetaConfig, discoveredContext int, discoveredKnown bool) resolvedModelMeta { func resolveModelMeta(provider, model string, cfg map[string]*ModelMetaConfig, discoveredContext int, discoveredKnown bool) resolvedModelMeta {
var out resolvedModelMeta var out resolvedModelMeta
out.Vision = configuredVision(provider, model, cfg)
override := lookupModelMetaConfig(provider, model, cfg) override := lookupModelMetaConfig(provider, model, cfg)
builtin, builtinOK := builtinModelMetaTable[model] builtin, builtinOK := builtinModelMetaTable[model]
@@ -190,15 +193,25 @@ func lookupModelMetaConfig(provider, model string, cfg map[string]*ModelMetaConf
// deployments keep today's behaviour. The exact "provider/model" key wins // deployments keep today's behaviour. The exact "provider/model" key wins
// over the bare key only when it sets Vision itself. // over the bare key only when it sets Vision itself.
func modelVisionCapable(provider, model string, cfg map[string]*ModelMetaConfig) bool { func modelVisionCapable(provider, model string, cfg map[string]*ModelMetaConfig) bool {
if v, ok := cfg[provider+"/"+model]; ok && v != nil && v.Vision != nil { if v := configuredVision(provider, model, cfg); v != nil {
return *v.Vision return *v
}
if v, ok := cfg[model]; ok && v != nil && v.Vision != nil {
return *v.Vision
} }
return true return true
} }
// configuredVision returns the explicitly configured Vision value, or nil
// when no applicable modelMeta entry sets it. Exact "provider/model" wins
// over the bare key only when it sets Vision itself.
func configuredVision(provider, model string, cfg map[string]*ModelMetaConfig) *bool {
if v, ok := cfg[provider+"/"+model]; ok && v != nil && v.Vision != nil {
return v.Vision
}
if v, ok := cfg[model]; ok && v != nil && v.Vision != nil {
return v.Vision
}
return nil
}
// resolveAliasModelMeta applies modelMeta's alias-inheritance rule // resolveAliasModelMeta applies modelMeta's alias-inheritance rule
// (feature v0.23): an alias inherits its target's fully resolved // (feature v0.23): an alias inherits its target's fully resolved
// metadata (resolveModelMeta against the alias's resolved provider/ // metadata (resolveModelMeta against the alias's resolved provider/
+33
View File
@@ -509,3 +509,36 @@ func TestModelMetaConfig_VisionJSONRoundTrip(t *testing.T) {
t.Errorf("unset vision must be omitted from JSON, got %s", out) t.Errorf("unset vision must be omitted from JSON, got %s", out)
} }
} }
func TestAdminModelMetaView_Vision(t *testing.T) {
t.Parallel()
yes, no := true, false
cfg := map[string]*ModelMetaConfig{
"p/seen": {Vision: &yes},
"p/blind": {Vision: &no},
"p/other": {ContextTokens: 1000},
}
cases := []struct {
want *bool
model string
wantJSON bool
}{
{&yes, "seen", true},
{&no, "blind", true},
{nil, "other", false},
{nil, "absent", false},
}
for _, c := range cases {
view := buildAdminModelMetaView(resolveModelMeta("p", c.model, cfg, 0, false))
if (view.Vision == nil) != (c.want == nil) || (c.want != nil && *view.Vision != *c.want) {
t.Fatalf("%s: Vision = %v, want %v", c.model, view.Vision, c.want)
}
raw, err := json.Marshal(view)
if err != nil {
t.Fatal(err)
}
if got := strings.Contains(string(raw), `"vision"`); got != c.wantJSON {
t.Fatalf("%s: json %s, vision present = %v, want %v", c.model, raw, got, c.wantJSON)
}
}
}