ForcePilot/backend/package/yuxi/channel/extensions/alipay/streaming.py
Kris 71364ea579 feat(alipay): 新增支付宝渠道插件完整实现
实现了支付宝生活号渠道的完整功能,包括消息接收回调、发送、安全验证、去重、配对绑定、流式回复支持等完整能力。
2026-05-21 10:39:23 +08:00

34 lines
1.1 KiB
Python

from yuxi.channel.extensions.alipay.constants import (
ALIPAY_BLOCK_STREAMING_CHUNK_MAX_CHARS,
ALIPAY_BLOCK_STREAMING_CHUNK_MIN_CHARS,
)
class AlipayStreaming:
streaming_mode = "block"
preview_stream_throttle_ms = 160
preview_min_initial_chars = 18
block_streaming_enabled = True
block_streaming_break = "double_newline"
block_streaming_chunk_min_chars = ALIPAY_BLOCK_STREAMING_CHUNK_MIN_CHARS
block_streaming_chunk_max_chars = ALIPAY_BLOCK_STREAMING_CHUNK_MAX_CHARS
block_streaming_chunk_break_preference = "double_newline_second_paragraph"
block_streaming_coalesce_defaults = {
"mintime": 1.2,
"maxtime": 3.5,
}
ENABLED = True
STRATEGY = "block"
MIN_CHARS = ALIPAY_BLOCK_STREAMING_CHUNK_MIN_CHARS
MAX_INTERVAL_MS = 1000
MAX_BLOCKS = 20
FINISH_MARK = ""
def create_draft_stream_session(self, target_id: str) -> dict:
return {"target_id": target_id, "mode": "block"}
def create_block_chunker(self) -> dict:
return {"mode": "length", "min_chars": 50, "max_chars": 500}