mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 02:24:59 +00:00
feat(image): support response_type
in the OpenAI API request (#2347)
* Change response_format type to string to match OpenAI Spec Signed-off-by: prajwal <prajwalnayak7@gmail.com> * updated response_type type to interface Signed-off-by: prajwal <prajwalnayak7@gmail.com> * feat: correctly parse generic struct Signed-off-by: mudler <mudler@localai.io> * add tests Signed-off-by: mudler <mudler@localai.io> --------- Signed-off-by: prajwal <prajwalnayak7@gmail.com> Signed-off-by: mudler <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com> Co-authored-by: mudler <mudler@localai.io>
This commit is contained in:
parent
087bceccac
commit
4d98dd9ce7
7 changed files with 57 additions and 13 deletions
|
@ -123,13 +123,36 @@ var _ = Describe("E2E test", func() {
|
|||
openai.ImageRequest{
|
||||
Prompt: "test",
|
||||
Size: openai.CreateImageSize512x512,
|
||||
//ResponseFormat: openai.CreateImageResponseFormatURL,
|
||||
},
|
||||
)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(len(resp.Data)).To(Equal(1), fmt.Sprint(resp))
|
||||
Expect(resp.Data[0].URL).To(ContainSubstring("png"), fmt.Sprint(resp.Data[0].URL))
|
||||
})
|
||||
It("correctly changes the response format to url", func() {
|
||||
resp, err := client.CreateImage(context.TODO(),
|
||||
openai.ImageRequest{
|
||||
Prompt: "test",
|
||||
Size: openai.CreateImageSize512x512,
|
||||
ResponseFormat: openai.CreateImageResponseFormatURL,
|
||||
},
|
||||
)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(len(resp.Data)).To(Equal(1), fmt.Sprint(resp))
|
||||
Expect(resp.Data[0].URL).To(ContainSubstring("png"), fmt.Sprint(resp.Data[0].URL))
|
||||
})
|
||||
It("correctly changes the response format to base64", func() {
|
||||
resp, err := client.CreateImage(context.TODO(),
|
||||
openai.ImageRequest{
|
||||
Prompt: "test",
|
||||
Size: openai.CreateImageSize512x512,
|
||||
ResponseFormat: openai.CreateImageResponseFormatB64JSON,
|
||||
},
|
||||
)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(len(resp.Data)).To(Equal(1), fmt.Sprint(resp))
|
||||
Expect(resp.Data[0].B64JSON).ToNot(BeEmpty(), fmt.Sprint(resp.Data[0].B64JSON))
|
||||
})
|
||||
})
|
||||
Context("embeddings", func() {
|
||||
It("correctly", func() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue