Skip to content

Commit

Permalink
bugfix:chat context to long to send message
Browse files Browse the repository at this point in the history
  • Loading branch information
ivhu committed Nov 25, 2024
1 parent a0115a0 commit 3834144
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ai/gemini/gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func (g *gemini) Chat(chatId string, msg string) (string, error) {
cs = g.model.StartChat()
g.chats[chatId] = cs
}
if len(cs.History) > 30 {
cs.History = cs.History[len(cs.History)-30:]
}
if err := g.db.Add(models.NewChat(chatId, true, msg)); err != nil {
log.Error().Err(err).Msg("failed to add chat record")
}
Expand Down

0 comments on commit 3834144

Please sign in to comment.