fengsilin
6ad0524172
test: add comprehensive pricing and channel selection tests
Add unit tests for group ratio, cross-group retry, and price calculation:
- Group ratio CRUD and special ratio override (12 tests)
- HandleGroupRatio with auto-group and special ratios (5 tests)
- ModelPriceHelper with group ratio in price/ratio modes (3 tests)
- Channel selection priority, groups, weighted LB (6 tests)
- RetryParam and AutoGroup service logic (7 tests)
Also restore the group pricing card in model detail SideSheet.
1週間前
fengsilin
052b41562a
fix(pricing): restore group info on model cards
Uncomment the group ratio display that was hidden in a95331a8 .
1週間前
fengsilin
0c2ea777f2
fix: remove channel-pricing API calls from frontend
Backend endpoints were removed but frontend still called them causing
404s. ChannelPricingCard no longer fetches, channelPricingApi and
pricingTagApi return empty stubs to keep dependent components stable.
1週間前
fengsilin
a88ab5914a
chore: remove web/dist from git tracking
Revert .gitignore exceptions that accidentally tracked web/dist build
artifacts. The directory should never be committed.
1週間前
fengsilin
7a2f584317
fix(claude): use gjson/sjson for reliable thinking.type replacement
Replace bytes.Replace with gjson.GetBytes+sjson.SetBytes in passthrough
mode to correctly handle JSON whitespace variations and avoid silently
sending empty body on read errors. Also add log search count limit to
prevent slow COUNT queries on large log tables.
1週間前
fengsilin
8150993caf
fix(admin): improve channel form inputs
Expose channel public_name in the edit modal and load a larger channel page when building model settings views.
Co-Authored-By: Codex <noreply@anthropic.com>
1週間前
fengsilin
3aa4cdf2ec
feat(models): add structured endpoint editor
Replace freeform endpoint JSON editing with a structured editor, keep advanced JSON mode, and make backend pricing parsing tolerate legacy array-form endpoint configs.
Co-Authored-By: Codex <noreply@anthropic.com>
1週間前
fengsilin
7ecedd8e57
fix: restore clean go test baseline
2週間前
fengsilin
3cf84775f2
feat: add channel metrics collector, fix search pagination and vendor sort order
- Register Prometheus ChannelCollector in GetMetrics() sync.Once block
- Add MetricsMiddleware to /v1 and /v1beta relay router groups when metrics enabled
- Remove public_name field from channel creation form and validation
- Restore InvitationCard in topup page
- Extract fetchSearchPage helper in useModelsData to eliminate ~50 lines of duplication; fix setSearching with finally block; use Axios params for URL encoding; fix missing vendor_counts update during paginated search
- Fix vendor ordering in HomePricingFilters to follow vendorsMap sort_order; fix O(n²) Array.includes to use Set
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2週間前
fengsilin
6434a523a1
feat: passthrough model mapping
2週間前
fengsilin
d32050d081
fix: restore login widget bundle and guard custom nav link
2週間前
fengsilin
54573991a4
feat: add customLink configuration UI in header nav settings
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3週間前
fengsilin
49c6755622
feat: add customLink to navigation hook with filtering logic
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3週間前
fengsilin
79f8a18cef
feat(widget): 重构登录组件为无 UI 的 headless SDK
3週間前
fengsilin
1c5e6d03d9
fix: 禁止修改同步用户余额
同步用户余额由主节点管理,从节点不应允许管理员修改其余额。
前端禁用额度输入和添加额度按钮,后端增加校验拦截。
3週間前
fengsilin
5afa4c48fc
feat: 用户表新增注册时间字段 + 用户列表显示邮箱和注册时间
- model/user.go: 新增 CreatedAt 字段,Insert 时自动填充
- UsersColumnDefs.jsx: 用户列表新增邮箱、注册时间列
- makefile: 新增 build-widget target
3週間前
fengsilin
763cf86a7a
fix(widget): 修复跨域 CORS 问题
- CORS 中间件改用 AllowOriginFunc 回显具体 origin,替代 AllowAllOrigins:*
- userRoute 添加 CORS 中间件,登录接口支持跨域请求
- Widget fetch 移除 credentials: 'include',无需 Cookie
3週間前
fengsilin
de3b359dea
feat(widget): 登录 Widget v1 — 密码登录,Shadow DOM 隔离
- 新增 web/widget/ 独立 Vite 构建,IIFE 格式打包
- Shadow DOM 样式隔离,支持 light/dark 主题
- 调用现有 /api/user/login 接口,零后端改动
- 构建产物 web/dist/static/login-widget.js (146KB)
3週間前
fengsilin
84eb6d6a88
feat: 端点格式限制功能 + 完善测试
当开启端点格式限制后,不同协议的渠道只能通过对应的端点访问:
- Anthropic 渠道只能用 /v1/messages
- Gemini 渠道只能用 /v1beta/models/*
- OpenAI 系渠道只能用 /v1/chat/completions 等
- VertexAI/阿里云等支持多协议的渠道不受限
核心实现:EndpointFormatGuard 中间件从请求路径推导协议家族,
不依赖 gin context 中的 relay_format(因 group middleware 执行
时 context 中尚无此值)。
修复了 /v1/models/*path 和 /v1/engines/ 路径被错误归类为
openai 家族的 bug(实际是 Gemini 格式)。
单元测试 58 个,E2E 测试 15 个,覆盖:
- 路径分类边界(含 Gemini relay 路径修复验证)
- 渠道类型覆盖(含非 LLM 渠道透传)
- 并发安全、运行时开关切换
- 错误消息 JSON 结构和内容验证
3週間前
fengsilin
ea0d4e5cde
refactor: 完整删除前端渠道选择和默认通道 UI
4週間前
fengsilin
155aa12014
perf(docker): BuildKit 缓存加速构建 + fix: 模型列表改用 enabled 接口
Dockerfile 添加 --mount=type=cache 持久化 bun/go 缓存,
前端改代码时跳过后端构建(~10s),后端改代码时跳过前端(~30s)。
模型限流下拉改用 /api/channel/models_enabled 只返回已启用模型。
4週間前
fengsilin
f07f2c25f4
feat(rate-limit): 用户模型限流配置改用下拉选择模型
将添加模型限流时的文本输入改为从渠道模型列表中选择,
并自动过滤已配置的模型,提升配置体验和准确性。
4週間前
fengsilin
714d8239d1
feat: Relay 请求抓包日志 + 用户模型 RPM 限流
两个独立功能:
1. Relay Capture:对开启 capture_relay 的用户记录完整请求/响应到本地文件
- 单 writer goroutine + 128 槽 channel 架构,无 OOM 风险
- 支持流式 SSE 和非流式请求
- 30s 超时保护
2. User-Model RPM Rate Limiting:按 用户+模型 维度的 RPM 限流
- Redis 令牌桶 + 内存滑动窗口双路径,Redis 故障自动降级
- 请求失败时退还令牌/配额(Redis Refund Lua 脚本 + 内存 Refund)
- Redis pipeline 错误处理:失败时清理缓存 key
- 前端用户编辑弹窗新增模型限流配置面板
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4週間前
fengsilin
69ed7d85d7
feat(sidebar): 添加监控外部链接菜单项
在管理员菜单区域新增「监控」入口,仅 root 用户可见,
点击后在新窗口打开外部监控面板。支持在侧边栏模块管理中切换显示/隐藏。
同时在 renderWrapper 中添加外部链接的通用支持。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
bae5c1faa5
feat(pricing): 隐藏模型广场标签和端点类型筛选器
注释掉模型广场侧边栏和筛选弹窗中的 PricingTags 和 PricingEndpointTypes 组件,
添加 EndpointType 常量及相关组件的文档注释。
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
e6b4a06557
feat(logs): 隐藏使用日志中的分组信息展示
使用注释方式隐藏分组列和分组倍率标签,便于后续恢复:
1. 注释 UsageLogsColumnDefs.jsx 中的分组列定义
2. 注释 useUsageLogsData.jsx 中的 COLUMN_KEYS.GROUP 和默认可见性配置
3. 将计费详情中的"分组倍率"改为"倍率"
后端计费逻辑不变,仍正常应用分组倍率。
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
1ヶ月前
fengsilin
f9eeb7e47e
fix(billing): 修复 Claude 计费明细未应用用户渠道折扣的问题
renderClaudeModelPrice 函数缺少 userChannelRatio 参数声明,导致运行时
ReferenceError;同时价格计算未乘以用户倍率,明细文本也未显示折扣信息。
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
1ヶ月前
fengsilin
f7ff684d0d
feat(pricing): 渠道定价展示用户折扣价格
登录用户查看渠道定价时,按用户分组倍率和渠道个人倍率计算实际折扣价
并在价格列展示划线原价与折扣价,新增 /pricing/user/*model 接口。
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
1ヶ月前
fengsilin
e1b6aff7e1
fix(log): 对普通用户隐藏 Chat ID 和 Upstream ID
后端 GetUserLogs 返回前清空 chat_id/upstream_id(omitempty 不输出),
前端搜索框和展开行详情加 isAdminUser 守卫。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
2d1a8d2f28
fix: 设置 chat_id + 优化日志查询参数构建
- Claude 和 OpenAI Responses 转发中设置 RelayChatID
- 日志查询使用 URLSearchParams 替代手动字符串拼接
- 日志查询日期范围改为可选,不再强制默认今天
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
3e86f523db
feat(playground): temperature/top_p 参数互斥设置
部分上游模型不允许同时设置 temperature 和 top_p,新增管理员可配置的
模型前缀列表,匹配的模型在 Playground 中自动互斥切换两个参数。
- 后端新增 PlaygroundSetting 配置 + GET /api/playground/config 公开端点
- 运营设置页面新增 Playground 互斥模型前缀编辑 textarea
- Playground 自动检测模型名匹配,启用一个参数自动禁用另一个
- 默认包含 deepseek-v4-flash/pro、deepseek-reasoner、o1-/o3-/o4-、gpt-5
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
d26ad9e635
feat: 渠道-模型级联选择 + 隐藏首页统计卡片
- UserRatioSection 模型输入改为级联下拉,选渠道后自动加载模型列表
- models 信息嵌入 channelOptions 消除冗余 channelMap 状态
- 注释掉首页 HeroSection 统计数据卡片
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
b026f6bc04
feat: 用户倍率前端展示 + 渠道下拉选择 + 上游调试日志
- UserRatioSection 渠道 ID 输入改为带搜索的下拉选择器
- 使用日志详情、计费过程、展开行均显示用户倍率
- renderLogContent suffix 统一追加,消除 4 处重复
- 提取 dumpUpstreamRequest 辅助函数,debug 日志走 SysLog
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
9dbf3365fe
feat(pricing): 添加用户-模型-渠道倍率功能
为每个用户添加独立于全局定价的倍率乘数,支持按 (userId, model, channel) 三维
精确控制用户级别定价。倍率以乘法叠加在现有 modelRatio × groupRatio 之上。
- 新增 user_channel_ratios 表,写入内存缓存(写穿透模式)
- 新增 /api/user_channel_ratio/ CRUD API(AdminAuth)
- 计费路径集成:compatible_handler、PostClaudeConsumeQuota、
PostWssConsumeQuota、PostAudioConsumeQuota、calculateAudioQuota
- 前端:EditUserModal 内嵌 UserRatioSection 组件
- 修复 Update() 缓存 key 零值 bug(先加载再更新)
- 修复 PreWssConsumeQuota 缺少 UserChannelRatio 导致归零
- 修复 ModelPriceHelperPerCall 缺少默认值 1.0
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
17a0c2c26a
refactor(playground): 隐藏对话页面的分组选择框
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
8945f8c39e
fix: synced 用户剩余额度取 synced_quota + 记录 chat ID
- 前端用户列表:synced 用户显式取 synced_quota 字段作为剩余额度
- 各 OpenAI handler 中记录 relayChatID 用于日志追踪
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
b2cb7bcf60
feat: record chat and upstream ids in usage logs
1ヶ月前
fengsilin
575f84064e
feat: codex API key 模式 + 前端凭证回显修复
- codex adaptor 支持 API key 和 OAuth 两种认证模式
- 提取 setupOAuthHeader 和 shouldUseChatCompletionsViaResponses
- 修复编辑页 codex_credential_mode 切换/回显不同步问题
- ResponsesStreamResponse 添加 Error 字段支持独立错误事件
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
332d5a62f2
feat: support codex api key credentials
1ヶ月前
fengsilin
1c0898257c
feat: add redemption remarks
1ヶ月前
fengsilin
d8272e7707
feat(channel): 添加渠道"对外名称"(public_name)字段
为 Channel 模型新增 public_name 字段,让管理员可以为每个渠道
设置用户可见的友好名称(如"标准通道"、"高速通道"),替代前端
硬编码的"通道一/二/三"。Playground 通道选择器展示对外名称,
"渠道"统一改为"通道"。新建渠道时对外名称必填,编辑时可选。
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
73d10b5799
feat: 错误日志记录上游 request-id 和响应体,Playground 渠道路由改为 header 传递
- 错误日志新增 upstream_request_id(从 Anthropic/OpenAI 响应 header 提取)和 upstream_body(截断 2KB)
- 修复 RelayErrorHandler 内部 WithOpenAIError/NewOpenAIError 分支丢失上游字段的 bug
- Playground 渠道和分组改为通过 X-Channel-Id/X-Group header 传递,而非 body 字段
- Distributor 中间件支持从 header 回退读取 channel_id 和 group
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
5b8303ae81
fix: 登录后跳转来源页,充值金额校验优化
- LoginForm: 登录成功后跳转回登录前的页面,而非固定 /console
- RechargeCard: 输入金额低于最低值时显示警告提示
- .dockerignore: 排除 .claude、.plans、脚本等非项目文件
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
8bb2883d7e
feat(home): 首页定价卡片添加"去体验"按钮,跳转 Playground
- PricingCardView 新增 showTryButton 属性,点击跳转 Playground 并预选模型
- 移除 PricingCardView 中未使用的 props (selectedGroup, currency 等)
- 首页页脚路由重命名: terms→user-agreement, usage-policy→privacy-policy
- i18n: "操练场"更名为"对话"
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
74cc8c0d56
feat(playground): 添加渠道选择功能,支持指定渠道体验模型
- 新增 /api/user/model_channels 接口,返回模型可用渠道及默认渠道
- Playground 设置面板添加渠道选择下拉框
- Distribute 中间件支持从请求体读取 channel_id 指定渠道
- 支持 URL 参数 ?model=xxx 直接选择模型
Co-Authored-By: Claude <noreply@anthropic.com>
1ヶ月前
fengsilin
967309fb56
feat: 添加邮箱后缀注册额度规则功能
管理员可在用户管理页面配置「邮箱后缀→初始额度」映射规则,
用户注册时根据邮箱后缀自动匹配并发放对应额度(替代默认额度)。
- 新增 email_quota_rule 数据表 + CRUD API(管理员权限)
- 内存缓存匹配,启动时加载,增删改时刷新
- 注册流程 Insert/InsertWithTx/FinalizeOAuthUserCreation 同步支持
- 前端用户管理页新增 Tab 展示规则管理卡片
- 含 24 个测试(model 16 + controller 8)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
d24d68a916
fix(i18n): 修复令牌和充值页面货币显示不一致问题
- 令牌创建:快捷选项标签根据系统货币设置动态生成,替换硬编码美元
- 充值页面:输入框显示值与预设卡片统一换算为本地货币,内部值仍为原始单位
- 使用 getQuotaPerUnit() 替代魔数 500000
- 消除 RechargeCard 中 getCurrencyConfig() 的 N+1 重复调用
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
1912dd3b72
feat: 添加图片验证码功能,防止脚本批量注册
- 后端:新增 GET /api/captcha 接口,使用 base64Captcha 生成图片验证码
- 后端:发送邮箱验证码时校验图片验证码(CaptchaEnabled 开关控制)
- 前端:注册表单邮箱验证码前增加图片验证码输入,支持点击刷新
- 管理后台:系统设置新增「图片验证码」开关
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
20163dbad5
fix(legal): 法律文档页面切换语言时强制重新加载内容
给 DocumentRenderer 添加 key={lang} 属性,确保切换语言时组件
重新挂载并从 API 获取对应语言的内容,而非使用缓存内容。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前
fengsilin
56e8d14485
fix: 语言切换后 TextArea 内容丢失
添加 useEffect 在 editingLang 变化时同步 form values,
确保重新挂载的 TextArea 能从 React state 中读取正确内容。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1ヶ月前