tests: enable whisper (#239)

This commit is contained in:
Ettore Di Giacinto 2023-05-12 14:10:18 +02:00 committed by GitHub
parent 8250391e49
commit b4241d0a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
. "github.com/go-skynet/LocalAI/api" . "github.com/go-skynet/LocalAI/api"
"github.com/go-skynet/LocalAI/pkg/model" "github.com/go-skynet/LocalAI/pkg/model"
@ -46,7 +47,7 @@ var _ = Describe("API test", func() {
It("returns the models list", func() { It("returns the models list", func() {
models, err := client.ListModels(context.TODO()) models, err := client.ListModels(context.TODO())
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(models.Models)).To(Equal(4)) Expect(len(models.Models)).To(Equal(5))
Expect(models.Models[0].ID).To(Equal("testmodel")) Expect(models.Models[0].ID).To(Equal("testmodel"))
}) })
It("can generate completions", func() { It("can generate completions", func() {
@ -82,7 +83,10 @@ var _ = Describe("API test", func() {
Expect(err).To(HaveOccurred()) Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("error, status code: 500, message: could not load model - all backends returned error: 12 errors occurred:")) Expect(err.Error()).To(ContainSubstring("error, status code: 500, message: could not load model - all backends returned error: 12 errors occurred:"))
}) })
PIt("transcribes audio", func() { It("transcribes audio", func() {
if runtime.GOOS != "linux" {
Skip("test supported only on linux")
}
resp, err := client.CreateTranscription( resp, err := client.CreateTranscription(
context.Background(), context.Background(),
openai.AudioRequest{ openai.AudioRequest{
@ -119,7 +123,7 @@ var _ = Describe("API test", func() {
models, err := client.ListModels(context.TODO()) models, err := client.ListModels(context.TODO())
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(len(models.Models)).To(Equal(6)) Expect(len(models.Models)).To(Equal(7))
Expect(models.Models[0].ID).To(Equal("testmodel")) Expect(models.Models[0].ID).To(Equal("testmodel"))
}) })
It("can generate chat completions from config file", func() { It("can generate chat completions from config file", func() {

4
tests/fixtures/whisper.yaml vendored Normal file
View File

@ -0,0 +1,4 @@
name: whisper-1
backend: whisper
parameters:
model: whisper-en