resolve conflicts

This commit is contained in:
RockYang
2025-02-11 09:53:41 +08:00
7 changed files with 74 additions and 28 deletions

View File

@@ -274,17 +274,17 @@ func (h *ChatHandler) Tokens(c *gin.Context) {
}
// 如果没有传入 text 字段,则说明是获取当前 reply 总的 token 消耗(带上下文)
if data.Text == "" && data.ChatId != "" {
var item model.ChatMessage
userId, _ := c.Get(types.LoginUserID)
res := h.DB.Where("user_id = ?", userId).Where("chat_id = ?", data.ChatId).Last(&item)
if res.Error != nil {
resp.ERROR(c, res.Error.Error())
return
}
resp.SUCCESS(c, item.Tokens)
return
}
//if data.Text == "" && data.ChatId != "" {
// var item model.ChatMessage
// userId, _ := c.Get(types.LoginUserID)
// res := h.DB.Where("user_id = ?", userId).Where("chat_id = ?", data.ChatId).Last(&item)
// if res.Error != nil {
// resp.ERROR(c, res.Error.Error())
// return
// }
// resp.SUCCESS(c, item.Tokens)
// return
//}
tokens, err := utils.CalcTokens(data.Text, data.Model)
if err != nil {