From 5798d83ee2cb6612ba5f504f5fe43bd16c6e920e Mon Sep 17 00:00:00 2001 From: ScuroNeko Date: Tue, 27 Jan 2026 17:06:32 +0300 Subject: [PATCH] utils --- plugins/rp.go | 10 ++++------ utils/utils.go | 12 ++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/rp.go b/plugins/rp.go index 2a8e7e4..448efda 100644 --- a/plugins/rp.go +++ b/plugins/rp.go @@ -8,6 +8,7 @@ import ( "kurumibot/database/psql" "kurumibot/database/red" "kurumibot/laniakea" + "kurumibot/utils" "kurumibot/utils/ai" "strconv" "strings" @@ -612,8 +613,8 @@ func compress(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { } //compressModel := "anthropic/claude-sonnet-4" - compressModel := "gpt-5.1" - //compressModel := "deepseek-ai/deepseek-v3.2" + //compressModel := "gpt-5.1" + compressModel := "deepseek-ai/deepseek-v3.2" api := ai.NewOpenAIAPI(ai.GPTBaseUrl, "", compressModel) res, err := api.CompressChat(messages) if err != nil { @@ -637,10 +638,7 @@ func compress(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) { if err != nil { ctx.Error(err) } - offset := 20 - if len(history) < 20 { - offset = len(history) - } + offset := utils.Min(len(history), 20) for _, m := range history[len(history)-offset:] { err = mdb.UpdateChatHistory(db, chatId, m.Role, m.Message) if err != nil { diff --git a/utils/utils.go b/utils/utils.go index 55d07fc..a02a96f 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -5,3 +5,15 @@ import "math/rand/v2" func RandRange(min, max int) int { return rand.IntN(max-min) + min } +func Min(a, b int) int { + if a < b { + return a + } + return b +} +func Max(a, b int) int { + if a > b { + return a + } + return b +}