fix(models): 模型规格价格 - 修复主线兼容与参考图 SKU 匹配

This commit is contained in:
ddCat committed 2026-08-22 17:28:22 +08:00
1 parent c5e2312968
commit f4b62b8e11
9 files changed
+112 -46

No files matched your search

+20 -1
View File
@@ -1,6 +1,10 @@
package service
import "testing"
import (
"testing"
"infinite-canvas/backend/internal/model"
)
func TestModelRequestIntentNormalizesVideoResolution(t *testing.T) {
input := map[string]any{
@@ -12,3 +16,18 @@ func TestModelRequestIntentNormalizesVideoResolution(t *testing.T) {
t.Fatalf("vquality = %#v, want 480p", got)
}
}
func TestSKUSelectorIncludesVideoReferenceImageCount(t *testing.T) {
selector := skuSelectorForIntent(ModelRequestIntent{Capability: "video", Inputs: map[string]int{"image": 5}, Options: map[string]any{"vquality": "720p"}})
if selector["imageCount"] != "5" || selector["vquality"] != "720p" {
t.Fatalf("selector = %#v", selector)
}
modelWithTiers := model.ChannelModel{PriceTiers: []model.ChannelModelPriceTier{
{SelectorJSON: `{"vquality":"720p","imageCount":"5"}`, Enabled: true, PriceConfigured: true},
{SelectorJSON: `{"vquality":"720p","imageCount":"9"}`, Enabled: true, PriceConfigured: true},
}}
matched := channelModelPriceTierForIntent(modelWithTiers, ModelRequestIntent{Capability: "video", Inputs: map[string]int{"image": 5}, Options: map[string]any{"vquality": "720p"}})
if matched == nil || matched.SelectorJSON != `{"vquality":"720p","imageCount":"5"}` {
t.Fatalf("matched tier = %#v", matched)
}
}