diff --git a/internal/llm/models/local.go b/internal/llm/models/local.go index 5d8412c86a0f3f4ccf305763171f6acfdaea6eb1..6ff8391b48acf2d8553631b7a15ce9b758d0b480 100644 --- a/internal/llm/models/local.go +++ b/internal/llm/models/local.go @@ -2,6 +2,7 @@ package models import ( "cmp" + "context" "encoding/json" "net/http" "net/url" @@ -53,7 +54,6 @@ func init() { loadLocalModels(models) viper.SetDefault("providers.local.apiKey", "dummy") - ProviderPopularity[ProviderLocal] = 0 } } @@ -75,7 +75,7 @@ type localModel struct { } func listLocalModels(modelsEndpoint string) []localModel { - res, err := http.Get(modelsEndpoint) + res, err := http.NewRequestWithContext(context.Background(), http.MethodGet, modelsEndpoint, nil) if err != nil { logging.Debug("Failed to list local models", "error", err, @@ -84,9 +84,9 @@ func listLocalModels(modelsEndpoint string) []localModel { } defer res.Body.Close() - if res.StatusCode != http.StatusOK { + if res.Response.StatusCode != http.StatusOK { logging.Debug("Failed to list local models", - "status", res.StatusCode, + "status", res.Response.Status, "endpoint", modelsEndpoint, ) }