@@ -32,38 +32,38 @@ var SupportedProviders = []string{
3232 "hf-inference" ,
3333}
3434
35- // HFModel represents a model from the Hugging Face Router API.
36- type HFModel struct {
37- ID string `json:"id"`
38- Object string `json:"object"`
39- Created int64 `json:"created"`
40- OwnedBy string `json:"owned_by"`
41- Providers []HFProvider `json:"providers"`
35+ // Model represents a model from the Hugging Face Router API.
36+ type Model struct {
37+ ID string `json:"id"`
38+ Object string `json:"object"`
39+ Created int64 `json:"created"`
40+ OwnedBy string `json:"owned_by"`
41+ Providers []Provider `json:"providers"`
4242}
4343
44- // HFProvider represents a provider configuration for a model.
45- type HFProvider struct {
46- Provider string `json:"provider"`
47- Status string `json:"status"`
48- ContextLength int64 `json:"context_length,omitempty"`
49- Pricing * HFPricing `json:"pricing,omitempty"`
50- SupportsTools bool `json:"supports_tools"`
51- SupportsStructuredOutput bool `json:"supports_structured_output"`
44+ // Provider represents a provider configuration for a model.
45+ type Provider struct {
46+ Provider string `json:"provider"`
47+ Status string `json:"status"`
48+ ContextLength int64 `json:"context_length,omitempty"`
49+ Pricing * Pricing `json:"pricing,omitempty"`
50+ SupportsTools bool `json:"supports_tools"`
51+ SupportsStructuredOutput bool `json:"supports_structured_output"`
5252}
5353
54- // HFPricing contains the pricing information for a provider.
55- type HFPricing struct {
54+ // Pricing contains the pricing information for a provider.
55+ type Pricing struct {
5656 Input float64 `json:"input"`
5757 Output float64 `json:"output"`
5858}
5959
60- // HFModelsResponse is the response structure for the Hugging Face Router models API.
61- type HFModelsResponse struct {
62- Object string `json:"object"`
63- Data []HFModel `json:"data"`
60+ // ModelsResponse is the response structure for the Hugging Face Router models API.
61+ type ModelsResponse struct {
62+ Object string `json:"object"`
63+ Data []Model `json:"data"`
6464}
6565
66- func fetchHuggingFaceModels () (* HFModelsResponse , error ) {
66+ func fetchHuggingFaceModels () (* ModelsResponse , error ) {
6767 client := & http.Client {Timeout : 30 * time .Second }
6868 req , _ := http .NewRequestWithContext (
6969 context .Background (),
@@ -81,15 +81,15 @@ func fetchHuggingFaceModels() (*HFModelsResponse, error) {
8181 body , _ := io .ReadAll (resp .Body )
8282 return nil , fmt .Errorf ("status %d: %s" , resp .StatusCode , body )
8383 }
84- var mr HFModelsResponse
84+ var mr ModelsResponse
8585 if err := json .NewDecoder (resp .Body ).Decode (& mr ); err != nil {
8686 return nil , err //nolint:wrapcheck
8787 }
8888 return & mr , nil
8989}
9090
9191// findContextWindow looks for a context window from any provider for the given model.
92- func findContextWindow (model HFModel ) int64 {
92+ func findContextWindow (model Model ) int64 {
9393 for _ , provider := range model .Providers {
9494 if provider .ContextLength > 0 {
9595 return provider .ContextLength
0 commit comments