mirror of
https://github.com/mudler/LocalAI.git
synced 2025-06-27 21:24:59 +00:00
chore(tests): use quality to specify step
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
23054edb23
commit
2e3f90705f
3 changed files with 17 additions and 4 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -296,6 +297,14 @@ func updateRequestConfig(config *config.BackendConfig, input *schema.OpenAIReque
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a quality was defined as number, convert it to step
|
||||||
|
if input.Quality != "" {
|
||||||
|
q, err := strconv.Atoi(input.Quality)
|
||||||
|
if err == nil {
|
||||||
|
config.Step = q
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func mergeRequestWithConfig(modelFile string, input *schema.OpenAIRequest, cm *config.BackendConfigLoader, loader *model.ModelLoader, debug bool, threads, ctx int, f16 bool) (*config.BackendConfig, *schema.OpenAIRequest, error) {
|
func mergeRequestWithConfig(modelFile string, input *schema.OpenAIRequest, cm *config.BackendConfigLoader, loader *model.ModelLoader, debug bool, threads, ctx int, f16 bool) (*config.BackendConfig, *schema.OpenAIRequest, error) {
|
||||||
|
|
|
@ -191,8 +191,9 @@ type OpenAIRequest struct {
|
||||||
Stream bool `json:"stream"`
|
Stream bool `json:"stream"`
|
||||||
|
|
||||||
// Image (not supported by OpenAI)
|
// Image (not supported by OpenAI)
|
||||||
Mode int `json:"mode"`
|
Mode int `json:"mode"`
|
||||||
Step int `json:"step"`
|
Quality string `json:"quality"`
|
||||||
|
Step int `json:"step"`
|
||||||
|
|
||||||
// A grammar to constrain the LLM output
|
// A grammar to constrain the LLM output
|
||||||
Grammar string `json:"grammar" yaml:"grammar"`
|
Grammar string `json:"grammar" yaml:"grammar"`
|
||||||
|
|
|
@ -123,8 +123,9 @@ var _ = Describe("E2E test", func() {
|
||||||
It("correctly", func() {
|
It("correctly", func() {
|
||||||
resp, err := client.CreateImage(context.TODO(),
|
resp, err := client.CreateImage(context.TODO(),
|
||||||
openai.ImageRequest{
|
openai.ImageRequest{
|
||||||
Prompt: "test",
|
Prompt: "test",
|
||||||
Size: openai.CreateImageSize256x256,
|
Quality: "1",
|
||||||
|
Size: openai.CreateImageSize256x256,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
@ -136,6 +137,7 @@ var _ = Describe("E2E test", func() {
|
||||||
openai.ImageRequest{
|
openai.ImageRequest{
|
||||||
Prompt: "test",
|
Prompt: "test",
|
||||||
Size: openai.CreateImageSize256x256,
|
Size: openai.CreateImageSize256x256,
|
||||||
|
Quality: "1",
|
||||||
ResponseFormat: openai.CreateImageResponseFormatURL,
|
ResponseFormat: openai.CreateImageResponseFormatURL,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -148,6 +150,7 @@ var _ = Describe("E2E test", func() {
|
||||||
openai.ImageRequest{
|
openai.ImageRequest{
|
||||||
Prompt: "test",
|
Prompt: "test",
|
||||||
Size: openai.CreateImageSize256x256,
|
Size: openai.CreateImageSize256x256,
|
||||||
|
Quality: "1",
|
||||||
ResponseFormat: openai.CreateImageResponseFormatB64JSON,
|
ResponseFormat: openai.CreateImageResponseFormatB64JSON,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue