from __future__ import annotations import json from typing import Any def format_outbound( content: str, chat_type: str = "direct", metadata: dict[str, Any] | None = None, ) -> dict[str, Any]: meta = metadata or {} msg_key = "sampleText" msg_param: dict[str, Any] = {"content": content} if meta.get("use_markdown"): msg_key = "sampleMarkdown" msg_param = { "title": meta.get("title", "ForcePilot"), "text": content, } if meta.get("msg_key"): msg_key = meta["msg_key"] if meta.get("msg_param"): msg_param = meta["msg_param"] result: dict[str, Any] = { "msgKey": msg_key, "msgParam": json.dumps(msg_param, ensure_ascii=False), } if meta.get("openConversationId"): result["openConversationId"] = meta["openConversationId"] if meta.get("robotCode"): result["robotCode"] = meta["robotCode"] return result