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,
|
&buf,
|
||||||
` %q: {
|
` %q: {
|
||||||
Name: %q,
|
Name: %q,
|
||||||
Provider: %q,
|
|
||||||
ContextLength: %d,
|
ContextLength: %d,
|
||||||
MaxOutputTokens: %d,
|
MaxOutputTokens: %d,
|
||||||
Supports: SupportedParameters{
|
Supports: SupportedParameters{
|
||||||
@@ -145,7 +144,6 @@ var generatedModels = map[string]ModelDefinition{
|
|||||||
`,
|
`,
|
||||||
m.ID,
|
m.ID,
|
||||||
m.Name,
|
m.Name,
|
||||||
provider,
|
|
||||||
m.ContextLen,
|
m.ContextLen,
|
||||||
m.TopProvider.MaxCompletionTokens,
|
m.TopProvider.MaxCompletionTokens,
|
||||||
buildSupports(m.SupportedParams),
|
buildSupports(m.SupportedParams),
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ type (
|
|||||||
ModelDefinition struct {
|
ModelDefinition struct {
|
||||||
ID string
|
ID string
|
||||||
Name string
|
Name string
|
||||||
Provider string
|
|
||||||
ContextLength int
|
ContextLength int
|
||||||
MaxOutputTokens int
|
MaxOutputTokens int
|
||||||
Supports SupportedParameters
|
Supports SupportedParameters
|
||||||
@@ -89,6 +88,13 @@ func (r *Registry) Lookup(modelID string) (ModelDefinition, bool) {
|
|||||||
return ModelDefinition{}, false
|
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) {
|
func (r *Registry) index(m *ModelDefinition) {
|
||||||
r.byID[m.ID] = m
|
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{
|
r := llm.NewRegistry(map[string]llm.ModelDefinition{
|
||||||
"acme/test-model-1.5": {
|
"acme/test-model-1.5": {
|
||||||
Name: "Acme: Test Model 1.5",
|
Name: "Acme: Test Model 1.5",
|
||||||
Provider: "acme",
|
|
||||||
ContextLength: 8192,
|
ContextLength: 8192,
|
||||||
MaxOutputTokens: 4096,
|
MaxOutputTokens: 4096,
|
||||||
Supports: llm.SupportedParameters{
|
Supports: llm.SupportedParameters{
|
||||||
@@ -46,7 +45,7 @@ func TestRegistry_Lookup(t *testing.T) {
|
|||||||
m, ok := r.Lookup("acme/test-model-1.5")
|
m, ok := r.Lookup("acme/test-model-1.5")
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
assert.Equal(t, "acme/test-model-1.5", m.ID)
|
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, 8192, m.ContextLength)
|
||||||
assert.Equal(t, 4096, m.MaxOutputTokens)
|
assert.Equal(t, 4096, m.MaxOutputTokens)
|
||||||
},
|
},
|
||||||
@@ -59,7 +58,7 @@ func TestRegistry_Lookup(t *testing.T) {
|
|||||||
|
|
||||||
m, ok := r.Lookup("test-model-1.5")
|
m, ok := r.Lookup("test-model-1.5")
|
||||||
require.True(t, ok)
|
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")
|
m, ok := r.Lookup("test-model-1-5")
|
||||||
require.True(t, ok)
|
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{
|
r := llm.NewRegistry(map[string]llm.ModelDefinition{
|
||||||
"acme/reasoning-model": {
|
"acme/reasoning-model": {
|
||||||
Name: "Acme: Reasoning Model",
|
Name: "Acme: Reasoning Model",
|
||||||
Provider: "acme",
|
|
||||||
Supports: llm.SupportedParameters{
|
Supports: llm.SupportedParameters{
|
||||||
Reasoning: true,
|
Reasoning: true,
|
||||||
Seed: true,
|
Seed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"acme/chat-model": {
|
"acme/chat-model": {
|
||||||
Name: "Acme: Chat Model",
|
Name: "Acme: Chat Model",
|
||||||
Provider: "acme",
|
|
||||||
Supports: llm.SupportedParameters{
|
Supports: llm.SupportedParameters{
|
||||||
Temperature: true,
|
Temperature: true,
|
||||||
TopP: true,
|
TopP: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user