From dcbdc462bd31da1ee7933a3e44a016bb46fcda74 Mon Sep 17 00:00:00 2001 From: WangLiZhao <1838393649@qq.com> Date: Mon, 6 Jul 2026 17:00:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(billing):=20=E6=B7=BB=E5=8A=A0TTS=E6=A8=A1?= =?UTF-8?q?=E5=9E=8Binput=5Fchars=E5=AD=97=E7=AC=A6=E6=95=B0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=AE=A1=E7=AE=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/util/billing.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/util/billing.go b/common/util/billing.go index 59fac22..b9dabe6 100644 --- a/common/util/billing.go +++ b/common/util/billing.go @@ -158,7 +158,15 @@ func ExtractRequestBilling(ctx context.Context, config map[string]any, requestPa data := make(map[string]any) for key, path := range fields { - data[key] = extractValue(requestPayload, gconv.String(path)) + val := extractValue(requestPayload, gconv.String(path)) + // TTS 模型:input_chars 自动计算字符数 + if key == "input_chars" { + if s, ok := val.(string); ok { + data[key] = len([]rune(s)) + continue + } + } + data[key] = val } if defaults, ok := config["defaults"].(map[string]any); ok { @@ -169,7 +177,6 @@ func ExtractRequestBilling(ctx context.Context, config map[string]any, requestPa } } - // 处理 compute 字段 if compute, ok := config["compute"].(map[string]any); ok { for targetField, rule := range compute { r := rule.(map[string]any)