增加2.5模型调用
This commit is contained in:
1 parent
3f29ba716a
commit
be655b6569
32 files changed
+1075
-56
No files matched your search
@@ -136,6 +136,15 @@ func (c *CreationCoordinator) RetryPlatform(ctx context.Context, session identit
|
||||
if engine := retryEngine(original.Provider, original.Capability); engine != "" {
|
||||
body["engine"] = engine
|
||||
}
|
||||
if original.Provider == "evolink" && original.Capability == "image.generate" {
|
||||
model := strings.TrimSpace(original.ReqKey)
|
||||
if model == "" {
|
||||
model = strings.TrimSpace(request.Model)
|
||||
}
|
||||
if model != "" {
|
||||
body["model"] = model
|
||||
}
|
||||
}
|
||||
created, _, err := c.CreatePlatform(ctx, session, CreationInput{Capability: original.Capability, Body: body, RetryOf: original.ID})
|
||||
if err != nil {
|
||||
return jobs.Job{}, err
|
||||
|
||||
@@ -285,6 +285,48 @@ func TestCreationCoordinatorRetryRebuildsAnyOwnedImageJobWithFreshQuote(t *testi
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreationCoordinatorRetryPreservesEvoLinkImageModelForQuoteAndJob(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name, reqKey, payloadModel, expected string
|
||||
bodyModel bool
|
||||
}{
|
||||
{name: "reqKey wins", reqKey: "gpt-image-2.5-flare", payloadModel: "gpt-image-2.5-sunburst", expected: "gpt-image-2.5-flare", bodyModel: true},
|
||||
{name: "payload fallback", payloadModel: "gpt-image-2.5-sunburst", expected: "gpt-image-2.5-sunburst", bodyModel: true},
|
||||
{name: "legacy default", expected: "gpt-image-2"},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
builder := jobs.ProviderJobBuilder{
|
||||
ImageProvider: "evolink", ImageModel: "gpt-image-2", ImageEngine: "evolink",
|
||||
ImageEngines: map[string]jobs.ProviderTarget{"evolink": {Provider: "evolink", Model: "gpt-image-2", Settings: map[string]any{"quality": "medium"}}},
|
||||
ImageModels: map[string]jobs.ProviderTarget{
|
||||
"gpt-image-2.5-flare": {Provider: "evolink", Model: "gpt-image-2.5-flare", Settings: map[string]any{"quality": "medium"}},
|
||||
"gpt-image-2.5-sunburst": {Provider: "evolink", Model: "gpt-image-2.5-sunburst", Settings: map[string]any{"quality": "medium"}},
|
||||
},
|
||||
NewID: func() string { return "retry-job" },
|
||||
}
|
||||
creator := &creationStoreStub{}
|
||||
quoter := "erStub{}
|
||||
coordinator := NewCreationCoordinator(builder, creator, quoter, &chargeLedgerStub{}, &creationStateStub{})
|
||||
payload, _ := json.Marshal(providers.Request{Capability: "image.generate", Model: test.payloadModel, Prompt: "draw again", Settings: map[string]any{"quality": "high"}})
|
||||
original := jobs.Job{ID: "original", OwnerID: "account", Capability: "image.generate", Provider: "evolink", ReqKey: test.reqKey, RequestPayload: payload}
|
||||
created, err := coordinator.RetryPlatform(context.Background(), identity.Session{User: identity.User{ID: "account", OrganizationID: "org"}}, original)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var prepared providers.Request
|
||||
if err := json.Unmarshal(created.RequestPayload, &prepared); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if created.ReqKey != test.expected || prepared.Model != test.expected || quoter.command.ReqKey != test.expected || quoter.command.Provider != "evolink" || created.RetryOf != "original" || prepared.Settings["quality"] != "high" {
|
||||
t.Fatalf("created=%#v prepared=%#v quote=%#v", created, prepared, quoter.command)
|
||||
}
|
||||
if got, ok := quoter.command.Payload["model"]; ok != test.bodyModel || (ok && got != test.expected) {
|
||||
t.Fatalf("quote payload model=%#v present=%v", got, ok)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSafeBillingErrorMapsPostgresWalletFailures(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in new issue
Block a user