diff --git a/.github/ci/modelslist.go b/.github/ci/modelslist.go new file mode 100644 index 000000000000..55a839e3d4d7 --- /dev/null +++ b/.github/ci/modelslist.go @@ -0,0 +1,132 @@ +package main + +import ( + "fmt" + "html/template" + "io/ioutil" + "os" + + "gopkg.in/yaml.v3" +) + +var modelPageTemplate string = ` + + + + LocalAI model gallery + + + + +
+
+ +
+
+

+ LocalAI model gallery list +

+

+ Here is a glimpse of the models you can find in LocalAI. To use the models, you can download them from the LocalAI app. +

+
+
+ + +
+
+ + +
+ + {{ range $_, $model := .Models }} +
+ {{$model.Name}} + {{$model.Name}} + {{ range $_, $u := $model.URLs }} +

{{ $u }}

+ {{ end }} +

{{ $model.Description }}

+ Install in LocalAI ( instance at localhost:8080 ) +
+ {{ end }} +
+ +
+
+ + + + +` + +type GalleryModel struct { + Name string `json:"name" yaml:"name"` + URLs []string `json:"urls" yaml:"urls"` + Icon string `json:"icon" yaml:"icon"` + Description string `json:"description" yaml:"description"` +} + +func main() { + // read the YAML file which contains the models + + f, err := ioutil.ReadFile(os.Args[1]) + if err != nil { + fmt.Println("Error reading file:", err) + return + } + + models := []*GalleryModel{} + err = yaml.Unmarshal(f, &models) + if err != nil { + // write to stderr + os.Stderr.WriteString("Error unmarshaling YAML: " + err.Error() + "\n") + return + } + + // render the template + data := struct { + Models []*GalleryModel + }{ + Models: models, + } + tmpl := template.Must(template.New("modelPage").Parse(modelPageTemplate)) + + err = tmpl.Execute(os.Stdout, data) + if err != nil { + fmt.Println("Error executing template:", err) + return + } +} diff --git a/Makefile b/Makefile index 066e655be7a2..08466a7a957f 100644 --- a/Makefile +++ b/Makefile @@ -836,4 +836,10 @@ swagger: .PHONY: gen-assets gen-assets: - $(GOCMD) run core/dependencies_manager/manager.go embedded/webui_static.yaml core/http/static/assets \ No newline at end of file + $(GOCMD) run core/dependencies_manager/manager.go embedded/webui_static.yaml core/http/static/assets + +docs/layouts/_default: + mkdir -p docs/layouts/_default + +docs-models: docs/layouts/_default + $(GOCMD) run ./.github/ci/modelslist.go ./gallery/index.yaml > docs/layouts/_default/gallery.html \ No newline at end of file diff --git a/docs/content/docs/gallery.md b/docs/content/docs/gallery.md new file mode 100644 index 000000000000..7de13a725d3b --- /dev/null +++ b/docs/content/docs/gallery.md @@ -0,0 +1,6 @@ + ++++ +title = "Gallery" +layout = "gallery" +url = '/gallery/' ++++ \ No newline at end of file