mirror of
https://github.com/FuQuan233/nonebot-plugin-llmchat.git
synced 2025-09-04 10:20:45 +00:00
🐛 fix error when the history_size was set to an odd number
This commit is contained in:
parent
7408f90b3c
commit
17564b5463
1 changed files with 3 additions and 3 deletions
|
@ -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"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue