Merge branch 'main' into prod

This commit is contained in:
RockYang
2023-07-02 00:04:59 +08:00
7 changed files with 11 additions and 17 deletions

View File

@@ -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))
}
// 保存当前会话

View File

@@ -218,7 +218,7 @@ type userProfile struct {
Avatar string `json:"avatar"`
ChatConfig types.ChatConfig `json:"chat_config"`
Calls int `json:"calls"`
Tokens int `json:"tokens"`
Tokens int64 `json:"tokens"`
}
func (h *UserHandler) Profile(c *gin.Context) {