on main help sign in
small fixes
c03817cKujtim Hoxha
internal/llm/models/local.go+4−4
@@ -2,6 +2,7 @@ package models
2
2
3import (
3import (
4 "cmp"
4 "cmp"
5+ "context"
5 "encoding/json"
6 "encoding/json"
6 "net/http"
7 "net/http"
7 "net/url"
8 "net/url"
@@ -53,7 +54,6 @@ func init() {
53 loadLocalModels(models)
54 loadLocalModels(models)
54
55
55 viper.SetDefault("providers.local.apiKey", "dummy")
56 viper.SetDefault("providers.local.apiKey", "dummy")
56− ProviderPopularity[ProviderLocal] = 0
57 }
57 }
58}
58}
59
59
@@ -75,7 +75,7 @@ type localModel struct {
75}
75}
76
76
77func listLocalModels(modelsEndpoint string) []localModel {
77func listLocalModels(modelsEndpoint string) []localModel {
78− res, err := http.Get(modelsEndpoint)
78+ res, err := http.NewRequestWithContext(context.Background(), http.MethodGet, modelsEndpoint, nil)
79 if err != nil {
79 if err != nil {
80 logging.Debug("Failed to list local models",
80 logging.Debug("Failed to list local models",
81 "error", err,
81 "error", err,
@@ -84,9 +84,9 @@ func listLocalModels(modelsEndpoint string) []localModel {
84 }
84 }
85 defer res.Body.Close()
85 defer res.Body.Close()
86
86
87− if res.StatusCode != http.StatusOK {
87+ if res.Response.StatusCode != http.StatusOK {
88 logging.Debug("Failed to list local models",
88 logging.Debug("Failed to list local models",
89− "status", res.StatusCode,
89+ "status", res.Response.Status,
90 "endpoint", modelsEndpoint,
90 "endpoint", modelsEndpoint,
91 )
91 )
92 }
92 }