{"repo": "chadban/ai-api", "files": {"app/internal/service/init_domestic_models.go": {"b408060e66b5a4d4d7b6b6eef5b738cd0bcc9cf1": {"t": 1785746101.9964366, "n": 4448, "h": "4eeed21f46d0f094", "c": "package service\n\nimport (\n\t\"encoding/json\"\n\n\t\"ai-api/app/internal/logger\"\n\t\"ai-api/app/internal/model\"\n\n\t\"github.com/shopspring/decimal\"\n\t\"gorm.io/gorm\"\n)\n\n// InitDomesticModels 初始化国内大模型数据\nfunc InitDomesticModels(db *gorm.DB, log *logger.Logger) {\n\tlog.Info(\"Initializing domestic LLM models...\")\n\n\t// 定义国内大模型渠道配置\n\tdomesticChannels := []struct {\n\t\tchannelType int\n\t\tname string\n\t\tbaseURL string\n\t\tmodels []string\n\t}{\n\t\t{\n\t\t\tchannelType: model.ChannelTypeDoubao,\n\t\t\tname: \"豆包官方\",\n\t\t\tbaseURL: \"https://ark.cn-beijing.volces.com/api/v3\",\n\t\t\tmodels: []string{\"doubao-lite-4k\", \"doubao-pro-4k\", \"doubao-lite-32k\", \"doubao-pro-32k\"},\n\t\t},\n\t\t{\n\t\t\tchannelType: model.ChannelTypeAli,\n\t\t\tname: \"阿里通义官方\",\n\t\t\tbaseURL: \"https://dashscope.aliyuncs.com/compatible-mode\",\n\t\t\tmodels: []string{\"qwen-turbo\", \"qwen-plus\", \"qwen-max\", \"qwen-max-longcontext\"},\n\t\t},\n\t\t{\n\t\t\tchannelType: model.ChannelTypeDeepSeek,\n\t\t\tname: \"DeepSeek 官方\",\n\t\t\tbaseURL: \"https://api.deepseek.com\",\n\t\t\tmodels: []string{\"deepseek-chat\", \"deepseek-coder\"},\n\t\t},\n\t\t{\n\t\t\tchannelType: model.ChannelTypeMiniMax,\n\t\t\tname: \"MiniMax 官方\",\n\t\t\tbaseURL: \"https://api.minimax.chat/v1\",\n\t\t\tmodels: []string{\"abab6.5-chat\", \"abab6.5g-chat\", \"abab6.5t-chat\"},\n\t\t},\n\t\t{\n\t\t\tchannelType: model.ChannelTypeZhipu,\n\t\t\tname: \"智谱 AI 官方\",\n\t\t\tbaseURL: \"https://open.bigmodel.cn/api/paas/v4\",\n\t\t\tmodels: []string{\"glm-4\", \"glm-4-flash\", \"glm-3-turbo\"},\n\t\t},\n\t}\n\n\t// 添加渠道(仅当不存在时)\n\tfor _, cfg := range domesticChannels {\n\t\tvar count int64\n\t\tdb.Model(&model.Channel{}).Where(\"type = ? AND name = ?\", cfg.channelType, cfg.name).Count(&count)\n\n\t\tif count == 0 {\n\t\t\tmodelsJSON, _ := json.Marshal(cfg.models)\n\t\t\tchannel := model.Channel{\n\t\t\t\tType: cfg.channelType,\n\t\t\t\tName: cfg.name,\n\t\t\t\tBaseURL: cfg.baseURL,\n\t\t\t\tAPIKey: \"NEED_SETUP\", // 需要管理员后续配置\n\t\t\t\tStatus: 0, // 默认禁用,等待配置 API Key\n\t\t\t\tModels: string(modelsJSON),\n\t\t\t\tPriority: 1,\n\t\t\t\tWeight: 100,\n\t\t\t}\n\n\t\t\tif err := db.Create(&channel).Error; err != nil {\n\t\t\t\tlog.Warn(\"Failed to create domestic channel\", logger.String(\"name\", cfg.name), logger.Err(err))\n\t\t\t} else {\n\t\t\t\tlog.Info(\"Created domestic channel\", logger.String(\"name\", cfg.name), logger.Int(\"type\", cfg.channelType))\n\t\t\t}\n\t\t}\n\t}\n\n\t// 定义模型数据\n\tdomesticModels := []struct {\n\t\tname string\n\t\tdisplayName string\n\t\tcontextWindow int\n\t\tmaxTokens int\n\t\tinputPrice float64\n\t\toutputPrice float64\n\t}{\n\t\t// 豆包\n\t\t{\"doubao-lite-4k\", \"豆包 Lite 4K\", 4096, 2048, 0.0003, 0.0006},\n\t\t{\"doubao-pro-4k\", \"豆包 Pro 4K\", 4096, 2048, 0.0008, 0.0020},\n\t\t{\"doubao-lite-32k\", \"豆包 Lite 32K\", 32768, 4096, 0.0006, 0.0012},\n\t\t{\"doubao-pro-32k\", \"豆包 Pro 32K\", 32768, 4096, 0.0015, 0.0030},\n\t\t// 阿里通义\n\t\t{\"qwen-turbo\", \"通义千问 Turbo\", 8192, 4096, 0.0003, 0.0006},\n\t\t{\"qwen-plus\", \"通义千问 Plus\", 32768, 8192, 0.0008, 0.0020},\n\t\t{\"qwen-max\", \"通义千问 Max\", 32768, 8192, 0.0015, 0.0030},\n\t\t{\"qwen-max-longcontext\", \"通义千问 Max 长文本\", 131072, 8192, 0.0020, 0.0040},\n\t\t// DeepSeek\n\t\t{\"deepseek-chat\", \"DeepSeek Chat\", 32768, 4096, 0.0002, 0.0004},\n\t\t{\"deepseek-coder\", \"DeepSeek Coder\", 16384, 2048, 0.0002, 0.0004},\n\t\t// MiniMax\n\t\t{\"abab6.5-chat\", \"MiniMax Abab6.5 Chat\", 8192, 4096, 0.0005, 0.0010},\n\t\t{\"abab6.5g-chat\", \"MiniMax Abab6.5G Chat\", 8192, 4096, 0.0005, 0.0010},\n\t\t{\"abab6.5t-chat\", \"MiniMax Abab6.5T Chat\", 8192, 4096, 0.0005, 0.0010},\n\t\t// 智谱 AI\n\t\t{\"glm-4\", \"智谱 GLM-4\", 128000, 4096, 0.0010, 0.0020},\n\t\t{\"glm-4-flash\", \"智谱 GLM-4 Flash\", 8192, 4096, 0.0001, 0.0002},\n\t\t{\"glm-3-turbo\", \"智谱 GLM-3 Turbo\", 128000, 4096, 0.0005, 0.0010},\n\t}\n\n\t// 添加模型到 models 表\n\tfor _, m := range domesticModels {\n\t\tvar count int64\n\t\tdb.Model(&model.Model{}).Where(\"name = ?\", m.name).Count(&count)\n\n\t\tif count == 0 {\n\t\t\tmodelItem := model.Model{\n\t\t\t\tProviderID: 1, // 默认提供商\n\t\t\t\tName: m.name,\n\t\t\t\tDisplayName: m.displayName,\n\t\t\t\tType: \"chat\",\n\t\t\t\tContextWindow: m.contextWindow,\n\t\t\t\tMaxTokens: m.maxTokens,\n\t\t\t\tInputPrice: decimal.NewFromFloat(m.inputPrice),\n\t\t\t\tOutputPrice: decimal.NewFromFloat(m.outputPrice),\n\t\t\t\tStatus: 1,\n\t\t\t}\n\n\t\t\tif err := db.Create(&modelItem).Error; err != nil {\n\t\t\t\tlog.Warn(\"Failed to create domestic model\", logger.String(\"name\", m.name), logger.Err(err))\n\t\t\t} else {\n\t\t\t\tlog.Info(\"Created domestic model\", logger.String(\"name\", m.name), logger.String(\"displayName\", m.displayName))\n\t\t\t}\n\t\t}\n\t}\n\n\tlog.Info(\"Domestic LLM models initialization completed\")\n}\n"}, "644d9e61e38f9e26163655416f9ed9003d4338b6": {"t": 1785759879.308801, "n": 4448, "h": "4eeed21f46d0f094", "c": "package service\n\nimport (\n\t\"encoding/json\"\n\n\t\"ai-api/app/internal/logger\"\n\t\"ai-api/app/internal/model\"\n\n\t\"github.com/shopspring/decimal\"\n\t\"gorm.io/gorm\"\n)\n\n// InitDomesticModels 初始化国内大模型数据\nfunc InitDomesticModels(db *gorm.DB, log *logger.Logger) {\n\tlog.Info(\"Initializing domestic LLM models...\")\n\n\t// 定义国内大模型渠道配置\n\tdomesticChannels := []struct {\n\t\tchannelType int\n\t\tname string\n\t\tbaseURL string\n\t\tmodels []string\n\t}{\n\t\t{\n\t\t\tchannelType: model.ChannelTypeDoubao,\n\t\t\tname: \"豆包官方\",\n\t\t\tbaseURL: \"https://ark.cn-beijing.volces.com/api/v3\",\n\t\t\tmodels: []string{\"doubao-lite-4k\", \"doubao-pro-4k\", \"doubao-lite-32k\", \"doubao-pro-32k\"},\n\t\t},\n\t\t{\n\t\t\tchannelType: model.ChannelTypeAli,\n\t\t\tname: \"阿里通义官方\",\n\t\t\tbaseURL: \"https://dashscope.aliyuncs.com/compatible-mode\",\n\t\t\tmodels: []string{\"qwen-turbo\", \"qwen-plus\", \"qwen-max\", \"qwen-max-longcontext\"},\n\t\t},\n\t\t{\n\t\t\tchannelType: model.ChannelTypeDeepSeek,\n\t\t\tname: \"DeepSeek 官方\",\n\t\t\tbaseURL: \"https://api.deepseek.com\",\n\t\t\tmodels: []string{\"deepseek-chat\", \"deepseek-coder\"},\n\t\t},\n\t\t{\n\t\t\tchannelType: model.ChannelTypeMiniMax,\n\t\t\tname: \"MiniMax 官方\",\n\t\t\tbaseURL: \"https://api.minimax.chat/v1\",\n\t\t\tmodels: []string{\"abab6.5-chat\", \"abab6.5g-chat\", \"abab6.5t-chat\"},\n\t\t},\n\t\t{\n\t\t\tchannelType: model.ChannelTypeZhipu,\n\t\t\tname: \"智谱 AI 官方\",\n\t\t\tbaseURL: \"https://open.bigmodel.cn/api/paas/v4\",\n\t\t\tmodels: []string{\"glm-4\", \"glm-4-flash\", \"glm-3-turbo\"},\n\t\t},\n\t}\n\n\t// 添加渠道(仅当不存在时)\n\tfor _, cfg := range domesticChannels {\n\t\tvar count int64\n\t\tdb.Model(&model.Channel{}).Where(\"type = ? AND name = ?\", cfg.channelType, cfg.name).Count(&count)\n\n\t\tif count == 0 {\n\t\t\tmodelsJSON, _ := json.Marshal(cfg.models)\n\t\t\tchannel := model.Channel{\n\t\t\t\tType: cfg.channelType,\n\t\t\t\tName: cfg.name,\n\t\t\t\tBaseURL: cfg.baseURL,\n\t\t\t\tAPIKey: \"NEED_SETUP\", // 需要管理员后续配置\n\t\t\t\tStatus: 0, // 默认禁用,等待配置 API Key\n\t\t\t\tModels: string(modelsJSON),\n\t\t\t\tPriority: 1,\n\t\t\t\tWeight: 100,\n\t\t\t}\n\n\t\t\tif err := db.Create(&channel).Error; err != nil {\n\t\t\t\tlog.Warn(\"Failed to create domestic channel\", logger.String(\"name\", cfg.name), logger.Err(err))\n\t\t\t} else {\n\t\t\t\tlog.Info(\"Created domestic channel\", logger.String(\"name\", cfg.name), logger.Int(\"type\", cfg.channelType))\n\t\t\t}\n\t\t}\n\t}\n\n\t// 定义模型数据\n\tdomesticModels := []struct {\n\t\tname string\n\t\tdisplayName string\n\t\tcontextWindow int\n\t\tmaxTokens int\n\t\tinputPrice float64\n\t\toutputPrice float64\n\t}{\n\t\t// 豆包\n\t\t{\"doubao-lite-4k\", \"豆包 Lite 4K\", 4096, 2048, 0.0003, 0.0006},\n\t\t{\"doubao-pro-4k\", \"豆包 Pro 4K\", 4096, 2048, 0.0008, 0.0020},\n\t\t{\"doubao-lite-32k\", \"豆包 Lite 32K\", 32768, 4096, 0.0006, 0.0012},\n\t\t{\"doubao-pro-32k\", \"豆包 Pro 32K\", 32768, 4096, 0.0015, 0.0030},\n\t\t// 阿里通义\n\t\t{\"qwen-turbo\", \"通义千问 Turbo\", 8192, 4096, 0.0003, 0.0006},\n\t\t{\"qwen-plus\", \"通义千问 Plus\", 32768, 8192, 0.0008, 0.0020},\n\t\t{\"qwen-max\", \"通义千问 Max\", 32768, 8192, 0.0015, 0.0030},\n\t\t{\"qwen-max-longcontext\", \"通义千问 Max 长文本\", 131072, 8192, 0.0020, 0.0040},\n\t\t// DeepSeek\n\t\t{\"deepseek-chat\", \"DeepSeek Chat\", 32768, 4096, 0.0002, 0.0004},\n\t\t{\"deepseek-coder\", \"DeepSeek Coder\", 16384, 2048, 0.0002, 0.0004},\n\t\t// MiniMax\n\t\t{\"abab6.5-chat\", \"MiniMax Abab6.5 Chat\", 8192, 4096, 0.0005, 0.0010},\n\t\t{\"abab6.5g-chat\", \"MiniMax Abab6.5G Chat\", 8192, 4096, 0.0005, 0.0010},\n\t\t{\"abab6.5t-chat\", \"MiniMax Abab6.5T Chat\", 8192, 4096, 0.0005, 0.0010},\n\t\t// 智谱 AI\n\t\t{\"glm-4\", \"智谱 GLM-4\", 128000, 4096, 0.0010, 0.0020},\n\t\t{\"glm-4-flash\", \"智谱 GLM-4 Flash\", 8192, 4096, 0.0001, 0.0002},\n\t\t{\"glm-3-turbo\", \"智谱 GLM-3 Turbo\", 128000, 4096, 0.0005, 0.0010},\n\t}\n\n\t// 添加模型到 models 表\n\tfor _, m := range domesticModels {\n\t\tvar count int64\n\t\tdb.Model(&model.Model{}).Where(\"name = ?\", m.name).Count(&count)\n\n\t\tif count == 0 {\n\t\t\tmodelItem := model.Model{\n\t\t\t\tProviderID: 1, // 默认提供商\n\t\t\t\tName: m.name,\n\t\t\t\tDisplayName: m.displayName,\n\t\t\t\tType: \"chat\",\n\t\t\t\tContextWindow: m.contextWindow,\n\t\t\t\tMaxTokens: m.maxTokens,\n\t\t\t\tInputPrice: decimal.NewFromFloat(m.inputPrice),\n\t\t\t\tOutputPrice: decimal.NewFromFloat(m.outputPrice),\n\t\t\t\tStatus: 1,\n\t\t\t}\n\n\t\t\tif err := db.Create(&modelItem).Error; err != nil {\n\t\t\t\tlog.Warn(\"Failed to create domestic model\", logger.String(\"name\", m.name), logger.Err(err))\n\t\t\t} else {\n\t\t\t\tlog.Info(\"Created domestic model\", logger.String(\"name\", m.name), logger.String(\"displayName\", m.displayName))\n\t\t\t}\n\t\t}\n\t}\n\n\tlog.Info(\"Domestic LLM models initialization completed\")\n}\n"}}, "web/src/views/admin/Channels.vue": {"b408060e66b5a4d4d7b6b6eef5b738cd0bcc9cf1": {"t": 1785747442.1268895, "n": 30736, "h": "5f9f41f1b2f0c988", "c": "\n \n \n \n \n 渠道管理\n \n \n \n 添加渠道\n \n \n \n 批量测试\n \n \n \n 刷新\n \n \n \n \n \n \n \n \n \n \n {{ row.api_key ? '******' + row.api_key.slice(-4) : '' }}\n \n \n \n \n \n {{ row.group || 'default' }}\n \n \n \n \n \n \n {{ channelType(row.type) }}\n \n \n \n \n \n \n \n \n \n {{ getStatusText(row.status) }}\n \n \n \n \n \n {{ row.last_test_time || '未测试' }}\n \n \n \n \n \n \n 测试\n \n \n \n 编辑\n \n \n \n 删除\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 显示提示\n \n \n \n \n \n \n \n API Key提示\n \n \n \n \n \n \n \n \n \n \n \n \n ?\n \n \n \n \n \n \n \n ?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\">\n \n {{ model }}\n \n \n \n \n \n 全选\n \n \n 清空\n \n \n 填入相关模型\n \n \n \n 同步最新模型\n \n \n \n \n \n \n \n \n \n \n \n \n 取消\n 创建\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\">\n \n {{ model }}\n \n \n \n \n \n 全选\n \n \n 清空\n \n \n 填入相关模型\n \n \n \n 同步最新模型\n \n \n \n \n \n \n \n \n \n \n \n \n 取消\n 保存\n \n \n \n\n\n\n\n\n"}, "644d9e61e38f9e26163655416f9ed9003d4338b6": {"t": 1785759879.6416724, "n": 30736, "h": "5f9f41f1b2f0c988", "c": "\n \n \n \n \n 渠道管理\n \n \n \n 添加渠道\n \n \n \n 批量测试\n \n \n \n 刷新\n \n \n \n \n \n \n \n \n \n \n {{ row.api_key ? '******' + row.api_key.slice(-4) : '' }}\n \n \n \n \n \n {{ row.group || 'default' }}\n \n \n \n \n \n \n {{ channelType(row.type) }}\n \n \n \n \n \n \n \n \n \n {{ getStatusText(row.status) }}\n \n \n \n \n \n {{ row.last_test_time || '未测试' }}\n \n \n \n \n \n \n 测试\n \n \n \n 编辑\n \n \n \n 删除\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 显示提示\n \n \n \n \n \n \n \n API Key提示\n \n \n \n \n \n \n \n \n \n \n \n \n ?\n \n \n \n \n \n \n \n ?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\">\n \n {{ model }}\n \n \n \n \n \n 全选\n \n \n 清空\n \n \n 填入相关模型\n \n \n \n 同步最新模型\n \n \n \n \n \n \n \n \n \n \n \n \n 取消\n 创建\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\">\n \n {{ model }}\n \n \n \n \n \n 全选\n \n \n 清空\n \n \n 填入相关模型\n \n \n \n 同步最新模型\n \n \n \n \n \n \n \n \n \n \n \n \n 取消\n 保存\n \n \n \n\n\n\n\n\n"}, "223a324ebaa7104531eeb80eb2d97930edff6b0a": {"t": 1785759881.1665463, "n": 30794, "h": "36f77c3e7744b453", "c": "\n \n \n \n \n 渠道管理\n \n \n \n 添加渠道\n \n \n \n 批量测试\n \n \n \n 刷新\n \n \n \n \n \n \n \n \n \n \n \n \n {{ channelType(row.type) }}\n \n \n \n \n \n \n \n \n \n {{ getStatusText(row.status) }}\n \n \n \n \n \n {{ row.last_test_time || '未测试' }}\n \n \n \n \n \n \n 测试\n \n \n \n 编辑\n \n \n \n 删除\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 显示提示\n \n \n \n \n \n \n \n API Key提示\n \n \n \n \n \n \n \n \n \n \n \n \n ?\n \n \n \n \n \n \n \n ?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{ model }}\n \n \n \n \n \n \n \n \n \n 全选\n \n \n 清空\n \n \n 填入相关模型\n \n \n \n 同步最新模型\n \n \n 更多\n \n \n \n \n \n \n 填入\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 取消\n 创建\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{ model }}\n \n \n \n \n \n \n \n \n \n 全选\n \n \n 清空\n \n \n 填入相关模型\n \n \n \n 同步最新模型\n \n \n 更多\n \n \n \n \n \n \n 填入\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 取消\n 保存\n \n \n \n\n\n\n\n\n"}}}}