fix(universal): 映射脚本上游模型名
ci / verify (pull_request) Successful in 9m51s
ci / verify (pull_request) Successful in 9m51s
让 server-main 参数预处理兼容上下文使用平台绑定的真实模型名,避免把用户侧别名提交给上游。
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user