mirror of
https://github.com/mudler/LocalAI.git
synced 2026-10-28 09:08:54 -04:00
Add the add-on runtime to LocalAI: manifests, the host operation broker, admin gating by account role, the add-on UI bundle builder and the SDK for add-on pages. Move the navigation to Chat, Models, Add-ons and Settings, with pinned add-ons in the sidebar and an Add-ons drawer. Ship the first-party add-ons (voice, face, fine-tuning, quantization) as packages for linux/amd64, linux/arm64 and darwin/arm64. Intel macOS (darwin/amd64) is enabled in the platform files. Squashed from the review branch. The tree is unchanged; the pre-squash history is kept on a local backup branch. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package utils_test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
. "github.com/mudler/LocalAI/pkg/utils"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("ModelNameTaken", func() {
|
|
var dir string
|
|
|
|
BeforeEach(func() {
|
|
dir = GinkgoT().TempDir()
|
|
})
|
|
|
|
It("is free when nothing in the folder has the name", func() {
|
|
Expect(ModelNameTaken(dir, "my-model")).To(BeFalse())
|
|
})
|
|
|
|
It("is taken by a config file with the name", func() {
|
|
Expect(os.WriteFile(filepath.Join(dir, "my-model.yaml"), []byte("name: x"), 0600)).To(Succeed())
|
|
Expect(ModelNameTaken(dir, "my-model")).To(BeTrue())
|
|
})
|
|
|
|
It("is taken by a directory with the name, with no config file", func() {
|
|
Expect(os.Mkdir(filepath.Join(dir, "my-model"), 0750)).To(Succeed())
|
|
Expect(ModelNameTaken(dir, "my-model")).To(BeTrue())
|
|
})
|
|
|
|
It("is taken by a plain file with the name", func() {
|
|
Expect(os.WriteFile(filepath.Join(dir, "my-model"), []byte("x"), 0600)).To(Succeed())
|
|
Expect(ModelNameTaken(dir, "my-model")).To(BeTrue())
|
|
})
|
|
|
|
It("is taken by a file that has the name with another extension", func() {
|
|
Expect(os.WriteFile(filepath.Join(dir, "my-model.gguf"), []byte("x"), 0600)).To(Succeed())
|
|
Expect(ModelNameTaken(dir, "my-model")).To(BeTrue())
|
|
})
|
|
|
|
It("is taken when the name cannot be matched, so the guard refuses", func() {
|
|
Expect(ModelNameTaken(dir, "fo[")).To(BeTrue())
|
|
})
|
|
|
|
It("is not taken by a longer name that starts with it", func() {
|
|
Expect(os.Mkdir(filepath.Join(dir, "my-model-2"), 0750)).To(Succeed())
|
|
Expect(ModelNameTaken(dir, "my-model")).To(BeFalse())
|
|
})
|
|
})
|