This commit is contained in:
2026-01-13 21:01:10 +03:00
parent cec3a35d83
commit 7d540962a1
6 changed files with 79 additions and 21 deletions

View File

@@ -18,7 +18,7 @@ type RPChatMessage struct {
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_history")
col := database.GetMongoCollection(db, "rp_chat_messages")
cursor, err := col.Find(ctx, bson.M{"chat_id": chatId})
if err != nil {
return nil, err
@@ -30,7 +30,7 @@ func GetChatHistory(db *laniakea.DatabaseContext, chatId string) ([]*RPChatMessa
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_history")
col := database.GetMongoCollection(db, "rp_chat_messages")
_, err := col.InsertOne(ctx, RPChatMessage{
chatId,
role,