Skip to content

Commit d28f359

Browse files
committed
fix(ltm): preserve contexts when unique_session is enabled
1 parent a4d073b commit d28f359

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

astrbot/builtin_stars/astrbot/long_term_memory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ async def on_req_llm(self, event: AstrMessageEvent, req: ProviderRequest) -> Non
156156
chats_str = "\n---\n".join(self.session_chats[event.unified_msg_origin])
157157

158158
cfg = self.cfg(event)
159+
unique_session = cfg.get("platform_settings", {}).get("unique_session", False)
159160
if cfg["enable_active_reply"]:
160161
prompt = req.prompt
161162
req.prompt = (
@@ -164,7 +165,8 @@ async def on_req_llm(self, event: AstrMessageEvent, req: ProviderRequest) -> Non
164165
"Please react to it. Only output your response and do not output any other information. "
165166
"You MUST use the SAME language as the chatroom is using."
166167
)
167-
req.contexts = [] # 清空上下文,当使用了主动回复,所有聊天记录都在一个prompt中。
168+
if not unique_session:
169+
req.contexts = [] # 清空上下文,当使用了主动回复,所有聊天记录都在一个prompt中。
168170
else:
169171
req.system_prompt += (
170172
"You are now in a chatroom. The chat history is as follows: \n"

0 commit comments

Comments
 (0)