diff --git a/src/main/kotlin/PluginConfig.kt b/src/main/kotlin/PluginConfig.kt index 11c8050..06adb25 100644 --- a/src/main/kotlin/PluginConfig.kt +++ b/src/main/kotlin/PluginConfig.kt @@ -69,7 +69,7 @@ object PluginConfig : AutoSavePluginConfig("Config") { val timeout: Long by value(60000L) @Deprecated("使用外部文件而不是在配置文件内保存提示词") - @ValueDescription("系统提示词") + @ValueDescription("系统提示词,该字段已弃用,使用提示词文件而不是在这里修改") var prompt: String by value("你是一个乐于助人的助手") @ValueDescription("系统提示词文件路径,相对于插件配置目录") @@ -95,4 +95,7 @@ object PluginConfig : AutoSavePluginConfig("Config") { @ValueDescription("是否显示工具调用消息,默认是") val showToolCallingMessage by value(true) + + @ValueDescription("是否启用记忆编辑功能,记忆存在data目录,提示词中需要加上{memory}来填充记忆,每个群都有独立记忆") + val memoryEnabled by value(true) } \ No newline at end of file diff --git a/src/main/kotlin/tools/MemoryAppend.kt b/src/main/kotlin/tools/MemoryAppend.kt index 533d957..18ceef8 100644 --- a/src/main/kotlin/tools/MemoryAppend.kt +++ b/src/main/kotlin/tools/MemoryAppend.kt @@ -10,6 +10,7 @@ import kotlinx.serialization.json.putJsonArray import kotlinx.serialization.json.putJsonObject import net.mamoe.mirai.event.events.MessageEvent import top.jie65535.mirai.JChatGPT +import top.jie65535.mirai.PluginConfig import top.jie65535.mirai.PluginData class MemoryAppend : BaseAgent( @@ -30,6 +31,9 @@ class MemoryAppend : BaseAgent( } ) ) { + override val isEnabled: Boolean + get() = PluginConfig.memoryEnabled + override suspend fun execute(args: JsonObject?, event: MessageEvent): String { requireNotNull(args) val contactId = event.subject.id diff --git a/src/main/kotlin/tools/MemoryReplace.kt b/src/main/kotlin/tools/MemoryReplace.kt index f6fe2e7..98f1d27 100644 --- a/src/main/kotlin/tools/MemoryReplace.kt +++ b/src/main/kotlin/tools/MemoryReplace.kt @@ -10,13 +10,14 @@ import kotlinx.serialization.json.putJsonArray import kotlinx.serialization.json.putJsonObject import net.mamoe.mirai.event.events.MessageEvent import top.jie65535.mirai.JChatGPT +import top.jie65535.mirai.PluginConfig import top.jie65535.mirai.PluginData class MemoryReplace : BaseAgent( - tool = Tool.Companion.function( + tool = Tool.function( name = "memoryReplace", description = "替换记忆项", - parameters = Parameters.Companion.buildJsonObject { + parameters = Parameters.buildJsonObject { put("type", "object") putJsonObject("properties") { putJsonObject("oldMemory") { @@ -35,6 +36,9 @@ class MemoryReplace : BaseAgent( } ) ) { + override val isEnabled: Boolean + get() = PluginConfig.memoryEnabled + override suspend fun execute(args: JsonObject?, event: MessageEvent): String { requireNotNull(args) val contactId = event.subject.id