feat(billing): 添加TTS模型input_chars字符数自动计算功能
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user