feat(startup): fetch model definition remotely (#1654)

This commit is contained in:
Ettore Di Giacinto 2024-01-28 00:14:16 +01:00 committed by GitHub
parent f928899338
commit 6ac5d814fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 68 additions and 6 deletions

View file

@ -6,6 +6,8 @@ import (
"slices"
"strings"
"github.com/go-skynet/LocalAI/pkg/downloader"
"github.com/go-skynet/LocalAI/pkg/assets"
"gopkg.in/yaml.v3"
)
@ -30,6 +32,19 @@ func init() {
yaml.Unmarshal(modelLibrary, &modelShorteners)
}
func GetRemoteLibraryShorteners(url string) (map[string]string, error) {
remoteLibrary := map[string]string{}
err := downloader.GetURI(url, func(_ string, i []byte) error {
return yaml.Unmarshal(i, &remoteLibrary)
})
if err != nil {
return nil, fmt.Errorf("error downloading remote library: %s", err.Error())
}
return remoteLibrary, err
}
// ExistsInModelsLibrary checks if a model exists in the embedded models library
func ExistsInModelsLibrary(s string) bool {
f := fmt.Sprintf("%s.yaml", s)