Skip to content

imProxyAgentContent

将 IM 消息转为智能体 LLM 用户内容(文本或多模态 AgentInputContentPart[])。

函数签名

typescript
function imMessageToAgentUserContent(
  m: ImMessage,
  format: AiAttachmentPayloadFormat,
  recipientUserId: string,
): string | AgentInputContentPart[]

function agentUserContentCharEstimate(
  c: string | AgentInputContentPart[],
): number

function imPersistedMessageTypeForReplyFormat(
  format: AiAgentReplyFormat,
): 'markdown' | 'text'

工作原理

  1. 无附件时返回规范化纯文本。
  2. format === 'openai' 时图片/视频/文件映射为 OpenAI 风格 content part。
  3. format === 'ag_ui' 时使用 binary part。
  4. 仅单段 text 时折叠为 string。