22 Commits
Author SHA1 Message Date
XianYuDaXian 5ea26356c0 fix: 调整日志输出并放开视频路由限制 2026-03-10 06:55:24 +08:00
Chenyme b6b753b97b feat: support new model Grok 4.20 Beta
# Conflicts:
#	app/services/grok/services/chat.py
2026-02-18 23:29:48 +08:00
XianYuDaXian bac0ed508c feat: 完善本地功能 (视频UI修复, 工作台重构, PWA支持, 提示词增强) 2026-02-18 23:18:58 +08:00
Chenyme 928faabbac refactor: update configuration settings, enhance public API integration, and streamline service imports while removing deprecated files 2026-02-15 17:43:57 +08:00
Chenyme 7f0db522ae refactor: enhance configuration management by adding public API key support, reorganizing chat and image settings, and removing deprecated components 2026-02-15 00:39:30 +08:00
Chenyme d04bc4ee4c refactor: streamline chat and video processing services, enhance validation, and remove unused components 2026-02-13 20:22:52 +08:00
Chenyme 314102dcba feat: add NSFW configuration and refactor related services for improved management 2026-02-13 13:00:12 +08:00
Chenyme 432acf41cf refactor: replace DownloadService with CacheService in admin API and update related methods 2026-02-13 00:31:05 +08:00
Chenyme a864751543 Merge remote-tracking branch 'origin/main' into reactor_reverse 2026-02-11 11:01:04 +08:00
piexian f53e412b4e feat: 添加跨 Token 重试机制,429 配额不足时自动换 Token
- 在 ChatService.completions() 中实现跨 Token 重试循环,最多尝试 3 个
  不同 Token,遇到 429 时标记当前 Token 为 COOLING 并切换下一个
- TokenPool.select() 和 TokenManager.get_token() 增加 exclude 参数,
  支持排除已失败的 Token
- 新增 TokenManager.mark_rate_limited() 方法,将 429 的 Token 配额
  归零并标记 COOLING,等待 Scheduler 刷新恢复
- 内层 retry_on_status 不再重试 429,避免对同一耗尽 Token 做无意义重试
- 循环耗尽后兜底抛出异常,避免隐式返回 None
2026-02-10 20:49:51 +08:00
piexian d11b059943 fix: 修复 Token 自动刷新失败导致持续 504/429 错误
- 修复 Scheduler 刷新使用错误的默认模型名 (grok-4-1-thinking-1129 → grok-3),
  避免 basic token 查询配额时返回 403
- 调整 Scheduler 启动后立即执行首轮刷新,而非等待整个 interval (2-8h)
- 移除刷新失败分支中的 mark_synced() 调用,使失败 token 在下一轮
  循环中被重新尝试而非被跳过
- Token 池耗尽时自动触发 refresh_cooling_tokens(),尝试恢复
  冷却中的 token,而非直接返回 429
2026-02-10 18:36:19 +08:00
Chenyme d947ef69ba refactor: simplify usage service by removing model_name parameter and integrating reverse request handler for rate limits 2026-02-09 22:03:27 +08:00
Chenyme d93824f781 refactor: remove deprecated smart token routing configuration and related test 2026-02-08 16:06:09 +08:00
double2tea 01dcea9b7c feat: implement smart token routing for video generation
- Add get_token_for_video() method to select token pool based on video requirements
- 720p or >6s videos automatically use ssoSuper token
- 480p and ≤6s videos use ssoBasic token
- Fallback to ssoBasic when ssoSuper is unavailable
- Add configuration options for smart routing
- Add test file for token routing logic

This solves the issue where non-SSO Super tokens were silently downgraded
to 480p by Grok API when requesting 720p videos.
2026-02-08 03:16:37 +08:00
Chenyme b132590045 feat: enhance configuration options across services for improved flexibility 2026-02-07 11:32:25 +08:00
Chenyme ef5a8dc8e5 refactor: reorganize imports and create new services for models, assets, and media processing 2026-02-06 10:12:48 +08:00
Chenyme a2c2b1ba7f feat: add super refresh interval configuration and update token management logic 2026-02-04 23:34:58 +08:00
piexian d25d2eae18 style: 修复 ruff 代码规范问题
- 修复裸 except 为 except Exception
- 修复单行多语句 (E701)
- 移除未使用的导入 (F401)
- 添加 noqa 注释忽略 main.py 的 E402 (设计决策)
- 代码格式化
2026-02-04 06:40:29 +08:00
piexian 2a50326517 fix: 修复 Token 失效标记及日志相关问题
Token 失效标记修复:
- record_fail() 同时接受 401 和 403 状态码
- consume() 不再清零 fail_count,只有 record_success() 才清零
- _wrap_stream() 只在成功完成时调用 consume(),失败时不扣费

其他修复:
- 优化日志输出和错误处理
- 改进重试机制
- 完善配置默认值
2026-02-04 04:57:16 +08:00
piexian dd323a67f2 feat(admin): 优化 NSFW 功能和 Token 管理界面
NSFW 功能优化:
- 修复成功判断逻辑:HTTP 200 且无 grpc-status 视为成功
- 成功后自动添加 nsfw 标签到 Token
- 超出数量限制时截取前 N 个处理,而非报错
- 完成后显示警告提示和自动刷新列表

Token 管理界面:
- 状态列显示 nsfw 紫色标签
- 新增「已开 NSFW」和「未开 NSFW」筛选 Tab
- Tab 分隔线区分状态筛选和 NSFW 筛选

配置管理界面:
- 添加 NSFW 相关配置的中文名称和说明
- 更新 JS 版本号强制刷新缓存

Token 管理器:
- 添加 add_tag/remove_tag 方法
2026-02-03 09:03:50 +08:00
piexian 41d5a8d48f feat: 添加 NSFW 启用功能、Token 筛选标签页及修复 use_count 统计
新增功能:
- 添加 gRPC-Web 协议工具用于 NSFW API 调用
- 添加批量执行工具支持并发控制
- 添加 NSFW 服务及管理 API 端点 POST /api/v1/admin/tokens/nsfw/enable
- 添加 Token 状态筛选标签页(全部/正常/限流/失效)支持 ARIA 无障碍
- 添加批量启用 NSFW 按钮到 Token 管理工具栏

缺陷修复:
- 修复 use_count 统计:在 chat/video/image 完成后调用 consume()
- 修复 use_count 计算:使用 actual_cost 替代 cost 避免过度计数
- 修复 toggleSelectAll 仅选择当前筛选结果

配置变更:
- 添加 NSFW 相关配置项到 config.defaults.toml
2026-02-03 08:00:45 +08:00
Chenyme 1dbe5d2525 refactor: project overall architecture and logic 2026-02-02 14:48:54 +08:00