From 9953f8fc0441e861a83a82f43a770f226b159c48 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sun, 17 Mar 2024 18:44:58 +0800 Subject: [PATCH] Fix chat in GetAnswer() --- controllers/message_answer.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/controllers/message_answer.go b/controllers/message_answer.go index 9ead8a243..e1b6a4125 100644 --- a/controllers/message_answer.go +++ b/controllers/message_answer.go @@ -299,6 +299,8 @@ func (c *ApiController) GetAnswer() { Text: question, } + questionMessage.Currency = modelResult.Currency + _, err = object.AddMessage(questionMessage) if err != nil { c.ResponseError(err.Error()) @@ -327,5 +329,20 @@ func (c *ApiController) GetAnswer() { return } + chat.TokenCount += answerMessage.TokenCount + chat.Price += answerMessage.Price + if chat.Currency == "" { + chat.Currency = answerMessage.Currency + } + + chat.UpdatedTime = util.GetCurrentTime() + chat.MessageCount += 2 + + _, err = object.UpdateChat(chat.GetId(), chat) + if err != nil { + c.ResponseOk(err.Error()) + return + } + c.ResponseOk(answer) }