mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-18 01:06:39 +08:00
fixed bug for calculate chat message tokens
This commit is contained in:
parent
cf817fd8ea
commit
5213bdf08b
@ -379,17 +379,17 @@ func (h *ChatHandler) Tokens(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有传入 text 字段,则说明是获取当前 reply 总的 token 消耗(带上下文)
|
// 如果没有传入 text 字段,则说明是获取当前 reply 总的 token 消耗(带上下文)
|
||||||
if data.Text == "" && data.ChatId != "" {
|
//if data.Text == "" && data.ChatId != "" {
|
||||||
var item model.ChatMessage
|
// var item model.ChatMessage
|
||||||
userId, _ := c.Get(types.LoginUserID)
|
// userId, _ := c.Get(types.LoginUserID)
|
||||||
res := h.DB.Where("user_id = ?", userId).Where("chat_id = ?", data.ChatId).Last(&item)
|
// res := h.DB.Where("user_id = ?", userId).Where("chat_id = ?", data.ChatId).Last(&item)
|
||||||
if res.Error != nil {
|
// if res.Error != nil {
|
||||||
resp.ERROR(c, res.Error.Error())
|
// resp.ERROR(c, res.Error.Error())
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
resp.SUCCESS(c, item.Tokens)
|
// resp.SUCCESS(c, item.Tokens)
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
|
||||||
tokens, err := utils.CalcTokens(data.Text, data.Model)
|
tokens, err := utils.CalcTokens(data.Text, data.Model)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user