mirror of
https://github.com/mudler/LocalAI.git
synced 2024-06-07 19:40:48 +00:00
0b637465d9
some minor renames and refactorings within BackendConfigLoader - make things more consistent, remove underused code, rename things for clarity Signed-off-by: Dave Lee <dave@gray101.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Test cases for config related functions", func() {
|
|
|
|
var (
|
|
configFile string
|
|
)
|
|
|
|
Context("Test Read configuration functions", func() {
|
|
configFile = os.Getenv("CONFIG_FILE")
|
|
It("Test readConfigFile", func() {
|
|
config, err := readMultipleBackendConfigsFromFile(configFile)
|
|
Expect(err).To(BeNil())
|
|
Expect(config).ToNot(BeNil())
|
|
// two configs in config.yaml
|
|
Expect(config[0].Name).To(Equal("list1"))
|
|
Expect(config[1].Name).To(Equal("list2"))
|
|
})
|
|
|
|
It("Test LoadConfigs", func() {
|
|
|
|
bcl := NewBackendConfigLoader()
|
|
err := bcl.LoadBackendConfigsFromPath(os.Getenv("MODELS_PATH"))
|
|
|
|
Expect(err).To(BeNil())
|
|
configs := bcl.GetAllBackendConfigs()
|
|
loadedModelNames := []string{}
|
|
for _, v := range configs {
|
|
loadedModelNames = append(loadedModelNames, v.Name)
|
|
}
|
|
Expect(configs).ToNot(BeNil())
|
|
|
|
Expect(loadedModelNames).To(ContainElements("code-search-ada-code-001"))
|
|
|
|
// config should includes text-embedding-ada-002 models's api.config
|
|
Expect(loadedModelNames).To(ContainElements("text-embedding-ada-002"))
|
|
|
|
// config should includes rwkv_test models's api.config
|
|
Expect(loadedModelNames).To(ContainElements("rwkv_test"))
|
|
|
|
// config should includes whisper-1 models's api.config
|
|
Expect(loadedModelNames).To(ContainElements("whisper-1"))
|
|
})
|
|
})
|
|
})
|