refactoring, fixes and laniakea v0.8
This commit is contained in:
@@ -2,10 +2,9 @@ package mdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kurumibot/database"
|
||||
"time"
|
||||
"ymgb/database"
|
||||
|
||||
"git.nix13.pw/scuroneko/laniakea"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
@@ -17,7 +16,7 @@ type AiChatMessage struct {
|
||||
Index int `bson:"index"`
|
||||
}
|
||||
|
||||
func GetRPChatHistory(db *laniakea.DatabaseContext, chatId string) ([]AiChatMessage, error) {
|
||||
func GetRPChatHistory(db *database.Context, chatId string) ([]AiChatMessage, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
col := database.GetMongoCollection(db, "rp_chat_messages")
|
||||
@@ -29,7 +28,7 @@ func GetRPChatHistory(db *laniakea.DatabaseContext, chatId string) ([]AiChatMess
|
||||
err = cursor.All(ctx, &result)
|
||||
return result, err
|
||||
}
|
||||
func UpdateRPChatHistory(db *laniakea.DatabaseContext, chatId, role, message string, index int) error {
|
||||
func UpdateRPChatHistory(db *database.Context, chatId, role, message string, index int) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
col := database.GetMongoCollection(db, "rp_chat_messages")
|
||||
@@ -41,13 +40,13 @@ func UpdateRPChatHistory(db *laniakea.DatabaseContext, chatId, role, message str
|
||||
})
|
||||
return err
|
||||
}
|
||||
func GetRPChatHistorySize(db *laniakea.DatabaseContext, chatId string) (int64, error) {
|
||||
func GetRPChatHistorySize(db *database.Context, chatId string) (int64, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
col := database.GetMongoCollection(db, "rp_chat_messages")
|
||||
return col.CountDocuments(ctx, bson.M{"chatId": chatId})
|
||||
}
|
||||
func DeleteRPChatEntry(db *laniakea.DatabaseContext, entry AiChatMessage) error {
|
||||
func DeleteRPChatEntry(db *database.Context, entry AiChatMessage) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
col := database.GetMongoCollection(db, "rp_chat_messages")
|
||||
|
||||
Reference in New Issue
Block a user