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