fix: add seedance vendor rule and improve vendor_id auto-mapping for existing records

This commit is contained in:
xiezhouwei 2026-06-18 18:07:47 +08:00
parent 46819578de
commit 06aa707141
2 changed files with 23 additions and 8 deletions

View File

@ -32,6 +32,7 @@ var defaultVendorRules = map[string]string{
"grok": "xAI",
"llama": "Meta",
"doubao": "字节跳动",
"seedance": "字节跳动",
"kling": "快手",
"jimeng": "即梦",
"vidu": "Vidu",
@ -71,9 +72,13 @@ var defaultVendorIcons = map[string]string{
func initDefaultVendorMapping(metaMap map[string]*Model, vendorMap map[int]*Vendor, enableAbilities []AbilityWithChannel) {
for _, ability := range enableAbilities {
modelName := ability.Model
if _, exists := metaMap[modelName]; exists {
if existing, exists := metaMap[modelName]; exists {
// 已有记录但 vendor_id 已赋值 → 跳过
if existing.VendorID != 0 {
continue
}
// vendor_id=0 → 继续尝试匹配(修复已有 DB 记录但缺供应商的场景)
}
// 匹配供应商
vendorID := 0
@ -85,7 +90,15 @@ func initDefaultVendorMapping(metaMap map[string]*Model, vendorMap map[int]*Vend
}
}
// 创建模型元数据
if vendorID == 0 {
// 仍未匹配到供应商 → 跳过(不给未匹配的模型写入 vendor_id=0 覆盖已有记录)
continue
}
// 写入或更新供应商 ID
if existing, exists := metaMap[modelName]; exists {
existing.VendorID = vendorID
} else {
metaMap[modelName] = &Model{
ModelName: modelName,
VendorID: vendorID,
@ -94,6 +107,7 @@ func initDefaultVendorMapping(metaMap map[string]*Model, vendorMap map[int]*Vend
}
}
}
}
// 查找或创建供应商
func getOrCreateVendor(vendorName string, vendorMap map[int]*Vendor) int {

View File

@ -324,6 +324,7 @@ var vendorKeywordAliases = []struct {
{"moonshot", []string{"moonshot"}},
{"kimi", []string{"moonshot"}},
{"doubao", []string{"bytedance", "volcengine", "volcano"}},
{"seedance", []string{"bytedance", "volcengine", "volcano", "doubao"}},
{"ernie", []string{"baidu"}},
{"wenxin", []string{"baidu"}},
{"hunyuan", []string{"tencent"}},