Split memory agent

This commit is contained in:
2025-07-20 11:11:47 +08:00
parent c479282fe4
commit 3a5caf86a1
4 changed files with 81 additions and 8 deletions

View File

@@ -8,4 +8,28 @@ object PluginData : AutoSavePluginData("data") {
* 联系人记忆
*/
val contactMemory by value(mutableMapOf<Long, String>())
/**
* 添加对话记忆
*/
fun appendContactMemory(contactId: Long, newMemory: String) {
val memory = contactMemory[contactId]
if (memory.isNullOrEmpty()) {
contactMemory[contactId] = "* $newMemory"
} else {
contactMemory[contactId] = "$memory\n* $newMemory"
}
}
/**
* 替换对话记忆
*/
fun replaceContactMemory(contactId: Long, oldMemory: String, newMemory: String) {
val memory = contactMemory[contactId]
if (memory.isNullOrEmpty()) {
contactMemory[contactId] = "* $newMemory"
} else {
contactMemory[contactId] = memory.replace(oldMemory, newMemory)
}
}
}