mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-28 14:35:00 +00:00
feat(startup): fetch model definition remotely (#1654)
This commit is contained in:
parent
f928899338
commit
6ac5d814fb
6 changed files with 68 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue