event重构暂时完成,待测试

This commit is contained in:
Windpicker-owo
2025-08-25 17:46:23 +08:00
parent 902a031a9d
commit 5d1390d546
10 changed files with 78 additions and 299 deletions

View File

@@ -339,14 +339,13 @@ class DefaultReplyer:
if not prompt:
logger.warning("构建prompt失败跳过回复生成")
return False, None, None, []
from src.plugin_system.core.events_manager import events_manager
return False, None, None
from src.plugin_system.core.event_manager import event_manager
if not from_plugin:
if not await events_manager.handle_mai_events(
EventType.POST_LLM, None, prompt, None, stream_id=stream_id
):
raise UserWarning("插件于请求前中断了内容生成")
result = await event_manager.trigger_event(EventType.POST_LLM,prompt=prompt,llm_response=llm_response,stream_id=stream_id)
if not result.all_continue_process():
raise UserWarning(f"插件{result.get_summary().get('stopped_handlers', '')}于请求前中断了内容生成")
# 4. 调用 LLM 生成回复
content = None
@@ -362,10 +361,11 @@ class DefaultReplyer:
"model": model_name,
"tool_calls": tool_call,
}
if not from_plugin and not await events_manager.handle_mai_events(
EventType.AFTER_LLM, None, prompt, llm_response, stream_id=stream_id
):
raise UserWarning("插件于请求后取消了内容生成")
# 触发 AFTER_LLM 事件
if not from_plugin:
result = await event_manager.trigger_event(EventType.AFTER_LLM,prompt=prompt,llm_response=llm_response,stream_id=stream_id)
if not result.all_continue_process():
raise UserWarning(f"插件{result.get_summary().get("stopped_handlers","")}于请求后取消了内容生成")
except UserWarning as e:
raise e
except Exception as llm_e: