mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-12-25 17:45:58 +08:00
feat: 增加用户 token 消耗统计功能
This commit is contained in:
@@ -319,6 +319,10 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session types.ChatSession
|
||||
if res.Error != nil {
|
||||
logger.Error("failed to save reply history message: ", res.Error)
|
||||
}
|
||||
|
||||
// 统计用户 token 数量
|
||||
h.db.Model(&user).UpdateColumn("tokens", gorm.Expr("tokens + ?",
|
||||
historyUserMsg.Tokens+historyReplyMsg.Tokens))
|
||||
}
|
||||
|
||||
// 保存当前会话
|
||||
|
||||
Reference in New Issue
Block a user