fix: memory
This commit is contained in:
parent
3755e58ec7
commit
4228adf7f3
3 changed files with 4 additions and 6 deletions
|
@ -3,6 +3,7 @@ package chatbot
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"sync"
|
||||
|
||||
|
@ -173,6 +174,8 @@ func getAIResponse(c *Chatbot, user *discordgo.User, question string) (string, e
|
|||
return "", err
|
||||
}
|
||||
|
||||
log.Printf("%s TOKEN: %d", user.ID, result.UsageMetadata.PromptTokenCount)
|
||||
|
||||
return resultText, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ func SaveMemory(data *databases.InsertMemory) error {
|
|||
func GetMemory(userId string) ([]*genai.Content, error) {
|
||||
var data []databases.Memory
|
||||
|
||||
MAX_LENGTH := 50
|
||||
memory := []*genai.Content{}
|
||||
|
||||
cur, err := databases.Database.Memory.Find(context.TODO(), bson.D{{Key: "user_id", Value: userId}})
|
||||
|
@ -26,10 +25,6 @@ func GetMemory(userId string) ([]*genai.Content, error) {
|
|||
|
||||
cur.All(context.TODO(), &data)
|
||||
|
||||
if len(data) > MAX_LENGTH {
|
||||
data = data[MAX_LENGTH:]
|
||||
}
|
||||
|
||||
for _, data := range data {
|
||||
memory = append(memory,
|
||||
genai.NewContentFromText(data.Content, genai.RoleUser),
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"git.wh64.net/muffin/goMuffin/utils"
|
||||
)
|
||||
|
||||
const MUFFIN_VERSION = "0.0.0-madeleine_canary.250604a-muffin-ai"
|
||||
const MUFFIN_VERSION = "0.0.0-madeleine_canary.250604b-muffin-ai"
|
||||
|
||||
var updatedString string = utils.RegexpDecimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0]
|
||||
|
||||
|
|
Loading…
Reference in a new issue