模块介绍 / 今日规划 / 下班日报 / 团队摘要 生成成功后没有上报,也几乎不写「AI」日志。

流结束时的 usage 用了非阻塞发送,通道一满就被丢掉;很多服务商默认还不在流里带 usage。
现在每次真正打到模型的调用都会:

在本地日志(分类 AI,消息 AI 调用完成)写下 scene / prompt / completion / cached
登录后同步上报到后台日汇总
This commit is contained in:
李琦
2026-08-17 14:00:47 +08:00
parent 83e69317d4
commit e71ce451ff
23 changed files with 1363 additions and 93 deletions

View File

@@ -368,7 +368,7 @@ func (a *App) checkAIPolicy() error {
}
// reportAIUsage 上报一次 AI 用量(失败忽略)。
func (a *App) reportAIUsage(provider string, prompt, completion int64, estimated bool) {
func (a *App) reportAIUsage(provider string, prompt, completion, cached int64, estimated bool) {
if a.syncUserID() <= 0 || a.store.Meta("sync_access_token") == "" {
return
}
@@ -376,6 +376,7 @@ func (a *App) reportAIUsage(provider string, prompt, completion int64, estimated
"provider": provider,
"promptTokens": prompt,
"completionTokens": completion,
"cachedTokens": cached,
"estimated": estimated,
}, nil, true)
}