@@ -49,6 +49,7 @@ type remoteModel struct {
4949 OwnedBy string `json:"owned_by"`
5050 Task string `json:"task"`
5151 DisplayName string `json:"display_name"`
52+ OfficialName string `json:"official_name"`
5253 Public bool `json:"public"`
5354 MaxInputTokens int `json:"max_input_tokens"`
5455 MaxTokens int `json:"max_tokens"`
@@ -172,6 +173,9 @@ func modelInfoFromRemote(item remoteModel) (api.ModelInfo, bool) {
172173 }
173174
174175 displayName := strings .TrimSpace (item .DisplayName )
176+ if displayName == "" {
177+ displayName = strings .TrimSpace (item .OfficialName )
178+ }
175179 if displayName == "" {
176180 displayName = strings .TrimSpace (item .ID )
177181 }
@@ -187,6 +191,10 @@ func modelInfoFromRemote(item remoteModel) (api.ModelInfo, bool) {
187191 }
188192 limits := modelTokenLimitsFromRemote (item )
189193
194+ llmType := extractLLMType (item .Metadata )
195+ ownedBy := strings .TrimSpace (item .OwnedBy )
196+ pricing := extractPricing (item .Metadata )
197+
190198 return api.ModelInfo {
191199 Name : item .ID ,
192200 Model : item .ID ,
@@ -198,6 +206,9 @@ func modelInfoFromRemote(item remoteModel) (api.ModelInfo, bool) {
198206 PipelineTag : pipelineTag ,
199207 HasMMProj : item .Task == "image-text-to-text" ,
200208 ContextWindow : int64 (limits .MaxInputTokens ),
209+ LLMType : llmType ,
210+ OwnedBy : ownedBy ,
211+ Pricing : pricing ,
201212 }, true
202213}
203214
@@ -325,6 +336,90 @@ func firstPositive(values ...int) int {
325336 return 0
326337}
327338
339+ func extractLLMType (metadata map [string ]interface {}) string {
340+ if len (metadata ) == 0 {
341+ return ""
342+ }
343+ if v , ok := metadata ["llm_type" ]; ok {
344+ switch val := v .(type ) {
345+ case string :
346+ return strings .TrimSpace (val )
347+ }
348+ }
349+ return ""
350+ }
351+
352+ func extractPricing (metadata map [string ]interface {}) * api.ModelPricing {
353+ if len (metadata ) == 0 {
354+ return nil
355+ }
356+
357+ pricingMap , ok := metadata ["pricing" ].(map [string ]interface {})
358+ if ! ok || len (pricingMap ) == 0 {
359+ return nil
360+ }
361+
362+ input := extractTokenPrice (pricingMap ["input_token_price" ])
363+ output := extractTokenPrice (pricingMap ["output_token_price" ])
364+ if input == nil && output == nil {
365+ return nil
366+ }
367+
368+ return & api.ModelPricing {
369+ InputTokenPrice : input ,
370+ OutputTokenPrice : output ,
371+ }
372+ }
373+
374+ func extractTokenPrice (value interface {}) * api.ModelTokenPrice {
375+ priceMap , ok := value .(map [string ]interface {})
376+ if ! ok || len (priceMap ) == 0 {
377+ return nil
378+ }
379+
380+ price , ok := numericPriceValue (priceMap ["price_per_million" ])
381+ if ! ok {
382+ return nil
383+ }
384+
385+ return & api.ModelTokenPrice {
386+ Currency : stringValue (priceMap ["currency" ]),
387+ PricePerMillion : price ,
388+ }
389+ }
390+
391+ func stringValue (value interface {}) string {
392+ switch v := value .(type ) {
393+ case string :
394+ return strings .TrimSpace (v )
395+ default :
396+ return ""
397+ }
398+ }
399+
400+ func numericPriceValue (value interface {}) (float64 , bool ) {
401+ switch v := value .(type ) {
402+ case float64 :
403+ return v , true
404+ case float32 :
405+ return float64 (v ), true
406+ case int :
407+ return float64 (v ), true
408+ case int64 :
409+ return float64 (v ), true
410+ case int32 :
411+ return float64 (v ), true
412+ case json.Number :
413+ n , err := v .Float64 ()
414+ return n , err == nil
415+ case string :
416+ n , err := strconv .ParseFloat (strings .TrimSpace (v ), 64 )
417+ return n , err == nil
418+ default :
419+ return 0 , false
420+ }
421+ }
422+
328423func cloneModels (models []api.ModelInfo ) []api.ModelInfo {
329424 if len (models ) == 0 {
330425 return nil
0 commit comments