Skip to content

Commit 8ccd5ab

Browse files
authored
feat(webui): statically embed js/css assets (#2348)
* feat(webui): statically embed js/css assets Signed-off-by: Ettore Di Giacinto <[email protected]> * update font assets Signed-off-by: Ettore Di Giacinto <[email protected]> --------- Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 5a3db73 commit 8ccd5ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+20497
-11
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,3 +786,7 @@ docker-image-intel-xpu:
786786
.PHONY: swagger
787787
swagger:
788788
swag init -g core/http/app.go --output swagger
789+
790+
.PHONY: gen-assets
791+
gen-assets:
792+
$(GOCMD) run core/dependencies_manager/manager.go embedded/webui_static.yaml core/http/static/assets
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
8+
"github.com/go-skynet/LocalAI/pkg/downloader"
9+
"github.com/go-skynet/LocalAI/pkg/utils"
10+
"gopkg.in/yaml.v3"
11+
)
12+
13+
type Asset struct {
14+
FileName string `yaml:"filename"`
15+
URL string `yaml:"url"`
16+
SHA string `yaml:"sha"`
17+
}
18+
19+
func main() {
20+
21+
// read the YAML file which contains a list of assets
22+
// and download them in the asset path
23+
assets := []Asset{}
24+
25+
assetFile := os.Args[1]
26+
destPath := os.Args[2]
27+
28+
// read the YAML file
29+
f, err := os.ReadFile(assetFile)
30+
if err != nil {
31+
panic(err)
32+
}
33+
// unmarshal the YAML data into a struct
34+
if err := yaml.Unmarshal(f, &assets); err != nil {
35+
panic(err)
36+
}
37+
38+
// download the assets
39+
for _, asset := range assets {
40+
if err := downloader.DownloadFile(asset.URL, filepath.Join(destPath, asset.FileName), asset.SHA, 1, 1, utils.DisplayDownloadFunction); err != nil {
41+
panic(err)
42+
}
43+
}
44+
45+
fmt.Println("Finished downloading assets")
46+
}
35.6 KB
Binary file not shown.
127 KB
Binary file not shown.
35.4 KB
Binary file not shown.
35.2 KB
Binary file not shown.
35.1 KB
Binary file not shown.
127 KB
Binary file not shown.
35.4 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)