You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
57 lines
1.6 KiB
1 year ago
|
package api_config_test
|
||
2 years ago
|
|
||
|
import (
|
||
|
"os"
|
||
|
|
||
1 year ago
|
. "github.com/go-skynet/LocalAI/api/config"
|
||
|
"github.com/go-skynet/LocalAI/api/options"
|
||
2 years ago
|
"github.com/go-skynet/LocalAI/pkg/model"
|
||
2 years ago
|
. "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 := ReadConfigFile(configFile)
|
||
|
Expect(err).To(BeNil())
|
||
|
Expect(config).ToNot(BeNil())
|
||
|
// two configs in config.yaml
|
||
2 years ago
|
Expect(config[0].Name).To(Equal("list1"))
|
||
|
Expect(config[1].Name).To(Equal("list2"))
|
||
2 years ago
|
})
|
||
|
|
||
2 years ago
|
It("Test LoadConfigs", func() {
|
||
1 year ago
|
cm := NewConfigLoader()
|
||
|
opts := options.NewOptions()
|
||
2 years ago
|
modelLoader := model.NewModelLoader(os.Getenv("MODELS_PATH"))
|
||
1 year ago
|
options.WithModelLoader(modelLoader)(opts)
|
||
2 years ago
|
|
||
1 year ago
|
err := cm.LoadConfigs(opts.Loader.ModelPath)
|
||
2 years ago
|
Expect(err).To(BeNil())
|
||
1 year ago
|
Expect(cm.ListConfigs()).ToNot(BeNil())
|
||
2 years ago
|
|
||
|
// config should includes gpt4all models's api.config
|
||
1 year ago
|
Expect(cm.ListConfigs()).To(ContainElements("gpt4all"))
|
||
2 years ago
|
|
||
|
// config should includes gpt2 models's api.config
|
||
1 year ago
|
Expect(cm.ListConfigs()).To(ContainElements("gpt4all-2"))
|
||
2 years ago
|
|
||
|
// config should includes text-embedding-ada-002 models's api.config
|
||
1 year ago
|
Expect(cm.ListConfigs()).To(ContainElements("text-embedding-ada-002"))
|
||
2 years ago
|
|
||
|
// config should includes rwkv_test models's api.config
|
||
1 year ago
|
Expect(cm.ListConfigs()).To(ContainElements("rwkv_test"))
|
||
2 years ago
|
|
||
|
// config should includes whisper-1 models's api.config
|
||
1 year ago
|
Expect(cm.ListConfigs()).To(ContainElements("whisper-1"))
|
||
2 years ago
|
})
|
||
2 years ago
|
})
|
||
|
})
|