实现了 GitLab 全功能集成,包含 Webhook 处理、API 客户端、消息收发、会话管理、安全校验、限流器等完整模块,支持 Issues、Merge Requests、流水线等事件监听与交互。
30 lines
856 B
Python
30 lines
856 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class GitLabStreaming:
|
|
streaming_mode = "block"
|
|
block_streaming_enabled = True
|
|
block_streaming_break = "text_end"
|
|
block_streaming_chunk_min_chars = 800
|
|
block_streaming_chunk_max_chars = 4000
|
|
block_streaming_chunk_break_preference = "paragraph"
|
|
block_streaming_coalesce_defaults = {
|
|
"min_chars": 400,
|
|
"max_chars": 2000,
|
|
"idle_ms": 1000,
|
|
}
|
|
|
|
def create_draft_stream_session(self, target_id: str) -> dict:
|
|
return {"target_id": target_id, "mode": "block", "chunks_sent": 0}
|
|
|
|
def create_block_chunker(self) -> dict:
|
|
return {
|
|
"mode": "length",
|
|
"min_chars": self.block_streaming_chunk_min_chars,
|
|
"max_chars": self.block_streaming_chunk_max_chars,
|
|
}
|