功能增加
This commit is contained in:
1 parent
b340fc7ad7
commit
f1993eb388
69 files changed
+2243
-162
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestA4ImageAdapterDimensions(t *testing.T) {
|
||||
for _, size := range []struct {
|
||||
width, height int
|
||||
evoSize, bailianSize string
|
||||
}{
|
||||
{1680, 2376, "848x1200", "1680*2376"},
|
||||
{2376, 1680, "1200x848", "2376*1680"},
|
||||
{848, 1200, "848x1200", "848*1200"},
|
||||
{1200, 848, "1200x848", "1200*848"},
|
||||
} {
|
||||
request := Request{Capability: "image.generate", Prompt: "A4 itinerary", Settings: map[string]any{"width": size.width, "height": size.height}}
|
||||
evo := NewEvoLink(Config{}, nil).payload(request).(map[string]any)
|
||||
if evo["size"] != size.evoSize || evo["resolution"] != "1K" {
|
||||
t.Fatalf("evolink=%#v", evo)
|
||||
}
|
||||
bailian := NewBailian(Config{}, nil).payload(request).(map[string]any)
|
||||
if object(bailian["parameters"])["size"] != size.bailianSize {
|
||||
t.Fatalf("bailian=%#v", bailian)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestA4JimengDimensionsAreSubmittedUnchanged(t *testing.T) {
|
||||
for _, size := range [][2]int{{1680, 2376}, {2376, 1680}} {
|
||||
client := roundTripFunc(func(request *http.Request) (*http.Response, error) {
|
||||
var body map[string]any
|
||||
if err := json.NewDecoder(request.Body).Decode(&body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["width"] != float64(size[0]) || body["height"] != float64(size[1]) {
|
||||
t.Fatalf("body=%#v", body)
|
||||
}
|
||||
return &http.Response{StatusCode: 200, Header: http.Header{}, Body: io.NopCloser(strings.NewReader(`{"code":10000,"data":{"task_id":"test-a4"}}`))}, nil
|
||||
})
|
||||
adapter := NewVolcengine(Config{BaseURL: "https://visual.test", Model: "jimeng_seedream46_cvtob", AccessKeyID: "test-key", SecretAccessKey: "test-secret"}, client, nil)
|
||||
if _, err := adapter.Submit(context.Background(), Request{Capability: "image.generate", Prompt: "A4 itinerary", Settings: map[string]any{"width": size[0], "height": size[1]}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user