fawney19
88e37594cf
refactor(backend): update handlers, utilities and core modules after models restructure
2025-12-15 14:30:53 +08:00
fawney19
7068aa9130
refactor(backend): optimize cache system and model/provider services
2025-12-15 14:30:21 +08:00
fawney19
56fb6bf36c
refactor(backend): update model catalog and provider APIs after mappings removal
2025-12-15 14:30:10 +08:00
fawney19
728f9bb126
refactor(backend): remove model mappings module
2025-12-15 14:30:00 +08:00
fawney19
beae7a2616
feat(api): add unified Models API endpoint
...
- Add models_service.py with model query logic and caching
- Add models.py unified endpoint supporting Claude/OpenAI/Gemini formats
- Auto-detect API format based on request headers
- Support /v1/models and /v1beta/models (Gemini) paths
- Update route registration and comments
2025-12-14 20:01:19 +08:00
fawney19
21eedbe331
feat: add version management with setuptools-scm
...
- Configure hatch-vcs for automatic version generation from git tags
- Update pyproject.toml to use dynamic versioning
- Add src/_version.py for runtime version access
- Update src/__init__.py to import version from _version
- Add __APP_VERSION__ to frontend vite config
- Add version script to frontend package.json
- Update CI workflows to trigger on version tags instead of branches
2025-12-14 00:12:37 +08:00
fawney19
393d4d13ff
fix(system): fix timezone handling in dashboard and stats services
...
- Use app timezone instead of UTC for date calculations in dashboard routes
- Ensure consistency between stats_daily.date and timezone-aware comparisons
- Fix date calculations in cleanup scheduler to handle DST correctly
- Update log message in stats aggregator to use business date
2025-12-13 23:50:59 +08:00
fawney19
77613795ed
refactor(backend): optimize usage service and database helpers
2025-12-13 22:27:00 +08:00
fawney19
a73e0d51db
fix: 修复链路追踪密钥显示和默认选中逻辑
...
1. 修复密钥脱敏显示问题:先解密再脱敏,避免显示加密后的 base64 数据
2. 优化详情默认选中逻辑:优先显示最后一个有效结果(成功/失败),而非未执行/跳过
2025-12-12 18:15:46 +08:00
fawney19
53bf74429e
refactor: 重构流式处理模块,提取 StreamContext/Processor/Telemetry
...
- 将 chat_handler_base.py 中的流式处理逻辑拆分为三个独立模块:
- StreamContext: 类型安全的流式上下文数据类,替代原有的 ctx dict
- StreamProcessor: SSE 解析、预读、嵌套错误检测
- StreamTelemetryRecorder: 统计记录(Usage/Audit/Candidate)
- 将硬编码配置外置到 settings.py,支持环境变量覆盖:
- HTTP 超时配置(connect/write/pool)
- 流式处理配置(预读行数、统计延迟)
- 并发控制配置(槽位 TTL、缓存预留比例)
2025-12-12 15:42:45 +08:00
fawney19
39defce71c
fix: 修复统计聚合的时区问题,启动时自动回填缺失数据
...
- 统计聚合使用业务时区(APP_TIMEZONE)计算日期,而非UTC
- 新增 _get_business_day_range() 将业务日期转换为UTC时间范围
- 启动时检查并自动回填因容器重启等原因缺失的统计数据
- 修复 aggregate_daily_stats/update_summary/get_today_realtime_stats 等方法的时区计算
2025-12-12 10:06:07 +08:00
fawney19
5722b1422e
fix: 启动时自动回填缺失的统计数据
2025-12-12 09:48:17 +08:00
fawney19
0e8bf0a23b
feat: 请求间隔散点图按模型区分颜色
...
- 后端 get_interval_timeline 接口返回数据添加 model 字段
- 前端散点图按模型分组显示不同颜色的数据点
- 横线统计信息支持按模型分别显示统计数据
- 管理员视图保持按用户分组,用户视图按模型分组
- 更新 mock 数据支持模型字段
2025-12-11 21:33:39 +08:00
fawney19
859c699e90
fix: 调整 interval-timeline 接口 limit 上限
...
- 管理员接口 limit 上限从 5000 调整为 50000
- 用户接口 limit 上限从 5000 调整为 20000
- 默认 hours 从 168 改为 24
2025-12-11 19:39:51 +08:00
fawney19
6e8107e340
fix: 修复管理员散点图只显示部分用户的问题
...
- 改为按比例采样,保持各用户数据量比例不变
- 散点图默认时间从7天改为当天(24小时)
- limit 从 2000 提高到 10000
2025-12-11 19:34:56 +08:00
fawney19
abc41c7d3c
feat: 添加缓存监控和使用量统计 API 端点
2025-12-11 17:47:59 +08:00
fawney19
22ea0e245d
refactor: 统一响应解析中的嵌套错误检测逻辑
...
- 提取 _check_nested_error 函数处理多种错误格式
- 支持检测顶层 error、type=error 以及 chunks 内嵌套的错误
- 简化 OpenAIResponseParser 和 ClaudeResponseParser 中的错误处理代码
- 提高代码复用性和可维护性
2025-12-11 11:33:07 +08:00
fawney19
8f914d89bb
fix: 增加写入超时时间支持大请求体
...
- 将 chat_handler_base 的写入超时从 10 秒增加到 60 秒
- 将 cli_handler_base 的写入超时从 10 秒增加到 60 秒
- 将 http_client 的写入超时从 10 秒增加到 60 秒
- 支持包含大量数据(如图片)的长对话请求
2025-12-11 11:21:46 +08:00
fawney19
d6994316f1
fix: 修复失败请求筛选兼容旧数据
...
失败请求筛选同时考虑新旧两种判断方式:
- 新方式:status = "failed"
- 旧方式:status_code >= 400 或 error_message 不为空
2025-12-11 10:52:12 +08:00
fawney19
323a514f77
refactor: 优化活跃请求状态查询逻辑
...
- 重命名 get_active_requests 为 get_active_requests_status
- 支持从端点配置读取超时时间
- 新增 content_length_limit 错误类型
2025-12-11 10:45:06 +08:00
fawney19
0474f63403
refactor: 完善 handler 基类类型注解和流式状态更新
...
- 为 BaseMessageHandler 和 MessageTelemetry 添加完整类型注解
- 新增 _update_usage_to_streaming 方法,异步更新 Usage 状态为 streaming
- 优化 chat/cli handler 的类型提示,提升代码可维护性
- 修复类型检查警告,确保 mypy 通过
2025-12-11 10:05:06 +08:00
fawney19
913a87d7f3
refactor: 重构活跃请求查询逻辑到 UsageService
...
- 在 UsageService 新增 get_active_requests 方法,统一处理活跃请求查询
- 支持自动清理超时的 pending 请求(默认 5 分钟)
- admin 和 user 接口均复用该方法,减少重复代码
- 支持按 ID 列表查询或查询所有活跃请求
2025-12-11 10:04:15 +08:00
fawney19
f784106826
Initial commit
2025-12-10 20:52:44 +08:00