utils
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user