Commit Graph

116 Commits

Author SHA1 Message Date
fawney19
6fbb867f5f Exclude unknown providers from usage aggregations 2026-05-06 13:40:18 +08:00
Entropy.Xu
4baee436ba feat(image): 接入 ChatGPT Web 生图反代 2026-05-06 11:52:33 +08:00
fawney19
beee7a76d2 Fix postgres export smoke import compatibility 2026-05-06 09:29:12 +08:00
fawney19
887a58d639 Fix usage provider stats and performance analysis UI 2026-05-06 09:29:12 +08:00
fawney19
6219491389 chore: squash inactive mysql sqlite migrations 2026-05-06 03:09:53 +08:00
fawney19
d7c2232062 fix: reconcile combined usage aggregation helpers 2026-05-06 02:47:52 +08:00
fawney19
2eb4afbec4 Merge remote-tracking branch 'origin/pr/384' into codex/pr-376-377-383-384-combined
# Conflicts:
#	frontend/src/views/admin/PerformanceAnalysis.vue
2026-05-06 02:39:53 +08:00
fawney19
b8a6feef4a Merge remote-tracking branch 'origin/pr/377' into codex/pr-376-377-383-384-combined
# Conflicts:
#	apps/aether-gateway/src/tests/frontdoor/public_support/dashboard.rs
#	crates/aether-data/src/lifecycle/backfill.rs
#	crates/aether-data/src/repository/usage/postgres/mod.rs
2026-05-06 02:36:57 +08:00
fawney19
be580c35bb chore: resolve pr 377 checks 2026-05-06 02:22:32 +08:00
fawney19
cf27773582 feat: improve admin performance analysis 2026-05-06 02:01:32 +08:00
fawney19
3264857e4a fix(usage): repair aggregate usage statistics 2026-05-06 01:13:23 +08:00
fawney19
8043cca126 fix: align postgres core export schema 2026-05-06 00:20:06 +08:00
fawney19
aacab1a90c Merge remote-tracking branch 'origin/aether-rust-pioneer' into aether-rust-pioneer
# Conflicts:
#	crates/aether-data-contracts/src/repository/usage/mod.rs
#	crates/aether-data/src/repository/global_models/postgres.rs
#	crates/aether-data/src/repository/usage/postgres/mod.rs
2026-05-05 18:53:14 +08:00
fawney19
fce7e959e5 Add multi-database data layer
Introduce aether-data-schema and driver-specific schema generation for Postgres, MySQL, and SQLite.

Split data backends, lifecycle, repositories, and gateway runtime integration across database drivers.

Verified with cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace.
2026-05-05 18:27:36 +08:00
mayrain
6b6d32b4a3 feat(usage): 新增输出速度统计与请求详情性能分析
- 把 upstream_is_stream 物化到 usage 与 billing facts,避免 Provider 聚合回连 public.usage
- 统一前端标准/流式 TPS 计算与显示,流式按首字后生成耗时计算
- 新增请求详情抽屉展示单请求输出速度与 Provider 聚合 TPS
2026-05-05 17:34:12 +08:00
mayrain
f0197b685f fix(data): 同步模型调用次数至 global_models 读模型
- 模型列表改为读取 global_models.usage_count,避免每次扫描 usage 明细表
- 通过历史 backfill 与 usage upsert delta 维护该读模型
- 详情页保留实时 facts 兜底,统一排除 pending/streaming 状态
2026-05-05 17:34:02 +08:00
mayrain
53fa33b0c5 fix(dashboard): 修复仪表盘与明细统计数值不一致并重建 cost_savings 聚合
- 统一 dashboard 聚合与 raw 查询的 token 计算,拆分今日节省和周期节省
- cache savings 改用 input price 估算未命中成本,修复历史 cost_savings 偏高
- raw 查询 total_tokens 改用 effective_input + output + cache_creation + cache_read 公式
- 新增独立 backfill 重建历史 cost_savings 聚合表,保留已发布 backfill 不变
2026-05-05 17:33:16 +08:00
mayrain
2f915b33c7 perf(usage): 重构多天聚合查询为数据库端按天分组计算
- 多天范围的模型、供应商和 API 格式分析复用已有用户日聚合表
- 只对未完成窗口回退明细查询,再合并排序截断
- 避免长范围直接扫 usage_billing_facts 视图
2026-05-05 17:33:04 +08:00
mayrain
fd8230121c fix(usage): 修复多天统计 NUMERIC→f64 解码失败导致记录清空
- 多天统计从日聚合表 SUM numeric 字段后返回 NUMERIC,代码按 f64 解码失败
- 显式添加 ::DOUBLE PRECISION 类型转换
- 管理员统计加载失败时不再清空已加载的记录列表
2026-05-05 17:32:50 +08:00
Entropy.Xu
ff1ed8b57d feat(stats): 添加 Provider 性能统计分析 2026-05-05 11:24:16 +08:00
fawney19
627eb4f335 Merge pull request #371 from Kayphoon/feature/embedding-model-support
feat: add embedding and rerank support
2026-05-04 12:56:11 +08:00
fawney19
8dd4135f7c Fix provider key insert placeholder order 2026-05-04 12:21:54 +08:00
fawney19
53a5e18b20 Merge pull request #370 from yao177/aether-rust-pioneer
fix(proxy): record manual proxy node traffic
2026-05-03 21:40:20 +08:00
fawney19
a24e4a793d Refactor pool candidate scheduling 2026-05-03 20:14:29 +08:00
fawney19
8ebee9922c fix: return auth mismatch key setting in provider key list 2026-05-03 20:11:49 +08:00
Yao177
c3d97b8c16 fix(proxy): record manual proxy node traffic
- add manual proxy traffic mutations to the data layer
- record sync and stream outcomes for manual proxy requests
- prevent tunnel proxy nodes from receiving manual traffic updates
2026-05-03 18:38:04 +08:00
Kayphoon
5abe664d65 feat: add embedding and rerank support 2026-05-03 17:32:41 +08:00
jiuwovo-ai
3e2eca4fd0 fix: 修复手动代理节点请求不计数及延迟/心跳不显示的问题 (#368)
* fix: 修复手动代理节点请求不计数及延迟/心跳不显示的问题

问题描述:
- 手动添加的代理节点请求数始终为0,不会递增
- 手动代理节点的延迟和最后心跳时间不显示

根因:
Rust 重写版中缺失了 Python 版的手动代理节点请求计数逻辑。
隧道节点通过心跳上报计数,但手动节点没有心跳机制,
需要在 usage recording 路径中递增计数并更新延迟信息。

修复方案:
1. 在 ExecutionPlan 中提取 proxy 信息,注入到 request_metadata
2. 在 request_metadata 白名单中添加 proxy 字段
3. 新增 INCREMENT_MANUAL_PROXY_NODE_REQUESTS_SQL,
   递增 total_requests/failed_requests,
   同时更新 avg_latency_ms 和 last_heartbeat_at
4. 在 ProxyNodeWriteRepository trait 新增 increment_manual_node_requests 方法
5. 在 write_event_record 中解析 request_metadata 中的 proxy 信息,
   对非隧道模式的手动节点调用递增方法
6. 为 GatewayDataState 实现 ManualProxyNodeCounter trait

影响范围:
- 仅影响手动代理节点的统计数据
- 隧道节点不受影响(继续通过心跳计数)
- 不影响请求转发逻辑

* style: cargo fmt

---------

Co-authored-by: root <root@ser406777952330.local>
2026-05-03 14:50:36 +08:00
Kayphoon
fe27fb17fb feat: add provider-key concurrent limit (#352)
* feat: add provider-key concurrent limit

* Fix provider key concurrent limit checks

---------

Co-authored-by: fawney19 <elky0401@gmail.com>
2026-05-03 01:55:23 +08:00
fawney19
e3ea2d1451 feat: configure auth channel mismatch formats 2026-05-03 00:49:22 +08:00
fawney19
9570e5c2c1 Fix legacy Claude and Gemini auth migration 2026-04-30 18:01:58 +08:00
RWDai
2b5247b9a8 fix(data): repair request candidate epoch created_at (#343)
Co-authored-by: fawney19 <elky0401@gmail.com>
2026-04-30 09:23:21 +08:00
Entropy.Xu
4d59d518d1 fix: correct API key expiry and dashboard savings (#361) 2026-04-30 00:35:32 +08:00
fawney19
9e2faa7e5b Tighten local auth allow-list matching 2026-04-30 00:26:33 +08:00
fawney19
e751289dfb Support per-format provider key auth 2026-04-29 15:46:50 +08:00
fawney19
07a319259b Normalize canonical API formats 2026-04-29 10:20:41 +08:00
fawney19
230e7d6259 Normalize management token prefixes 2026-04-28 19:46:38 +08:00
fawney19
0c9b5ddd77 Fix usage terminal state regression 2026-04-28 10:31:16 +08:00
fawney19
1d23bf4ecb Isolate standalone key wallet handling 2026-04-27 17:24:31 +08:00
Kayphoon
9b866a6d17 fix(auth): 修复独立密钥继承用户访问限制 (#347) 2026-04-27 12:32:21 +08:00
fawney19
4ec591fbf2 centralize openai responses alias handling 2026-04-26 23:59:53 +08:00
fawney19
5b914aa78c migrate ai format conversion to responses adapters 2026-04-26 23:59:53 +08:00
fawney19
e5bbc797e0 chore(gateway): 调小 Postgres 连接池默认值
- max_connections 100 → 20
- idle_timeout 60s → 30s
- .env.example 补充连接池相关变量注释
2026-04-25 09:53:21 +08:00
fawney19
f30b1f3f6b fix(usage): 流式终端 usage 以更完整值为准,Codex CLI 显式选择 response 解析器
- 新增 StandardizedUsage::signal_score/is_more_complete_than/choose_more_complete,流式合并与终端落库均按信号完整度择优
- OpenAI Chat/CLI 解析器支持仅 usage 的终结 chunk 与 response.completed usage
- Codex provider 注入 provider_stream_event_api_format=openai:cli,解析器选择改由 report_context 显式决定
- usage_mapper 扩展嵌套 response/message/item 兼容 Claude message_start/message_delta 及 Gemini stream chunks
- usage SQL upsert 在终态(completed/failed/cancelled)时按 GREATEST 写入 token/费用镜像列
2026-04-25 00:57:01 +08:00
fawney19
e265475c17 fix(usage): 修正 input_tokens 统计与显示
- SQL 查询不再用 settlement snapshot 的 billing_input_tokens 覆盖原始 input_tokens
- usage_mapper 针对 OpenAI 格式在 input_tokens 缺失时从 total_tokens - output_tokens 推导
- 前端轮询合并优先采用最新 record 的 input_tokens / effective_input_tokens
2026-04-24 20:59:12 +08:00
fawney19
657fcd595c refactor(rust): 拆分 usage sql 仓储为模块并外置 SQL 文件
- 将 usage/sql.rs 拆分为 sql/mod.rs 与 sql/tests.rs
- 将内联 SQL 抽离到 sql/queries/ 目录下的独立 .sql 文件
- 前端用量记录表格移除缓存创建 token 展示,保留 cache read 列
2026-04-24 20:22:24 +08:00
fawney19
f695238e8a feat(billing): 引入 billing v3 settlement snapshot 及 usage_billing_facts 视图
- 新增迁移 20260424000000:为 usage_settlement_snapshots 添加 settlement_snapshot、
  billing_dimensions、billing_input/output/cache tokens、billing_total_cost_usd 等列,
  并创建 usage_billing_facts 视图(从 settlement snapshot 覆盖原始 usage token/cost 字段)
- event_enrichment:构建结构化 settlement_snapshot(含 pricing_snapshot、billing_plan_snapshot、
  resolved_dimensions、cost_breakdown 等),写入 request_metadata
- pricing:新增 pricing_source() 方法区分 provider_override / global_default / unpriced
- sql.rs:settlement snapshot 写入新列;用量汇总查询改用 usage_billing_facts 视图
- maintenance/runtime:所有统计查询的 FROM usage 替换为 FROM usage_billing_facts
- admin observability:在 settlement 响应中暴露 settlement_snapshot / billing_dimensions,
  并从 metadata 中剥离对应字段
- request_metadata:允许 settlement_snapshot / billing_dimensions 字段传播
- stream execution:在首个数据帧到达时记录 TTFB,补全流式请求的 streaming 事件
2026-04-24 17:52:33 +08:00
fawney19
780f09c1a2 feat(billing): 引入 model_id 精确计费查找路径,传播模型 ID 至用量事件与 report context
- UsageEventData 新增 model_id / global_model_id 字段,write.rs seed 结构体同步补充
- report_context 新增 model_id / global_model_id / global_model_name,各 payload 构建时从 candidate 传入
- event_enrichment 优先按 model_id 精确查找计费上下文,回退为按名称多轮查找(保留 NoRule 结果降级逻辑)
- BillingReadRepository 新增 find_model_context_by_model_id,memory/sql 分别实现;SQL 查询重构支持按 provider_model_name 和 mappings 匹配并按优先级排序
- pricing.rs 修复:model_tiered_pricing 为空 tiers 时回退到 default_tiered_pricing
- request_metadata 允许字段列表补充 model_id / global_model_id / global_model_name
- admin usage 路由信息输出及脱敏字段列表同步新增三个 model 相关字段
2026-04-24 14:40:28 +08:00
fawney19
f3c9835759 feat(pool): 引入 pro_first 调度预设、Pool 候选持久化跳过与诊断信息优化
- 新增 pro_first 调度预设(Pro 优先),更新 plus_first 仅针对 Plus 计划,移除 free_team_first
- Pool 内部候选(pool_key_index 不为空)跳过 DB 持久化(available/skipped/unused 均适用)
- LRU 排序新增 catalog_lru_score 回退:runtime 无记录时使用 last_used_at_unix_secs
- 执行路径 miss 诊断消息细化为中文,按 reason 分类输出可读说明
- build_local_request_candidate_status_record 补充 extra_data 和 created_at_unix_ms 字段
- OpenAI CLI 计划构建流程补充候选评估进度跟踪与 terminal reason 设置
- 前端 PoolSchedulingDialog 增加 pro_first 预设展示,修复 LRU 默认预设检测逻辑
2026-04-24 13:29:05 +08:00
AAEE86
a9d10163af fix(oauth): 修复 OAuth 刷新后 Token 有效期不更新问题 (#324)
- 持久化刷新后的 `expires_at` 到 Provider Key SQL 更新链路
- 手动刷新接口优先返回本次刷新得到的过期时间
- 按当前 Key 字段重建 OAuth 状态快照,避免旧快照覆盖
- 前端刷新后防止旧列表数据回退覆盖新有效期
2026-04-24 09:35:25 +08:00