diff --git a/pkg/pipeline/process/handlers/chat.py b/pkg/pipeline/process/handlers/chat.py index b6da5fa6..6e133cc9 100644 --- a/pkg/pipeline/process/handlers/chat.py +++ b/pkg/pipeline/process/handlers/chat.py @@ -9,7 +9,6 @@ from .. import handler from ... import entities from ....provider import runner as runner_module -import langbot_plugin.api.entities.builtin.platform.message as platform_message import langbot_plugin.api.entities.events as events from ....utils import importutil from ....provider import runners @@ -47,18 +46,19 @@ class ChatMessageHandler(handler.MessageHandler): event_ctx = await self.ap.plugin_connector.emit_event(event) is_create_card = False # 判断下是否需要创建流式卡片 + if event_ctx.is_prevented_default(): - if event_ctx.event.reply is not None: - mc = platform_message.MessageChain(event_ctx.event.reply) + if event_ctx.event.reply_message_chain is not None: + mc = event_ctx.event.reply_message_chain query.resp_messages.append(mc) yield entities.StageProcessResult(result_type=entities.ResultType.CONTINUE, new_query=query) else: yield entities.StageProcessResult(result_type=entities.ResultType.INTERRUPT, new_query=query) else: - if event_ctx.event.alter is not None: + if event_ctx.event.user_message_alter is not None: # if isinstance(event_ctx.event, str): # 现在暂时不考虑多模态alter - query.user_message.content = event_ctx.event.alter + query.user_message.content = event_ctx.event.user_message_alter text_length = 0 try: diff --git a/pkg/pipeline/process/handlers/command.py b/pkg/pipeline/process/handlers/command.py index 382838f8..52bcdb6f 100644 --- a/pkg/pipeline/process/handlers/command.py +++ b/pkg/pipeline/process/handlers/command.py @@ -5,7 +5,6 @@ import typing from .. import handler from ... import entities import langbot_plugin.api.entities.builtin.provider.message as provider_message -import langbot_plugin.api.entities.builtin.platform.message as platform_message import langbot_plugin.api.entities.builtin.provider.session as provider_session import langbot_plugin.api.entities.builtin.pipeline.query as pipeline_query import langbot_plugin.api.entities.events as events @@ -49,8 +48,8 @@ class CommandHandler(handler.MessageHandler): event_ctx = await self.ap.plugin_connector.emit_event(event) if event_ctx.is_prevented_default(): - if event_ctx.event.reply is not None: - mc = platform_message.MessageChain(event_ctx.event.reply) + if event_ctx.event.reply_message_chain is not None: + mc = event_ctx.event.reply_message_chain query.resp_messages.append(mc) @@ -59,11 +58,6 @@ class CommandHandler(handler.MessageHandler): yield entities.StageProcessResult(result_type=entities.ResultType.INTERRUPT, new_query=query) else: - if event_ctx.event.alter is not None: - query.message_chain = platform_message.MessageChain( - [platform_message.Plain(text=event_ctx.event.alter)] - ) - session = await self.ap.sess_mgr.get_session(query) async for ret in self.ap.cmd_mgr.execute( @@ -80,8 +74,12 @@ class CommandHandler(handler.MessageHandler): self.ap.logger.info(f'Command({query.query_id}) error: {self.cut_str(str(ret.error))}') yield entities.StageProcessResult(result_type=entities.ResultType.CONTINUE, new_query=query) - elif (ret.text is not None or ret.image_url is not None or ret.image_base64 is not None - or ret.file_url is not None): + elif ( + ret.text is not None + or ret.image_url is not None + or ret.image_base64 is not None + or ret.file_url is not None + ): content: list[provider_message.ContentElement] = [] if ret.text is not None: diff --git a/pkg/pipeline/wrapper/wrapper.py b/pkg/pipeline/wrapper/wrapper.py index 439595e9..6267c864 100644 --- a/pkg/pipeline/wrapper/wrapper.py +++ b/pkg/pipeline/wrapper/wrapper.py @@ -80,8 +80,8 @@ class ResponseWrapper(stage.PipelineStage): new_query=query, ) else: - if event_ctx.event.reply is not None: - query.resp_message_chain.append(platform_message.MessageChain(event_ctx.event.reply)) + if event_ctx.event.reply_message_chain is not None: + query.resp_message_chain.append(event_ctx.event.reply_message_chain) else: query.resp_message_chain.append(result.get_content_platform_message_chain()) @@ -123,10 +123,8 @@ class ResponseWrapper(stage.PipelineStage): new_query=query, ) else: - if event_ctx.event.reply is not None: - query.resp_message_chain.append( - platform_message.MessageChain(text=event_ctx.event.reply) - ) + if event_ctx.event.reply_message_chain is not None: + query.resp_message_chain.append(event_ctx.event.reply_message_chain) else: query.resp_message_chain.append(