♻️ code format

This commit is contained in:
FuQuan233 2025-02-28 11:21:15 +08:00
parent 6db55055a2
commit e8db066647

View file

@ -272,7 +272,7 @@ async def process_messages(group_id: int):
# 请求成功后再保存历史记录保证user和assistant穿插防止R1模型报错 # 请求成功后再保存历史记录保证user和assistant穿插防止R1模型报错
state.history.append({"role": "user", "content": content}) state.history.append({"role": "user", "content": content})
# 添加助手回复到历史 # 添加助手回复到历史
state.history.append({"role": "assistant","content": reply}) state.history.append({"role": "assistant", "content": reply})
state.past_events.clear() state.past_events.clear()
if state.output_reasoning_content and reasoning_content: if state.output_reasoning_content and reasoning_content:
@ -285,7 +285,9 @@ async def process_messages(group_id: int):
), ),
) )
except Exception as e: except Exception as e:
await handler.send(f"合并转发消息发送失败:\n{e!s}\n"+reasoning_content) await handler.send(
f"合并转发消息发送失败:\n{e!s}\n" + reasoning_content
)
assert reply is not None assert reply is not None
logger.info( logger.info(
@ -369,6 +371,7 @@ async def handle_reset(event: GroupMessageEvent, args: Message = CommandArg()):
group_states[group_id].history.clear() group_states[group_id].history.clear()
await reset_handler.finish("记忆已清空") await reset_handler.finish("记忆已清空")
set_prob_handler = on_command( set_prob_handler = on_command(
"设置主动回复概率", "设置主动回复概率",
priority=99, priority=99,
@ -383,8 +386,8 @@ async def handle_set_prob(event: GroupMessageEvent, args: Message = CommandArg()
prob = 0 prob = 0
try: try:
prob=float(args.extract_plain_text().strip()) prob = float(args.extract_plain_text().strip())
if prob<0 or prob>1: if prob < 0 or prob > 1:
raise ValueError raise ValueError
except Exception as e: except Exception as e:
await reset_handler.finish(f"输入有误,请使用 [0,1] 的浮点数\n{e!s}") await reset_handler.finish(f"输入有误,请使用 [0,1] 的浮点数\n{e!s}")
@ -457,7 +460,10 @@ async def load_state():
state.last_active = state_data["last_active"] state.last_active = state_data["last_active"]
state.group_prompt = state_data["group_prompt"] state.group_prompt = state_data["group_prompt"]
state.output_reasoning_content = state_data["output_reasoning_content"] state.output_reasoning_content = state_data["output_reasoning_content"]
state.random_trigger_prob = (state_data.get("random_trigger_prob") or plugin_config.random_trigger_prob) state.random_trigger_prob = (
state_data.get("random_trigger_prob")
or plugin_config.random_trigger_prob
)
group_states[int(gid)] = state group_states[int(gid)] = state