diff --git a/pkg/pipeline/longtext/longtext.py b/pkg/pipeline/longtext/longtext.py index 4b461bd6..47f00843 100644 --- a/pkg/pipeline/longtext/longtext.py +++ b/pkg/pipeline/longtext/longtext.py @@ -21,10 +21,15 @@ class LongTextProcessStage(stage.PipelineStage): - resp_message_chain """ - strategy_impl: strategy.LongTextStrategy + strategy_impl: strategy.LongTextStrategy | None async def initialize(self, pipeline_config: dict): config = pipeline_config['output']['long-text-processing'] + + if config['strategy'] == 'none': + self.strategy_impl = None + return + if config['strategy'] == 'image': use_font = config['font-path'] try: @@ -67,6 +72,10 @@ class LongTextProcessStage(stage.PipelineStage): await self.strategy_impl.initialize() async def process(self, query: pipeline_query.Query, stage_inst_name: str) -> entities.StageProcessResult: + if self.strategy_impl is None: + self.ap.logger.debug('Long message processing strategy is not set, skip long message processing.') + return entities.StageProcessResult(result_type=entities.ResultType.CONTINUE, new_query=query) + # 检查是否包含非 Plain 组件 contains_non_plain = False diff --git a/pkg/pipeline/longtext/strategies/forward.py b/pkg/pipeline/longtext/strategies/forward.py index 201622ce..1553ea25 100644 --- a/pkg/pipeline/longtext/strategies/forward.py +++ b/pkg/pipeline/longtext/strategies/forward.py @@ -26,7 +26,7 @@ class ForwardComponentStrategy(strategy_model.LongTextStrategy): platform_message.ForwardMessageNode( sender_id=query.adapter.bot_account_id, sender_name='User', - message_chain=platform_message.MessageChain([message]), + message_chain=platform_message.MessageChain([platform_message.Plain(text=message)]), ) ] diff --git a/templates/default-pipeline-config.json b/templates/default-pipeline-config.json index f7801a47..c5398e76 100644 --- a/templates/default-pipeline-config.json +++ b/templates/default-pipeline-config.json @@ -83,7 +83,7 @@ "output": { "long-text-processing": { "threshold": 1000, - "strategy": "forward", + "strategy": "none", "font-path": "" }, "force-delay": { diff --git a/templates/metadata/pipeline/output.yaml b/templates/metadata/pipeline/output.yaml index 8d571e91..1978dea4 100644 --- a/templates/metadata/pipeline/output.yaml +++ b/templates/metadata/pipeline/output.yaml @@ -27,7 +27,7 @@ stages: zh_Hans: 长文本的处理策略 type: select required: true - default: forward + default: none options: - name: forward label: @@ -37,6 +37,10 @@ stages: label: en_US: Convert to Image zh_Hans: 转换为图片 + - name: none + label: + en_US: None + zh_Hans: 不处理 - name: font-path label: en_US: Font Path