feat(core): 在新对话中重用先前的对话人格设置 (#3005)

* 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>
This commit is contained in:
Dt8333
2025-10-12 10:42:35 +08:00
committed by GitHub
co-authored by Soulter
parent 8c120b020e
commit 6f73e5087d
2 changed files with 17 additions and 6 deletions
+16 -2
View File
@@ -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(