fix(billing): 视频价格档 - 按参考素材分类匹配
This commit is contained in:
commit
d1d4b73d42
2 files changed
+55
No files matched your search
@@ -684,6 +684,14 @@ func skuSelectorForIntent(intent ModelRequestIntent) map[string]string {
|
|||||||
}
|
}
|
||||||
switch normalizeCapability(intent.Capability) {
|
switch normalizeCapability(intent.Capability) {
|
||||||
case "video":
|
case "video":
|
||||||
|
// 价格档按实际参考素材归类。供应商执行仍可使用 reference_to_video、extend
|
||||||
|
// 等细分操作;计价时视频参考优先归为视频生视频,其余图片参考无论数量
|
||||||
|
// 都归为图生视频。
|
||||||
|
if intent.Inputs["video"] > 0 {
|
||||||
|
selector["operation"] = "video_to_video"
|
||||||
|
} else if intent.Inputs["image"] > 0 {
|
||||||
|
selector["operation"] = "image_to_video"
|
||||||
|
}
|
||||||
if count := intent.Inputs["image"]; count > 0 {
|
if count := intent.Inputs["image"]; count > 0 {
|
||||||
selector["imageCount"] = strconv.Itoa(count)
|
selector["imageCount"] = strconv.Itoa(count)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,3 +31,50 @@ func TestSKUSelectorIncludesVideoReferenceImageCount(t *testing.T) {
|
|||||||
t.Fatalf("matched tier = %#v", matched)
|
t.Fatalf("matched tier = %#v", matched)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSKUSelectorTreatsAnyVideoReferenceAsVideoToVideo(t *testing.T) {
|
||||||
|
intent := ModelRequestIntentFromTaskInput(map[string]any{
|
||||||
|
"mode": "video",
|
||||||
|
"referenceImages": []any{map[string]any{"url": "https://example.com/reference.png"}},
|
||||||
|
"referenceVideos": []any{map[string]any{"url": "https://example.com/reference.mp4"}},
|
||||||
|
"referenceAudios": []any{map[string]any{"url": "https://example.com/reference.mp3"}},
|
||||||
|
"capabilityOptions": map[string]any{"vquality": "720p"},
|
||||||
|
}, "canvas_video", "reference_to_video")
|
||||||
|
selector := skuSelectorForIntent(intent)
|
||||||
|
if selector["operation"] != "video_to_video" {
|
||||||
|
t.Fatalf("operation = %q, want video_to_video; selector = %#v", selector["operation"], selector)
|
||||||
|
}
|
||||||
|
|
||||||
|
modelWithTiers := model.ChannelModel{PriceTiers: []model.ChannelModelPriceTier{
|
||||||
|
{SelectorJSON: `{}`, Enabled: true, PriceConfigured: true},
|
||||||
|
{SelectorJSON: `{"operation":"video_to_video"}`, Enabled: true, PriceConfigured: true},
|
||||||
|
}}
|
||||||
|
matched := channelModelPriceTierForIntent(modelWithTiers, intent)
|
||||||
|
if matched == nil || matched.SelectorJSON != `{"operation":"video_to_video"}` {
|
||||||
|
t.Fatalf("matched tier = %#v", matched)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSKUSelectorTreatsAnyImageReferenceCountAsImageToVideo(t *testing.T) {
|
||||||
|
intent := ModelRequestIntentFromTaskInput(map[string]any{
|
||||||
|
"mode": "video",
|
||||||
|
"referenceImages": []any{
|
||||||
|
map[string]any{"url": "https://example.com/reference-1.png"},
|
||||||
|
map[string]any{"url": "https://example.com/reference-2.png"},
|
||||||
|
map[string]any{"url": "https://example.com/reference-3.png"},
|
||||||
|
},
|
||||||
|
}, "canvas_video", "reference_to_video")
|
||||||
|
selector := skuSelectorForIntent(intent)
|
||||||
|
if selector["operation"] != "image_to_video" || selector["imageCount"] != "3" {
|
||||||
|
t.Fatalf("selector = %#v, want image_to_video with imageCount 3", selector)
|
||||||
|
}
|
||||||
|
|
||||||
|
modelWithTiers := model.ChannelModel{PriceTiers: []model.ChannelModelPriceTier{
|
||||||
|
{SelectorJSON: `{}`, Enabled: true, PriceConfigured: true},
|
||||||
|
{SelectorJSON: `{"operation":"image_to_video"}`, Enabled: true, PriceConfigured: true},
|
||||||
|
}}
|
||||||
|
matched := channelModelPriceTierForIntent(modelWithTiers, intent)
|
||||||
|
if matched == nil || matched.SelectorJSON != `{"operation":"image_to_video"}` {
|
||||||
|
t.Fatalf("matched tier = %#v", matched)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user