some fixes

This commit is contained in:
2026-01-19 21:56:41 +03:00
parent ad6e52890b
commit 65acbab94e
9 changed files with 88 additions and 76 deletions

View File

@@ -13,16 +13,13 @@ type RPChatMessage struct {
ChatID string `bson:"chat_id"`
Role string `bson:"role"`
Message string `bson:"message"`
Index int `bson:"index"`
}
func GetChatHistory(db *laniakea.DatabaseContext, chatId string, index int) ([]*RPChatMessage, error) {
func GetChatHistory(db *laniakea.DatabaseContext, chatId string) ([]*RPChatMessage, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
col := database.GetMongoCollection(db, "rp_chat_messages")
cursor, err := col.Find(ctx, bson.M{"chat_id": chatId, "index": bson.M{
"$gt": index - 8, "$lt": index,
}})
cursor, err := col.Find(ctx, bson.M{"chat_id": chatId})
if err != nil {
return nil, err
}
@@ -30,7 +27,7 @@ func GetChatHistory(db *laniakea.DatabaseContext, chatId string, index int) ([]*
err = cursor.All(ctx, &result)
return result, err
}
func UpdateChatHistory(db *laniakea.DatabaseContext, chatId, role, message string, index int) error {
func UpdateChatHistory(db *laniakea.DatabaseContext, chatId, role, message string) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
col := database.GetMongoCollection(db, "rp_chat_messages")
@@ -38,7 +35,6 @@ func UpdateChatHistory(db *laniakea.DatabaseContext, chatId, role, message strin
chatId,
role,
message,
index,
})
return err
}