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)