mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 10:35:01 +00:00
refactor: gallery inconsistencies (#2647)
* refactor(gallery): move under core/ Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(unarchive): do not allow symlinks Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
69206fcd4b
commit
a181dd0ebc
25 changed files with 93 additions and 54 deletions
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/mudler/LocalAI/pkg/gallery"
|
||||
"github.com/mudler/LocalAI/pkg/xsysinfo"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
@ -36,7 +35,7 @@ type ApplicationConfig struct {
|
|||
|
||||
ModelLibraryURL string
|
||||
|
||||
Galleries []gallery.Gallery
|
||||
Galleries []Gallery
|
||||
|
||||
BackendAssets embed.FS
|
||||
AssetsDestination string
|
||||
|
@ -180,10 +179,10 @@ func WithBackendAssets(f embed.FS) AppOption {
|
|||
func WithStringGalleries(galls string) AppOption {
|
||||
return func(o *ApplicationConfig) {
|
||||
if galls == "" {
|
||||
o.Galleries = []gallery.Gallery{}
|
||||
o.Galleries = []Gallery{}
|
||||
return
|
||||
}
|
||||
var galleries []gallery.Gallery
|
||||
var galleries []Gallery
|
||||
if err := json.Unmarshal([]byte(galls), &galleries); err != nil {
|
||||
log.Error().Err(err).Msg("failed loading galleries")
|
||||
}
|
||||
|
@ -191,7 +190,7 @@ func WithStringGalleries(galls string) AppOption {
|
|||
}
|
||||
}
|
||||
|
||||
func WithGalleries(galleries []gallery.Gallery) AppOption {
|
||||
func WithGalleries(galleries []Gallery) AppOption {
|
||||
return func(o *ApplicationConfig) {
|
||||
o.Galleries = append(o.Galleries, galleries...)
|
||||
}
|
||||
|
|
|
@ -390,10 +390,6 @@ func (c *BackendConfig) Validate() bool {
|
|||
}
|
||||
}
|
||||
|
||||
if c.Name == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
if c.Backend != "" {
|
||||
// a regex that checks that is a string name with no special characters, except '-' and '_'
|
||||
re := regexp.MustCompile(`^[a-zA-Z0-9-_]+$`)
|
||||
|
|
|
@ -16,7 +16,8 @@ var _ = Describe("Test cases for config related functions", func() {
|
|||
Expect(err).To(BeNil())
|
||||
defer os.Remove(tmp.Name())
|
||||
_, err = tmp.WriteString(
|
||||
`backend: "foo-bar"
|
||||
`backend: "../foo-bar"
|
||||
name: "foo"
|
||||
parameters:
|
||||
model: "foo-bar"`)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
|
6
core/config/gallery.go
Normal file
6
core/config/gallery.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package config
|
||||
|
||||
type Gallery struct {
|
||||
URL string `json:"url" yaml:"url"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue