34 lines
1.1 KiB
Python
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}
|