fix: FindModel reverse fuzzy match for date-suffixed model IDs
Add step between exact ID match and forward fuzzy match that checks if registry model ID starts with the requested name. Fixes models like 'gpt-5.4-mini' not matching 'gpt-5.4-mini-2026-04-01' in registry.
This commit is contained in:
@@ -58,3 +58,23 @@ func TestModelRegistry_FindModel_NotFound(t *testing.T) {
|
||||
t.Fatal("expected nil for nonexistent model")
|
||||
}
|
||||
}
|
||||
|
||||
func TestModelRegistry_FindModel_ReverseFuzzy(t *testing.T) {
|
||||
r := &ModelRegistry{
|
||||
Providers: map[string]ProviderInfo{
|
||||
"openai": {
|
||||
Models: map[string]ModelMetadata{
|
||||
"gpt-5.4-mini-2026-04-01": {ID: "gpt-5.4-mini-2026-04-01", Name: "GPT-5.4 Mini"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
// Reverse fuzzy: "gpt-5.4-mini" should match "gpt-5.4-mini-2026-04-01"
|
||||
m := r.FindModel("gpt-5.4-mini")
|
||||
if m == nil {
|
||||
t.Fatal("expected reverse fuzzy match")
|
||||
}
|
||||
if m.Name != "GPT-5.4 Mini" {
|
||||
t.Fatalf("expected GPT-5.4 Mini, got %s", m.Name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user