From 6f73e5087d1132127ad4ffe55da984712415ce68 Mon Sep 17 00:00:00 2001 From: Dt8333 <25431943+Dt8333@users.noreply.github.com> Date: Sun, 12 Oct 2025 10:42:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E5=9C=A8=E6=96=B0=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E4=B8=AD=E9=87=8D=E7=94=A8=E5=85=88=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E4=BA=BA=E6=A0=BC=E8=AE=BE=E7=BD=AE=20(#3005?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(core): reuse persona conf in new conversation #2985 * refactor(core): simplify persona retrieval logic * style: code format --------- Co-authored-by: Soulter <905617992@qq.com> --- astrbot/core/config/default.py | 5 +---- packages/astrbot/commands/conversation.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 4c42bf0a3..1e43d77bc 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -1436,10 +1436,7 @@ CONFIG_METADATA_2 = { "description": "服务订阅密钥", "hint": "Azure_TTS 服务的订阅密钥(注意不是令牌)", }, - "dashscope_tts_voice": { - "description": "音色", - "type": "string" - }, + "dashscope_tts_voice": {"description": "音色", "type": "string"}, "gm_resp_image_modal": { "description": "启用图片模态", "type": "bool", diff --git a/packages/astrbot/commands/conversation.py b/packages/astrbot/commands/conversation.py index a29d35ea6..49f3cdcc5 100644 --- a/packages/astrbot/commands/conversation.py +++ b/packages/astrbot/commands/conversation.py @@ -41,6 +41,17 @@ class ConversationCommands: self.context = context self.ltm = ltm + async def _get_current_persona_id(self, session_id): + curr = await self.context.conversation_manager.get_curr_conversation_id( + session_id + ) + if not curr: + return None + conv = await self.context.conversation_manager.get_conversation( + session_id, curr + ) + return conv.persona_id + def ltm_enabled(self, event: AstrMessageEvent): if not self.ltm: return False @@ -255,8 +266,9 @@ class ConversationCommands: ) return + cpersona = await self._get_current_persona_id(message.unified_msg_origin) cid = await self.context.conversation_manager.new_conversation( - message.unified_msg_origin, message.get_platform_id() + message.unified_msg_origin, message.get_platform_id(), persona_id=cpersona ) # 长期记忆 @@ -290,8 +302,10 @@ class ConversationCommands: session_id=sid, ) ) + + cpersona = await self._get_current_persona_id(session) cid = await self.context.conversation_manager.new_conversation( - session, message.get_platform_id() + session, message.get_platform_id(), persona_id=cpersona ) message.set_result( MessageEventResult().message(