2024-05-19 16:24:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2024-06-23 08:24:36 +00:00
|
|
|
"github.com/mudler/LocalAI/pkg/downloader"
|
|
|
|
"github.com/mudler/LocalAI/pkg/utils"
|
2024-05-19 16:24:27 +00:00
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Asset struct {
|
|
|
|
FileName string `yaml:"filename"`
|
|
|
|
URL string `yaml:"url"`
|
|
|
|
SHA string `yaml:"sha"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
// read the YAML file which contains a list of assets
|
|
|
|
// and download them in the asset path
|
|
|
|
assets := []Asset{}
|
|
|
|
|
|
|
|
assetFile := os.Args[1]
|
|
|
|
destPath := os.Args[2]
|
|
|
|
|
|
|
|
// read the YAML file
|
|
|
|
f, err := os.ReadFile(assetFile)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
// unmarshal the YAML data into a struct
|
|
|
|
if err := yaml.Unmarshal(f, &assets); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// download the assets
|
|
|
|
for _, asset := range assets {
|
2024-08-02 18:06:25 +00:00
|
|
|
uri := downloader.URI(asset.URL)
|
|
|
|
if err := uri.DownloadFile(filepath.Join(destPath, asset.FileName), asset.SHA, 1, 1, utils.DisplayDownloadFunction); err != nil {
|
2024-05-19 16:24:27 +00:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Finished downloading assets")
|
|
|
|
}
|