From 19ff0026c07bbd68bac2464484e9169925074460 Mon Sep 17 00:00:00 2001 From: FuQuan233 Date: Fri, 16 May 2025 21:43:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8Ddeque=20mutate?= =?UTF-8?q?d=20during=20iteration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_llmchat/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nonebot_plugin_llmchat/__init__.py b/nonebot_plugin_llmchat/__init__.py index 2fb78fb..c9dda84 100755 --- a/nonebot_plugin_llmchat/__init__.py +++ b/nonebot_plugin_llmchat/__init__.py @@ -313,8 +313,10 @@ async def process_messages(group_id: int): content: list[ChatCompletionContentPartParam] = [] # 将机器人错过的消息推送给LLM - for ev in state.past_events: - content.append({"type": "text", "text": format_message(ev)}) + past_events_snapshot = list(state.past_events) + for ev in past_events_snapshot: + text_content = ",".join([format_message(ev) for ev in past_events_snapshot]) + content.append({"type": "text", "text": text_content}) # 将消息中的图片转成 base64 if preset.support_image: