mirror of
https://github.com/jie65535/JChatGPT.git
synced 2025-12-08 18:31:36 +08:00
Split memory agent
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user