fengsilin
d8272e7707
feat(channel): 添加渠道"对外名称"(public_name)字段
为 Channel 模型新增 public_name 字段,让管理员可以为每个渠道
设置用户可见的友好名称(如"标准通道"、"高速通道"),替代前端
硬编码的"通道一/二/三"。Playground 通道选择器展示对外名称,
"渠道"统一改为"通道"。新建渠道时对外名称必填,编辑时可选。
Co-Authored-By: Claude <noreply@anthropic.com>
há 1 semana
fengsilin
3a29f3772f
feat(channel): 添加模型默认通道功能,支持优先路由和卡片标识
- 新增 is_default 字段和缓存层,支持管理员为模型指定默认通道
- Distribute 中间件优先级调整:Token 指定 → 默认通道 → 亲和性 → 随机
- 模型定价卡片和详情弹窗展示默认通道 amber 标识
- 管理后台定价页面新增星标切换默认通道
- 新增 set_default / clear_default API 和 6 个单元测试
- 简化卡片价格显示(移除内联缓存价格,改为详情弹窗展示)
Co-Authored-By: Claude <noreply@anthropic.com>
há 2 semanas
fengsilin
93e331b624
feat: 支持 LOGO_FILE_PATH 环境变量指定本地 Logo,优化定价与语言设置
- 新增 LOGO_FILE_PATH 环境变量,优先级高于数据库配置,支持本地文件服务
- 渠道定价高级字段(缓存/图片/音频)不再回退全局默认值,未设置直接返回 0
- 缓存价格单位从表头移到具体价格值,新增渠道 ID 复制功能
- 修复默认语言在用户已有偏好时仍被覆盖的问题
- img 标签统一添加 referrerPolicy/crossOrigin 防止跨域问题
- 新增缓存倍率和最小余额阈值的详细说明文本
Co-Authored-By: Claude <noreply@anthropic.com>
há 2 semanas
fengsilin
00058cd671
refactor(channel-pricing): 提取辅助方法消除重复代码,修复缓存一致性
- 提取 PriceData.ApplyChannelPricingRatios 消除 ModelPriceHelper 和
UpdatePriceDataForChannelPricing 中重复的 ~30 行比率回退逻辑
- 提取 ChannelPricing.ApplyFields 消除 controller 中 4 处相同的字段赋值
- 提取 setCache/removeCache 辅助函数统一写穿透缓存操作
- 将 claudeCacheCreation1hMultiplier 常量移至 types 包避免循环依赖
- 修复 BatchUpsertChannelPricing 成功后未刷新内存缓存的 bug
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 2 semanas
fengsilin
235f7c6e5f
refactor(channel-pricing): 提取 ParseTagIds 辅助函数 + 移除调试 console.log
- 将 tag ID 解析逻辑提取为 model.ParseTagIds,消除 model 层和 controller 层重复代码
- 统一 TrimSpace 处理(之前 controller 版本漏了)
- 移除 ChannelPricingView 残留的 console.log('Expanded keys:')
- 删除多余空行
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 3 semanas
fengsilin
c84c26b5a2
feat(channel-pricing): GetChannelPricingByModelWithChannelInfo 支持 CASE WHEN 回退 + 扩展字段
在 SQL 查询中使用 CASE WHEN > 0 回退策略,让渠道定价的扩展比率
(cache_ratio, cache_creation_ratio, image_ratio, audio_ratio,
audio_completion_ratio) 在未设置时自动回退到全局默认值,
而不是像 COALESCE 那样被零值拦截。同时更新 GROUP BY 子句包含所有
新选择的列,确保 MySQL 兼容。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 3 semanas
fengsilin
d5d4714908
test(channel-pricing): 缓存写穿 + 字段默认值单元测试
验证 ChannelPricing 的 Insert/Update/Delete 操作正确更新内存缓存,
以及未设置的扩展字段(CacheRatio 等)默认为零值。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 3 semanas
fengsilin
2d4c73d3aa
refactor(channel-pricing): 结构体新增扩展字段 + 缓存重写为全量加载写穿
- ChannelPricing 结构体新增 5 个扩展计费字段: cache_ratio, cache_creation_ratio, image_ratio, audio_ratio, audio_completion_ratio
- 缓存机制从 TTL+惰性加载重写为全量加载+写穿模式,消除 DB 查询延迟
- Insert/Update/Delete 改为写穿缓存(直接更新内存,不再整表失效)
- 新增 LoadChannelPricingCache 启动时全量加载函数
- 删除 RefreshChannelPricingCache/InvalidateChannelPricingCache(不再需要)
- BatchUpsertChannelPricing DoUpdates 列表同步新增 5 字段
- GetEffectivePricing 签名改为 (*ChannelPricing, bool)(调用方适配在后续 Task)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 3 semanas
fengsilin
a95331a85f
chore: 隐藏侧边栏聊天子菜单、账户管理及隐私价格设置
- 注释侧边栏"聊天"子菜单,保留"操练场"
- 隐藏个人设置中的账户管理模块
- 隐藏其他设置中的价格设置和隐私设置Tab
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 1 mês
fengsilin
62737d3f8c
feat: 添加模型详情页渠道价格展示 & 优化筛选行布局
- 新增 API 端点获取模型在各渠道的定价信息,支持全局价格回退
- 在模型详情侧边栏添加渠道价格卡片,显示所有支持该模型的渠道
- 优化 HorizontalFilterRow 组件,改用 flex-wrap 自动换行布局
- 隐藏数量为 0 的模型类型筛选项
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 1 mês
fengsilin
15a99da48e
fix: channel pricing not working correctly
This PR fixes three issues:
1. Token bound_channel_id not updating: Add bound field to Update() method
2. Channel pricing quota_type detection: Use QuotaTypeByCall constant instead of magic number 1
3. Log display for ratio-based pricing: Set ModelPrice=-1 for ratio-based pricing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 1 mês
fengsilin
ba21a870cd
feat: invalidate cache on channel pricing changes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 1 mês
fengsilin
6c9ee5ec2b
feat: add channel pricing cache and GetEffectivePricing function
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 1 mês
fengsilin
961a845b28
fix: implement proper upsert in BatchUpsertChannelPricing
The previous implementation only did INSERT without handling conflicts.
Now uses GORM's OnConflict clause to properly update existing records
when (model_name, channel_id) unique constraint is violated.
On conflict updates: quota_type, model_ratio, completion_ratio,
model_price, tag_ids, updated_time
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 1 mês
fengsilin
6dc260bb1e
feat: add ChannelPricing model for per-channel pricing
Add new model to support per-channel pricing for models,
allowing the same model to have different prices across
different channels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
há 1 mês