From 53aeee4ff7eca858454a0e394351c7309f2d7fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B3=93=E5=AE=BE?= <514660094@qq.com> Date: Tue, 31 Mar 2026 17:12:06 +0800 Subject: [PATCH] Comment out price data adjustment logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comment out code that modifies price data based on image count. 测试发现,如果是接入阿里百炼平台的qwen-image-2.0系列模型,这边计费的时候会出现 0.2*n*倍率*n的情况,最前面的0.2*n会直接显示为模型价格。 例如: 日志详情 模型价格 $0.600000,专属倍率 0.3 其他详情 大小 1080*1920, 品质 standard, 生成数量 3, 其他倍率 n: 3.000000 计费过程 模型价格:$0.600000 * 专属倍率:0.3 = $0.180000 --- relay/channel/ali/image.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/relay/channel/ali/image.go b/relay/channel/ali/image.go index 18427d77..68be2de9 100644 --- a/relay/channel/ali/image.go +++ b/relay/channel/ali/image.go @@ -55,9 +55,9 @@ func oaiImage2AliImageRequest(info *relaycommon.RelayInfo, request dto.ImageRequ } // 检查n参数 - if imageRequest.Parameters.N != 0 { - info.PriceData.AddOtherRatio("n", float64(imageRequest.Parameters.N)) - } + // if imageRequest.Parameters.N != 0 { + // info.PriceData.AddOtherRatio("n", float64(imageRequest.Parameters.N)) + // } // 同步图片模型和异步图片模型请求格式不一样 if isSync { @@ -329,11 +329,12 @@ func aliImageHandler(a *Adaptor, c *gin.Context, resp *http.Response, info *rela imageResponses := responseAli2OpenAIImage(c, aliResponse, originRespBody, info, responseFormat) // 可能生成多张图片,修正计费数量n - if aliResponse.Usage.ImageCount != 0 { - info.PriceData.AddOtherRatio("n", float64(aliResponse.Usage.ImageCount)) - } else if len(imageResponses.Data) != 0 { - info.PriceData.AddOtherRatio("n", float64(len(imageResponses.Data))) - } + // 注释掉,否则会导致多次扣费用 + // if aliResponse.Usage.ImageCount != 0 { + // info.PriceData.AddOtherRatio("n", float64(aliResponse.Usage.ImageCount)) + // } else if len(imageResponses.Data) != 0 { + // info.PriceData.AddOtherRatio("n", float64(len(imageResponses.Data))) + // } jsonResponse, err := common.Marshal(imageResponses) if err != nil { return types.NewError(err, types.ErrorCodeBadResponseBody), nil