Skip to content

Commit f66b34d

Browse files
committed
feat: expose richer model metadata in v1/models
Enrich OpenAIModel schema with additional metadata: - context_window - architecture - parameters - quantization - size This allows client applications to better understand model capabilities.
1 parent 9803886 commit f66b34d

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

pkg/inference/models/api.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,26 @@ func ToOpenAI(m types.Model) (*OpenAIModel, error) {
8282
id = tags[0]
8383
}
8484

85+
config, err := m.Config()
86+
if err != nil {
87+
return nil, fmt.Errorf("get config: %w", err)
88+
}
89+
90+
var contextWindow int32
91+
if cw := config.GetContextSize(); cw != nil {
92+
contextWindow = *cw
93+
}
94+
8595
return &OpenAIModel{
86-
ID: id,
87-
Object: "model",
88-
Created: created,
89-
OwnedBy: "docker",
96+
ID: id,
97+
Object: "model",
98+
Created: created,
99+
OwnedBy: "docker",
100+
ContextWindow: contextWindow,
101+
Architecture: config.GetArchitecture(),
102+
Parameters: config.GetParameters(),
103+
Quantization: config.GetQuantization(),
104+
Size: config.GetSize(),
90105
}, nil
91106
}
92107

@@ -100,6 +115,13 @@ type OpenAIModel struct {
100115
Created int64 `json:"created"`
101116
// OwnedBy is the model owner. At the moment, it is always "docker".
102117
OwnedBy string `json:"owned_by"`
118+
119+
// Additional metadata
120+
ContextWindow int32 `json:"context_window,omitempty"`
121+
Architecture string `json:"architecture,omitempty"`
122+
Parameters string `json:"parameters,omitempty"`
123+
Quantization string `json:"quantization,omitempty"`
124+
Size string `json:"size,omitempty"`
103125
}
104126

105127
// OpenAIModelList represents a list of models using OpenAI conventions.

0 commit comments

Comments
 (0)