fix(*): 画布生成与邮件 - 合并 PR #423 并修复恢复关联和规格报价
保留 PR 原始提交,合并待测试文档双方内容。补齐摘要 nodeId 消费端,修复缺省质量的 <nil> 匹配,并移除报价面板按价格档篡改自动质量的行为。 验证:前端完整测试脚本 1139 项通过,生产构建通过;后端相关专项通过。全量后端存在 4 项基线可复现失败;另一次资源清理测试出现 SQLite 表锁,合并分支与基线单独重跑通过。未执行真实 SMTP、浏览器端到端或收费生成。
This commit is contained in:
commit
8f4e2fca33
16 files changed
+441
-34
No files matched your search
@@ -85,7 +85,14 @@ func ModelRequestIntentFromTaskInput(input map[string]any, taskType string, oper
|
||||
}
|
||||
|
||||
func normalizeModelRequestOption(name string, value any) any {
|
||||
if canonicalCapabilityOptionName(name) != "vquality" {
|
||||
canonicalName := canonicalCapabilityOptionName(name)
|
||||
if canonicalName == "quality" || canonicalName == "size" {
|
||||
if text, ok := value.(string); ok {
|
||||
return strings.ToLower(strings.TrimSpace(text))
|
||||
}
|
||||
return value
|
||||
}
|
||||
if canonicalName != "vquality" {
|
||||
return value
|
||||
}
|
||||
resolution, ok := value.(string)
|
||||
@@ -730,8 +737,22 @@ func skuSelectorForIntent(intent ModelRequestIntent) map[string]string {
|
||||
selector["videoSeconds"] = strconv.Itoa(seconds)
|
||||
}
|
||||
case "image":
|
||||
if intent.Inputs["image"] > 0 {
|
||||
selector["operation"] = "image_to_image"
|
||||
} else {
|
||||
selector["operation"] = "text_to_image"
|
||||
}
|
||||
rawQuality, _ := intent.Options["quality"].(string)
|
||||
rawSize, _ := intent.Options["size"].(string)
|
||||
if quality := normalizeImagePriceQuality(rawQuality, rawSize); quality != "" {
|
||||
selector["quality"] = quality
|
||||
}
|
||||
for _, key := range []string{"quality", "size"} {
|
||||
if value := strings.ToLower(strings.TrimSpace(fmt.Sprint(intent.Options[key]))); value != "" && value != "auto" && value != "any" {
|
||||
if key == "quality" && selector["quality"] != "" {
|
||||
continue
|
||||
}
|
||||
text, _ := intent.Options[key].(string)
|
||||
if value := strings.ToLower(strings.TrimSpace(text)); value != "" && value != "auto" && value != "any" {
|
||||
selector[key] = value
|
||||
}
|
||||
}
|
||||
@@ -739,6 +760,33 @@ func skuSelectorForIntent(intent ModelRequestIntent) map[string]string {
|
||||
return selector
|
||||
}
|
||||
|
||||
func normalizeImagePriceQuality(rawQuality string, rawSize string) string {
|
||||
quality := strings.ToLower(strings.TrimSpace(rawQuality))
|
||||
if quality != "" && quality != "auto" && quality != "any" {
|
||||
return quality
|
||||
}
|
||||
parts := strings.Split(strings.ToLower(strings.TrimSpace(rawSize)), "x")
|
||||
if len(parts) != 2 {
|
||||
return ""
|
||||
}
|
||||
width, widthErr := strconv.ParseInt(strings.TrimSpace(parts[0]), 10, 64)
|
||||
height, heightErr := strconv.ParseInt(strings.TrimSpace(parts[1]), 10, 64)
|
||||
if widthErr != nil || heightErr != nil || width <= 0 || height <= 0 || width > (1<<32)/height {
|
||||
return ""
|
||||
}
|
||||
pixels := width * height
|
||||
switch {
|
||||
case pixels <= 2_000_000:
|
||||
return "1k"
|
||||
case pixels <= 4_300_000:
|
||||
return "2k"
|
||||
case pixels <= 8_294_400:
|
||||
return "4k"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func skuSelectorForTier(tier model.ChannelModelPriceTier) map[string]string {
|
||||
selector := model.DecodeSKUSelector(tier.SelectorJSON)
|
||||
if len(selector) == 0 {
|
||||
|
||||
Reference in new issue
Block a user