Skip to content

Commit

Permalink
Fix chat in GetAnswer()
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Mar 17, 2024
1 parent c25466e commit 9953f8f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions controllers/message_answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
}

0 comments on commit 9953f8f

Please sign in to comment.