Derive provider from model ID
The provider is always the prefix before "/" in the model ID, so storing it as a separate field is redundant. Replace the field with a Provider() method. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
committed by
Sacha Al Himdani
parent
adeef0d5cb
commit
481b56402a
@@ -136,7 +136,6 @@ var generatedModels = map[string]ModelDefinition{
|
||||
&buf,
|
||||
` %q: {
|
||||
Name: %q,
|
||||
Provider: %q,
|
||||
ContextLength: %d,
|
||||
MaxOutputTokens: %d,
|
||||
Supports: SupportedParameters{
|
||||
@@ -145,7 +144,6 @@ var generatedModels = map[string]ModelDefinition{
|
||||
`,
|
||||
m.ID,
|
||||
m.Name,
|
||||
provider,
|
||||
m.ContextLen,
|
||||
m.TopProvider.MaxCompletionTokens,
|
||||
buildSupports(m.SupportedParams),
|
||||
|
||||
@@ -24,7 +24,6 @@ type (
|
||||
ModelDefinition struct {
|
||||
ID string
|
||||
Name string
|
||||
Provider string
|
||||
ContextLength int
|
||||
MaxOutputTokens int
|
||||
Supports SupportedParameters
|
||||
@@ -89,6 +88,13 @@ func (r *Registry) Lookup(modelID string) (ModelDefinition, bool) {
|
||||
return ModelDefinition{}, false
|
||||
}
|
||||
|
||||
// Provider returns the provider prefix from the model ID (e.g. "anthropic"
|
||||
// from "anthropic/claude-opus-4.6").
|
||||
func (m *ModelDefinition) Provider() string {
|
||||
provider, _, _ := strings.Cut(m.ID, "/")
|
||||
return provider
|
||||
}
|
||||
|
||||
func (r *Registry) index(m *ModelDefinition) {
|
||||
r.byID[m.ID] = m
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,6 @@ func TestRegistry_Lookup(t *testing.T) {
|
||||
r := llm.NewRegistry(map[string]llm.ModelDefinition{
|
||||
"acme/test-model-1.5": {
|
||||
Name: "Acme: Test Model 1.5",
|
||||
Provider: "acme",
|
||||
ContextLength: 8192,
|
||||
MaxOutputTokens: 4096,
|
||||
Supports: llm.SupportedParameters{
|
||||
@@ -46,7 +45,7 @@ func TestRegistry_Lookup(t *testing.T) {
|
||||
m, ok := r.Lookup("acme/test-model-1.5")
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "acme/test-model-1.5", m.ID)
|
||||
assert.Equal(t, "acme", m.Provider)
|
||||
assert.Equal(t, "acme", m.Provider())
|
||||
assert.Equal(t, 8192, m.ContextLength)
|
||||
assert.Equal(t, 4096, m.MaxOutputTokens)
|
||||
},
|
||||
@@ -59,7 +58,7 @@ func TestRegistry_Lookup(t *testing.T) {
|
||||
|
||||
m, ok := r.Lookup("test-model-1.5")
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "acme", m.Provider)
|
||||
assert.Equal(t, "acme", m.Provider())
|
||||
},
|
||||
)
|
||||
|
||||
@@ -70,7 +69,7 @@ func TestRegistry_Lookup(t *testing.T) {
|
||||
|
||||
m, ok := r.Lookup("test-model-1-5")
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "acme", m.Provider)
|
||||
assert.Equal(t, "acme", m.Provider())
|
||||
},
|
||||
)
|
||||
|
||||
@@ -110,16 +109,14 @@ func TestRegistry_Capabilities(t *testing.T) {
|
||||
|
||||
r := llm.NewRegistry(map[string]llm.ModelDefinition{
|
||||
"acme/reasoning-model": {
|
||||
Name: "Acme: Reasoning Model",
|
||||
Provider: "acme",
|
||||
Name: "Acme: Reasoning Model",
|
||||
Supports: llm.SupportedParameters{
|
||||
Reasoning: true,
|
||||
Seed: true,
|
||||
},
|
||||
},
|
||||
"acme/chat-model": {
|
||||
Name: "Acme: Chat Model",
|
||||
Provider: "acme",
|
||||
Name: "Acme: Chat Model",
|
||||
Supports: llm.SupportedParameters{
|
||||
Temperature: true,
|
||||
TopP: true,
|
||||
|
||||
Reference in New Issue
Block a user