forked from mudler/LocalAI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: mudler <[email protected]>
- Loading branch information
Showing
9 changed files
with
168 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
name: 'tests' | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
ubuntu-latest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v1 | ||
with: | ||
submodules: true | ||
- name: Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install build-essential | ||
- name: Test | ||
run: | | ||
make test | ||
# macOS-latest: | ||
# runs-on: macOS-latest | ||
|
||
# steps: | ||
# - name: Clone | ||
# uses: actions/checkout@v1 | ||
# with: | ||
# submodules: true | ||
|
||
# - name: Dependencies | ||
# run: | | ||
# brew update | ||
# brew install sdl2 | ||
|
||
# - name: Test | ||
# run: | | ||
# make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ local-ai | |
|
||
# Ignore models | ||
models/*.bin | ||
models/ggml-* | ||
models/ggml-* | ||
test-models/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package api_test | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
. "github.com/go-skynet/LocalAI/api" | ||
"github.com/go-skynet/LocalAI/pkg/model" | ||
"github.com/gofiber/fiber/v2" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/sashabaranov/go-openai" | ||
) | ||
|
||
var _ = Describe("API test", func() { | ||
|
||
var app *fiber.App | ||
var modelLoader *model.ModelLoader | ||
var client *openai.Client | ||
Context("API query", func() { | ||
BeforeEach(func() { | ||
modelLoader = model.NewModelLoader(os.Getenv("MODELS_PATH")) | ||
app = App(modelLoader, 1, 512, false, false, true) | ||
go app.Listen("127.0.0.1:9090") | ||
|
||
defaultConfig := openai.DefaultConfig("") | ||
defaultConfig.BaseURL = "http://127.0.0.1:9090/v1" | ||
|
||
// Wait for API to be ready | ||
client = openai.NewClientWithConfig(defaultConfig) | ||
Eventually(func() error { | ||
_, err := client.ListModels(context.TODO()) | ||
return err | ||
}, "2m").ShouldNot(HaveOccurred()) | ||
}) | ||
AfterEach(func() { | ||
app.Shutdown() | ||
}) | ||
It("returns the models list", func() { | ||
models, err := client.ListModels(context.TODO()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(len(models.Models)).To(Equal(1)) | ||
Expect(models.Models[0].ID).To(Equal("testmodel")) | ||
}) | ||
It("can generate completions", func() { | ||
resp, err := client.CreateCompletion(context.TODO(), openai.CompletionRequest{Model: "testmodel", Prompt: "abcdedfghikl"}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(len(resp.Choices)).To(Equal(1)) | ||
Expect(resp.Choices[0].Text).ToNot(BeEmpty()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package api_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestLocalAI(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "LocalAI test suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters