2024-02-21 01:21:19 +00:00
|
|
|
package config_test
|
2023-05-30 11:01:55 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2024-02-21 01:21:19 +00:00
|
|
|
. "github.com/go-skynet/LocalAI/core/config"
|
|
|
|
"github.com/go-skynet/LocalAI/core/options"
|
2024-01-05 17:04:46 +00:00
|
|
|
"github.com/go-skynet/LocalAI/pkg/model"
|
2023-05-30 11:01:55 +00:00
|
|
|
. "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() {
|
2024-01-05 17:04:46 +00:00
|
|
|
config, err := ReadConfigFile(configFile)
|
2023-05-30 11:01:55 +00:00
|
|
|
Expect(err).To(BeNil())
|
|
|
|
Expect(config).ToNot(BeNil())
|
|
|
|
// two configs in config.yaml
|
2023-06-01 14:20:45 +00:00
|
|
|
Expect(config[0].Name).To(Equal("list1"))
|
|
|
|
Expect(config[1].Name).To(Equal("list2"))
|
2023-05-30 11:01:55 +00:00
|
|
|
})
|
|
|
|
|
2023-06-01 14:20:45 +00:00
|
|
|
It("Test LoadConfigs", func() {
|
2024-01-05 17:04:46 +00:00
|
|
|
cm := NewConfigLoader()
|
|
|
|
opts := options.NewOptions()
|
|
|
|
modelLoader := model.NewModelLoader(os.Getenv("MODELS_PATH"))
|
|
|
|
options.WithModelLoader(modelLoader)(opts)
|
|
|
|
|
|
|
|
err := cm.LoadConfigs(opts.Loader.ModelPath)
|
2023-06-01 14:20:45 +00:00
|
|
|
Expect(err).To(BeNil())
|
2023-07-14 23:19:43 +00:00
|
|
|
Expect(cm.ListConfigs()).ToNot(BeNil())
|
2023-06-01 14:20:45 +00:00
|
|
|
|
|
|
|
// config should includes gpt4all models's api.config
|
2023-07-14 23:19:43 +00:00
|
|
|
Expect(cm.ListConfigs()).To(ContainElements("gpt4all"))
|
2023-06-01 14:20:45 +00:00
|
|
|
|
|
|
|
// config should includes gpt2 models's api.config
|
2023-07-14 23:19:43 +00:00
|
|
|
Expect(cm.ListConfigs()).To(ContainElements("gpt4all-2"))
|
2023-06-01 14:20:45 +00:00
|
|
|
|
|
|
|
// config should includes text-embedding-ada-002 models's api.config
|
2023-07-14 23:19:43 +00:00
|
|
|
Expect(cm.ListConfigs()).To(ContainElements("text-embedding-ada-002"))
|
2023-06-01 14:20:45 +00:00
|
|
|
|
|
|
|
// config should includes rwkv_test models's api.config
|
2023-07-14 23:19:43 +00:00
|
|
|
Expect(cm.ListConfigs()).To(ContainElements("rwkv_test"))
|
2023-06-01 14:20:45 +00:00
|
|
|
|
|
|
|
// config should includes whisper-1 models's api.config
|
2023-07-14 23:19:43 +00:00
|
|
|
Expect(cm.ListConfigs()).To(ContainElements("whisper-1"))
|
2023-06-01 14:20:45 +00:00
|
|
|
})
|
2023-05-30 11:01:55 +00:00
|
|
|
})
|
|
|
|
})
|