mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-22 12:26:08 +00:00
perf: disable long message processing as default (#1670)
This commit is contained in:
committed by
GitHub
parent
1a13a41168
commit
c8ffc79077
@@ -21,10 +21,15 @@ class LongTextProcessStage(stage.PipelineStage):
|
|||||||
- resp_message_chain
|
- resp_message_chain
|
||||||
"""
|
"""
|
||||||
|
|
||||||
strategy_impl: strategy.LongTextStrategy
|
strategy_impl: strategy.LongTextStrategy | None
|
||||||
|
|
||||||
async def initialize(self, pipeline_config: dict):
|
async def initialize(self, pipeline_config: dict):
|
||||||
config = pipeline_config['output']['long-text-processing']
|
config = pipeline_config['output']['long-text-processing']
|
||||||
|
|
||||||
|
if config['strategy'] == 'none':
|
||||||
|
self.strategy_impl = None
|
||||||
|
return
|
||||||
|
|
||||||
if config['strategy'] == 'image':
|
if config['strategy'] == 'image':
|
||||||
use_font = config['font-path']
|
use_font = config['font-path']
|
||||||
try:
|
try:
|
||||||
@@ -67,6 +72,10 @@ class LongTextProcessStage(stage.PipelineStage):
|
|||||||
await self.strategy_impl.initialize()
|
await self.strategy_impl.initialize()
|
||||||
|
|
||||||
async def process(self, query: pipeline_query.Query, stage_inst_name: str) -> entities.StageProcessResult:
|
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 组件
|
# 检查是否包含非 Plain 组件
|
||||||
contains_non_plain = False
|
contains_non_plain = False
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class ForwardComponentStrategy(strategy_model.LongTextStrategy):
|
|||||||
platform_message.ForwardMessageNode(
|
platform_message.ForwardMessageNode(
|
||||||
sender_id=query.adapter.bot_account_id,
|
sender_id=query.adapter.bot_account_id,
|
||||||
sender_name='User',
|
sender_name='User',
|
||||||
message_chain=platform_message.MessageChain([message]),
|
message_chain=platform_message.MessageChain([platform_message.Plain(text=message)]),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
"output": {
|
"output": {
|
||||||
"long-text-processing": {
|
"long-text-processing": {
|
||||||
"threshold": 1000,
|
"threshold": 1000,
|
||||||
"strategy": "forward",
|
"strategy": "none",
|
||||||
"font-path": ""
|
"font-path": ""
|
||||||
},
|
},
|
||||||
"force-delay": {
|
"force-delay": {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ stages:
|
|||||||
zh_Hans: 长文本的处理策略
|
zh_Hans: 长文本的处理策略
|
||||||
type: select
|
type: select
|
||||||
required: true
|
required: true
|
||||||
default: forward
|
default: none
|
||||||
options:
|
options:
|
||||||
- name: forward
|
- name: forward
|
||||||
label:
|
label:
|
||||||
@@ -37,6 +37,10 @@ stages:
|
|||||||
label:
|
label:
|
||||||
en_US: Convert to Image
|
en_US: Convert to Image
|
||||||
zh_Hans: 转换为图片
|
zh_Hans: 转换为图片
|
||||||
|
- name: none
|
||||||
|
label:
|
||||||
|
en_US: None
|
||||||
|
zh_Hans: 不处理
|
||||||
- name: font-path
|
- name: font-path
|
||||||
label:
|
label:
|
||||||
en_US: Font Path
|
en_US: Font Path
|
||||||
|
|||||||
Reference in New Issue
Block a user