新增了完整的Confluence集成插件,包含以下核心功能: 1. 基础认证与配置管理,支持API Token和OAuth2两种认证方式 2. 评论去重、权限控制与提及解析 3. 知识库检索与页面内容处理 4. 评论收发、编辑删除与流式回复支持 5. 附件与页面标签管理 6. 内容属性存储与AI元数据管理 7. Webhook事件接收与处理 8. 完整的插件配置与状态检查
30 lines
801 B
Python
30 lines
801 B
Python
class ConfluenceStreaming:
|
|
streaming_mode = "block"
|
|
block_streaming_enabled = True
|
|
MIN_CHARS = 200
|
|
MAX_CHARS = 2000
|
|
CHUNK_BREAK = "paragraph"
|
|
COALESCE_MIN = 80
|
|
COALESCE_MAX = 400
|
|
COALESCE_IDLE_MS = 500
|
|
MAX_BLOCKS = 5
|
|
FINISH_MARK = "..."
|
|
|
|
@classmethod
|
|
def should_stream(cls, estimated_length: int) -> bool:
|
|
return estimated_length > cls.MIN_CHARS
|
|
|
|
@classmethod
|
|
def build_chunk(cls, text: str, is_final: bool) -> str:
|
|
if is_final:
|
|
return text
|
|
return f"{text}\n\n{cls.FINISH_MARK}"
|
|
|
|
@classmethod
|
|
def create_chunker(cls):
|
|
return {
|
|
"mode": "paragraph",
|
|
"min_chars": cls.COALESCE_MIN,
|
|
"max_chars": cls.MAX_CHARS,
|
|
"break_on": cls.CHUNK_BREAK,
|
|
} |