From 431e2fad72d17e2786fb6f5d0a43ff21c54a9a3b Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sun, 23 Feb 2025 16:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=94=AF=E6=8C=81=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=A6=81=E6=AD=A2=E9=BB=98=E8=AE=A4=E7=9A=84llm?= =?UTF-8?q?=E8=B0=83=E7=94=A8=20#579?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/pipeline/process_stage/stage.py | 2 +- astrbot/core/platform/astr_message_event.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/astrbot/core/pipeline/process_stage/stage.py b/astrbot/core/pipeline/process_stage/stage.py index f93be8108..c22ab4d92 100644 --- a/astrbot/core/pipeline/process_stage/stage.py +++ b/astrbot/core/pipeline/process_stage/stage.py @@ -45,7 +45,7 @@ class ProcessStage(Stage): if not self.ctx.astrbot_config['provider_settings'].get('enable', True): return - if not event._has_send_oper and event.is_at_or_wake_command: + if not event._has_send_oper and event.is_at_or_wake_command and not event.call_llm: # 是否有过发送操作 and 是否是被 @ 或者通过唤醒前缀 if (event.get_result() and not event.get_result().is_stopped()) or not event.get_result(): # 事件没有终止传播 diff --git a/astrbot/core/platform/astr_message_event.py b/astrbot/core/platform/astr_message_event.py index d650ba840..0500d0279 100644 --- a/astrbot/core/platform/astr_message_event.py +++ b/astrbot/core/platform/astr_message_event.py @@ -57,7 +57,8 @@ class AstrMessageEvent(abc.ABC): self._has_send_oper = False '''是否有过至少一次发送操作''' - + self.call_llm = False + '''是否在此消息事件中禁止默认的 LLM 请求''' # back_compability self.platform = platform_meta @@ -242,7 +243,15 @@ class AstrMessageEvent(abc.ABC): ''' if self._result is None: return False # 默认是继续传播 - return self._result.is_stopped() + return self._result.is_stopped() + + def should_call_llm(self, call_llm: bool): + ''' + 是否在此消息事件中禁止默认的 LLM 请求。 + + 只会阻止 AstrBot 默认的 LLM 请求链路,不会阻止插件中的 LLM 请求。 + ''' + self.call_llm = call_llm def get_result(self) -> MessageEventResult: '''