2025-08-11 15:33:55 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 简化的供应商映射规则
|
|
|
|
|
var defaultVendorRules = map[string]string{
|
|
|
|
|
"gpt": "OpenAI",
|
|
|
|
|
"dall-e": "OpenAI",
|
|
|
|
|
"whisper": "OpenAI",
|
|
|
|
|
"o1": "OpenAI",
|
|
|
|
|
"o3": "OpenAI",
|
|
|
|
|
"claude": "Anthropic",
|
|
|
|
|
"gemini": "Google",
|
|
|
|
|
"moonshot": "Moonshot",
|
|
|
|
|
"kimi": "Moonshot",
|
|
|
|
|
"chatglm": "智谱",
|
|
|
|
|
"glm-": "智谱",
|
|
|
|
|
"qwen": "阿里巴巴",
|
|
|
|
|
"deepseek": "DeepSeek",
|
|
|
|
|
"abab": "MiniMax",
|
|
|
|
|
"ernie": "百度",
|
|
|
|
|
"spark": "讯飞",
|
|
|
|
|
"hunyuan": "腾讯",
|
|
|
|
|
"command": "Cohere",
|
|
|
|
|
"@cf/": "Cloudflare",
|
|
|
|
|
"360": "360",
|
|
|
|
|
"yi": "零一万物",
|
|
|
|
|
"jina": "Jina",
|
|
|
|
|
"mistral": "Mistral",
|
|
|
|
|
"grok": "xAI",
|
|
|
|
|
"llama": "Meta",
|
|
|
|
|
"doubao": "字节跳动",
|
|
|
|
|
"kling": "快手",
|
|
|
|
|
"jimeng": "即梦",
|
|
|
|
|
"vidu": "Vidu",
|
|
|
|
|
}
|
|
|
|
|
|
✨ feat(pricing): add default vendor icons with LobeHub color support
- Add defaultVendorIcons mapping for major AI vendors
- Update getOrCreateVendor to automatically set vendor icons
- Add getDefaultVendorIcon helper function
- Support LobeHub icons Color variants (e.g., Claude.Color, Gemini.Color)
- Fix issue where default vendors were created without icons
This ensures that when new models are encountered, their vendors
will be created with appropriate colored icons for better UI display.
Affected vendors include:
- OpenAI, Anthropic, Google, Moonshot, 智谱, 阿里巴巴
- DeepSeek, MiniMax, 百度, 讯飞, 腾讯, Cohere
- Cloudflare, 360, 零一万物, Jina, Mistral, xAI
- Meta, 字节跳动, 快手, 即梦, Vidu, Microsoft/Azure
2025-08-29 23:42:33 +08:00
|
|
|
// 供应商默认图标映射
|
|
|
|
|
var defaultVendorIcons = map[string]string{
|
|
|
|
|
"OpenAI": "OpenAI",
|
|
|
|
|
"Anthropic": "Claude.Color",
|
|
|
|
|
"Google": "Gemini.Color",
|
|
|
|
|
"Moonshot": "Moonshot",
|
|
|
|
|
"智谱": "Zhipu.Color",
|
|
|
|
|
"阿里巴巴": "Qwen.Color",
|
|
|
|
|
"DeepSeek": "DeepSeek.Color",
|
|
|
|
|
"MiniMax": "Minimax.Color",
|
|
|
|
|
"百度": "Wenxin.Color",
|
|
|
|
|
"讯飞": "Spark.Color",
|
|
|
|
|
"腾讯": "Hunyuan.Color",
|
|
|
|
|
"Cohere": "Cohere.Color",
|
|
|
|
|
"Cloudflare": "Cloudflare.Color",
|
|
|
|
|
"360": "Ai360.Color",
|
|
|
|
|
"零一万物": "Yi.Color",
|
|
|
|
|
"Jina": "Jina",
|
|
|
|
|
"Mistral": "Mistral.Color",
|
|
|
|
|
"xAI": "XAI",
|
|
|
|
|
"Meta": "Ollama",
|
|
|
|
|
"字节跳动": "Doubao.Color",
|
|
|
|
|
"快手": "Kling.Color",
|
|
|
|
|
"即梦": "Jimeng.Color",
|
|
|
|
|
"Vidu": "Vidu",
|
|
|
|
|
"微软": "AzureAI",
|
|
|
|
|
"Microsoft": "AzureAI",
|
|
|
|
|
"Azure": "AzureAI",
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-11 15:33:55 +08:00
|
|
|
// initDefaultVendorMapping 简化的默认供应商映射
|
|
|
|
|
func initDefaultVendorMapping(metaMap map[string]*Model, vendorMap map[int]*Vendor, enableAbilities []AbilityWithChannel) {
|
|
|
|
|
for _, ability := range enableAbilities {
|
|
|
|
|
modelName := ability.Model
|
|
|
|
|
if _, exists := metaMap[modelName]; exists {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 匹配供应商
|
|
|
|
|
vendorID := 0
|
|
|
|
|
modelLower := strings.ToLower(modelName)
|
|
|
|
|
for pattern, vendorName := range defaultVendorRules {
|
|
|
|
|
if strings.Contains(modelLower, pattern) {
|
|
|
|
|
vendorID = getOrCreateVendor(vendorName, vendorMap)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建模型元数据
|
|
|
|
|
metaMap[modelName] = &Model{
|
|
|
|
|
ModelName: modelName,
|
|
|
|
|
VendorID: vendorID,
|
|
|
|
|
Status: 1,
|
|
|
|
|
NameRule: NameRuleExact,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查找或创建供应商
|
|
|
|
|
func getOrCreateVendor(vendorName string, vendorMap map[int]*Vendor) int {
|
|
|
|
|
// 查找现有供应商
|
|
|
|
|
for id, vendor := range vendorMap {
|
|
|
|
|
if vendor.Name == vendorName {
|
|
|
|
|
return id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建新供应商
|
|
|
|
|
newVendor := &Vendor{
|
|
|
|
|
Name: vendorName,
|
|
|
|
|
Status: 1,
|
✨ feat(pricing): add default vendor icons with LobeHub color support
- Add defaultVendorIcons mapping for major AI vendors
- Update getOrCreateVendor to automatically set vendor icons
- Add getDefaultVendorIcon helper function
- Support LobeHub icons Color variants (e.g., Claude.Color, Gemini.Color)
- Fix issue where default vendors were created without icons
This ensures that when new models are encountered, their vendors
will be created with appropriate colored icons for better UI display.
Affected vendors include:
- OpenAI, Anthropic, Google, Moonshot, 智谱, 阿里巴巴
- DeepSeek, MiniMax, 百度, 讯飞, 腾讯, Cohere
- Cloudflare, 360, 零一万物, Jina, Mistral, xAI
- Meta, 字节跳动, 快手, 即梦, Vidu, Microsoft/Azure
2025-08-29 23:42:33 +08:00
|
|
|
Icon: getDefaultVendorIcon(vendorName),
|
2025-08-11 15:33:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := newVendor.Insert(); err != nil {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vendorMap[newVendor.Id] = newVendor
|
|
|
|
|
return newVendor.Id
|
|
|
|
|
}
|
✨ feat(pricing): add default vendor icons with LobeHub color support
- Add defaultVendorIcons mapping for major AI vendors
- Update getOrCreateVendor to automatically set vendor icons
- Add getDefaultVendorIcon helper function
- Support LobeHub icons Color variants (e.g., Claude.Color, Gemini.Color)
- Fix issue where default vendors were created without icons
This ensures that when new models are encountered, their vendors
will be created with appropriate colored icons for better UI display.
Affected vendors include:
- OpenAI, Anthropic, Google, Moonshot, 智谱, 阿里巴巴
- DeepSeek, MiniMax, 百度, 讯飞, 腾讯, Cohere
- Cloudflare, 360, 零一万物, Jina, Mistral, xAI
- Meta, 字节跳动, 快手, 即梦, Vidu, Microsoft/Azure
2025-08-29 23:42:33 +08:00
|
|
|
|
|
|
|
|
// 获取供应商默认图标
|
|
|
|
|
func getDefaultVendorIcon(vendorName string) string {
|
|
|
|
|
if icon, exists := defaultVendorIcons[vendorName]; exists {
|
|
|
|
|
return icon
|
|
|
|
|
}
|
|
|
|
|
return ""
|
|
|
|
|
}
|