From 17564b5463792c887d375f8517da875a42ac49f7 Mon Sep 17 00:00:00 2001 From: FuQuan233 Date: Sat, 1 Mar 2025 21:57:27 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20error=20when=20the=20histo?= =?UTF-8?q?ry=5Fsize=20was=20set=20to=20an=20odd=20number?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_llmchat/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nonebot_plugin_llmchat/__init__.py b/nonebot_plugin_llmchat/__init__.py index d953d5c..6eb3df2 100644 --- a/nonebot_plugin_llmchat/__init__.py +++ b/nonebot_plugin_llmchat/__init__.py @@ -76,7 +76,7 @@ def pop_reasoning_content( class GroupState: def __init__(self): self.preset_name = plugin_config.default_preset - self.history = deque(maxlen=plugin_config.history_size) + self.history = deque(maxlen=plugin_config.history_size * 2) self.queue = asyncio.Queue() self.processing = False self.last_active = time.time() @@ -247,7 +247,7 @@ async def process_messages(group_id: int): {"role": "system", "content": systemPrompt} ] - messages += list(state.history)[-plugin_config.history_size :] + messages += list(state.history)[-plugin_config.history_size * 2 :] # 没有未处理的消息说明已经被处理了,跳过 if state.past_events.__len__() < 1: @@ -462,7 +462,7 @@ async def load_state(): state = GroupState() state.preset_name = state_data["preset"] state.history = deque( - state_data["history"], maxlen=plugin_config.history_size + state_data["history"], maxlen=plugin_config.history_size * 2 ) state.last_active = state_data["last_active"] state.group_prompt = state_data["group_prompt"]