From db9794a18aa4e42851c5a4aff7d5db03fa19e1d2 Mon Sep 17 00:00:00 2001 From: FuQuan233 Date: Mon, 28 Apr 2025 20:19:47 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=87=BA=E7=8E=B0=E9=A6=96=E6=9D=A1=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=B8=8D=E4=B8=BAuser=E6=B6=88=E6=81=AF=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_llmchat/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nonebot_plugin_llmchat/__init__.py b/nonebot_plugin_llmchat/__init__.py index 879953a..15f9e7a 100644 --- a/nonebot_plugin_llmchat/__init__.py +++ b/nonebot_plugin_llmchat/__init__.py @@ -252,6 +252,9 @@ async def process_messages(group_id: int): {"role": "system", "content": systemPrompt} ] + while len(state.history) > 0 and state.history[0]["role"] != "user": + state.history.popleft() + messages += list(state.history)[-plugin_config.history_size * 2 :] # 没有未处理的消息说明已经被处理了,跳过