新增飞书机器人适配器全套功能,包括: - 基础适配器入口与工具导出 - 消息格式化、卡片渲染、回复调度逻辑 - 会话ID生成、模型覆盖策略 - 消息发送缓存、顺序队列管理 - 飞书签名验证、加解密webhook请求 - 审批权限校验、机器人菜单事件处理 - 文档评论、钉消息、语音转码处理 - 静态/动态目录管理、子代理生命周期管理 - 各类工具集:聊天、云盘、文档、知识库API封装
24 lines
670 B
Python
24 lines
670 B
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from .cards import is_post_format_requested
|
|
|
|
|
|
def format_outbound(
|
|
content: str,
|
|
chat_type: str = "private",
|
|
metadata: dict[str, Any] | None = None,
|
|
) -> dict[str, Any]:
|
|
meta = metadata or {}
|
|
return {
|
|
"content": content,
|
|
"chat_type": chat_type,
|
|
"thread_id": meta.get("thread_id"),
|
|
"buttons": meta.get("buttons", []),
|
|
"url_unfurl": meta.get("url_unfurl"),
|
|
"template": meta.get("template", meta.get("card_template")),
|
|
"tone": meta.get("tone", meta.get("card_tone")),
|
|
"use_post_format": is_post_format_requested(metadata),
|
|
}
|