修复 Gemini 图像默认参数与 server-main 脚本兼容 #18

Merged
easyai merged 5 commits from codex/fix-gemini-image-options into main 2026-07-22 04:17:44 +08:00
2 changed files with 8 additions and 4 deletions
Showing only changes of commit 16149260c7 - Show all commits
+6 -2
View File
@@ -242,9 +242,13 @@ func universalScriptContext(request Request, modelType string, payload map[strin
return selectedBase + "/" + strings.TrimLeft(path, "/")
}
context["creatRequestURL"] = context["createRequestURL"]
context["processedParams"] = cloneBody(request.Body)
processedParams := cloneBody(request.Body)
processedParams["model"] = upstreamModelName(request.Candidate)
context["processedParams"] = processedParams
context["preProcessParams"] = func(params map[string]any, _ ...string) map[string]any {
return cloneMapAny(params)
processed := cloneMapAny(params)
processed["model"] = upstreamModelName(request.Candidate)
return processed
}
context["resolveGetTaskURL"] = func(taskID string) string {
return resolveUniversalTaskURL(request.Candidate.PlatformConfig, taskID)
+2 -2
View File
@@ -102,7 +102,7 @@ func TestUniversalClientSupportsServerMainScriptContextAndNestedResult(t *testin
"customGetParamsScript": map[string]any{
"image_generate": `async function getParams(params, context) {
const processed = await context.preProcessParams(params, context.type);
return { prompt: processed.prompt + "-" + context.processedParams.prompt };
return { prompt: processed.prompt + "-" + processed.model + "-" + context.processedParams.model };
}`,
},
"customSubmitScript": map[string]any{
@@ -128,7 +128,7 @@ func TestUniversalClientSupportsServerMainScriptContextAndNestedResult(t *testin
t.Fatalf("unexpected nested result: %#v", response.Result)
}
image, ok := data[0].(map[string]any)
if !ok || image["url"] != "https://cdn.example/hello-hello.png" {
if !ok || image["url"] != "https://cdn.example/hello-provider-model-provider-model.png" {
t.Fatalf("unexpected image result: %#v", response.Result)
}
}