From c8a4a4f4e9b515e839f36d3c872eba3f5d3c1c45 Mon Sep 17 00:00:00 2001 From: Aisuko Date: Fri, 2 Jun 2023 00:20:45 +1000 Subject: [PATCH 1/3] feat: Add new test cases for LoadConfigs (#447) Signed-off-by: Aisuko --- Makefile | 2 +- api/config.go | 13 ++++++++++--- api/config_test.go | 29 ++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6fa334ae..8c79251d 100644 --- a/Makefile +++ b/Makefile @@ -235,7 +235,7 @@ test-models/testmodel: test: prepare test-models/testmodel cp tests/models_fixtures/* test-models - C_INCLUDE_PATH=${C_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models $(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --flakeAttempts 5 -v -r ./api ./pkg + C_INCLUDE_PATH=${C_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models $(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --flake-attempts 5 -v -r ./api ./pkg ## Help: help: ## Show this help. diff --git a/api/config.go b/api/config.go index 42aecbe8..5204cea7 100644 --- a/api/config.go +++ b/api/config.go @@ -3,7 +3,7 @@ package api import ( "encoding/json" "fmt" - "io/ioutil" + "io/fs" "os" "path/filepath" "strings" @@ -130,11 +130,18 @@ func (cm ConfigMerger) ListConfigs() []string { func (cm ConfigMerger) LoadConfigs(path string) error { cm.Lock() defer cm.Unlock() - files, err := ioutil.ReadDir(path) + entries, err := os.ReadDir(path) if err != nil { return err } - + files := make([]fs.FileInfo, 0, len(entries)) + for _, entry := range entries { + info, err := entry.Info() + if err != nil { + return err + } + files = append(files, info) + } for _, file := range files { // Skip templates, YAML and .keep files if !strings.Contains(file.Name(), ".yaml") { diff --git a/api/config_test.go b/api/config_test.go index 9950f803..626b90be 100644 --- a/api/config_test.go +++ b/api/config_test.go @@ -3,6 +3,7 @@ package api import ( "os" + "github.com/go-skynet/LocalAI/pkg/model" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -20,8 +21,34 @@ var _ = Describe("Test cases for config related functions", func() { Expect(err).To(BeNil()) Expect(config).ToNot(BeNil()) // two configs in config.yaml - Expect(len(config)).To(Equal(2)) + Expect(config[0].Name).To(Equal("list1")) + Expect(config[1].Name).To(Equal("list2")) }) + It("Test LoadConfigs", func() { + cm := NewConfigMerger() + options := newOptions() + modelLoader := model.NewModelLoader(os.Getenv("MODELS_PATH")) + WithModelLoader(modelLoader)(options) + + err := cm.LoadConfigs(options.loader.ModelPath) + Expect(err).To(BeNil()) + Expect(cm.configs).ToNot(BeNil()) + + // config should includes gpt4all models's api.config + Expect(cm.configs).To(HaveKey("gpt4all")) + + // config should includes gpt2 models's api.config + Expect(cm.configs).To(HaveKey("gpt4all-2")) + + // config should includes text-embedding-ada-002 models's api.config + Expect(cm.configs).To(HaveKey("text-embedding-ada-002")) + + // config should includes rwkv_test models's api.config + Expect(cm.configs).To(HaveKey("rwkv_test")) + + // config should includes whisper-1 models's api.config + Expect(cm.configs).To(HaveKey("whisper-1")) + }) }) }) From c5cb2ff2687f7539696b710b5d97ea07e5899d77 Mon Sep 17 00:00:00 2001 From: "ci-robbot [bot]" <105103991+ci-robbot@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:21:13 +0200 Subject: [PATCH 2/3] :arrow_up: Update go-skynet/go-bert.cpp (#463) Signed-off-by: GitHub Co-authored-by: mudler --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8c79251d..836ef569 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ GOGGMLTRANSFORMERS_VERSION?=13ccc22621bb21afecd38675a2b043498e2e756c RWKV_REPO?=https://github.com/donomii/go-rwkv.cpp RWKV_VERSION?=ccb05c3e1c6efd098017d114dcb58ab3262b40b2 WHISPER_CPP_VERSION?=ce6f7470649f169027626dc92b3a2e39b4eff463 -BERT_VERSION?=771b4a08597224b21cff070950ef4f68690e14ad +BERT_VERSION?=0548994371f7081e45fcf8d472f3941a12f179aa BLOOMZ_VERSION?=1834e77b83faafe912ad4092ccf7f77937349e2f BUILD_TYPE?= CGO_LDFLAGS?= From 07cee3f6efe75ebfb820d12f8a4018e0fe8019c1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:21:32 +0200 Subject: [PATCH 3/3] fix(deps): update github.com/donomii/go-rwkv.cpp digest to 3b28b09 (#467) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 7ab82410..eaacf3e2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/go-skynet/LocalAI go 1.19 require ( - github.com/donomii/go-rwkv.cpp v0.0.0-20230531084548-c43cdf5fc5bf + github.com/donomii/go-rwkv.cpp v0.0.0-20230601111443-3b28b09469fc github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20230601065548-3f7436e8a096 github.com/go-audio/wav v1.1.0 github.com/go-skynet/bloomz.cpp v0.0.0-20230510223001-e9366e82abdf @@ -22,6 +22,7 @@ require ( github.com/rs/zerolog v1.29.1 github.com/sashabaranov/go-openai v1.9.5 github.com/swaggo/swag v1.16.1 + github.com/tmc/langchaingo v0.0.0-20230530193922-fb062652f841 github.com/urfave/cli/v2 v2.25.3 github.com/valyala/fasthttp v1.47.0 gopkg.in/yaml.v2 v2.4.0 @@ -59,7 +60,6 @@ require ( github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect github.com/tinylib/msgp v1.1.8 // indirect - github.com/tmc/langchaingo v0.0.0-20230530193922-fb062652f841 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect diff --git a/go.sum b/go.sum index 872940b2..f1cd37f0 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,8 @@ github.com/donomii/go-rwkv.cpp v0.0.0-20230529074347-ccb05c3e1c6e h1:YbcLoxAwS0r github.com/donomii/go-rwkv.cpp v0.0.0-20230529074347-ccb05c3e1c6e/go.mod h1:gWy7FIWioqYmYxkaoFyBnaKApeZVrUkHhv9EV9pz4dM= github.com/donomii/go-rwkv.cpp v0.0.0-20230531084548-c43cdf5fc5bf h1:upCz8WYdzMeJg0qywUaVaGndY+niuicj5j6V4pvhNS4= github.com/donomii/go-rwkv.cpp v0.0.0-20230531084548-c43cdf5fc5bf/go.mod h1:gWy7FIWioqYmYxkaoFyBnaKApeZVrUkHhv9EV9pz4dM= +github.com/donomii/go-rwkv.cpp v0.0.0-20230601111443-3b28b09469fc h1:RCGGh/zw+K09sjCIYHUV7lFenxONml+LS02RdN+AkwI= +github.com/donomii/go-rwkv.cpp v0.0.0-20230601111443-3b28b09469fc/go.mod h1:gWy7FIWioqYmYxkaoFyBnaKApeZVrUkHhv9EV9pz4dM= github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20230520182345-041be06d5881 h1:dafqVivljYk51VLFnnpTXJnfWDe637EobWZ1l8PyEf8= github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20230520182345-041be06d5881/go.mod h1:QIjZ9OktHFG7p+/m3sMvrAJKKdWrr1fZIK0rM6HZlyo= github.com/ggerganov/whisper.cpp/bindings/go v0.0.0-20230523110439-77eab3fbfe5e h1:4PMorQuoUGAXmIzCtnNOHaasyLokXdgd8jUWwsraFTo=