AS AgentScopeAPI 手册 / API Reference

ChannelMediaMetadata

public final class ChannelMediaMetadata
源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:37–153

渠道 Media 元数据,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.extensions.channel.common 包。核心成员包括 markerText、putIfPresent、KIND_IMAGE、KIND_AUDIO、KIND_VIDEO、KIND_FILE。

Metadata key contract for inbound media (image / audio / video / file) messages surfaced by channel inbound mappers.

Channel adapters deliberately do not decode provider media into content blocks: material identifiers (media_id / image_key / file_key / downloadCode) are not URLs and can only be exchanged for bytes through a token-authenticated download whose artifacts are short-lived. Deciding whether and when to fetch, where to buffer, and how to degrade is application policy. Mappers therefore surface a media event as a user Msg whose text content is a neutral marker (#markerText(String, String)) and whose metadata carries the keys defined here, so the application can observe the event, download the material through its own path, or reply with guidance.

All values are strings. Keys absent on a given platform are omitted; readers must treat the metadata as a sparse map and never assume a key's presence.

字段摘要Field Summary

字段Field类型Type说明Description
KIND_IMAGE
staticfinal
String
种类图像字段。
Normalized media kind: image (photo / picture).
KIND_AUDIO
staticfinal
String
种类音频字段。
Normalized media kind: audio (voice message).
KIND_VIDEO
staticfinal
String
种类视频字段。
Normalized media kind: video, including video-bearing composite messages.
KIND_FILE
staticfinal
String
种类文件字段。
Normalized media kind: generic file attachment.
KIND
staticfinal
String
种类字段。
Normalized media kind — one of `image`, `audio`, `video`, `file`.
PROVIDER_TYPE
staticfinal
String
提供者类型字段。
Original provider type token, verbatim (WeCom `MsgType`, Feishu ` message_type`, DingTalk `msgtype`) — e.g.
ID
staticfinal
String
标识字段。
Primary provider material identifier (`MediaId` / `image_key` / ` file_key` / `downloadCode`), verbatim.
SECONDARY_ID
staticfinal
String
SECONDARY 标识字段。
Secondary material identifier when the platform provides one (thumbnail / cover image / picture-specific download code).
URL
staticfinal
String
URL字段。
Directly fetchable URL when the platform provides one alongside the material id (WeCom image `PicUrl`).
FILE_NAME
staticfinal
String
文件名称字段。
File name, when the platform reports one.
FORMAT
staticfinal
String
格式字段。
Container / format token (WeCom voice `Format`, DingTalk video `videoType`).
DURATION_MS
staticfinal
String
时长 MS字段。
Playback duration in milliseconds, as reported by the platform (Feishu and DingTalk both document the field in milliseconds for audio and video messages).
RECOGNITION
staticfinal
String
RECOGNITION字段。
Platform speech-to-text result for audio messages, when the platform provides one.

方法摘要Method Summary

方法Method说明Description
public static String markerText(String kind, String fileName)
static
执行 `markerText` 方法。
Returns the neutral marker text used as the `Msg` text content of a mapped media message: `"[image]"`, `"[audio]"`, `"[video]"`, or ` "[file: report.pdf]"` when a file name is available.
public static void putIfPresent(Map<String, Object> metadata, String key, String value)
static
执行 `putIfPresent` 方法。
Puts `value` under `key` only when `value` is neither `null` nor blank; a null/blank value is silently skipped.

字段详情Field Detail

KIND_IMAGE

public static final String KIND_IMAGE
staticfinal

种类图像字段。声明为 public static final String KIND_IMAGE。

Normalized media kind: image (photo / picture).

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:44

KIND_AUDIO

public static final String KIND_AUDIO
staticfinal

种类音频字段。声明为 public static final String KIND_AUDIO。

Normalized media kind: audio (voice message).

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:47

KIND_VIDEO

public static final String KIND_VIDEO
staticfinal

种类视频字段。声明为 public static final String KIND_VIDEO。

Normalized media kind: video, including video-bearing composite messages.

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:50

KIND_FILE

public static final String KIND_FILE
staticfinal

种类文件字段。声明为 public static final String KIND_FILE。

Normalized media kind: generic file attachment.

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:53

KIND

public static final String KIND
staticfinal

种类字段。声明为 public static final String KIND。

Normalized media kind — one of image, audio, video, file.

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:56

PROVIDER_TYPE

public static final String PROVIDER_TYPE
staticfinal

提供者类型字段。声明为 public static final String PROVIDER_TYPE。

Original provider type token, verbatim (WeCom MsgType, Feishu message_type, DingTalk msgtype) — e.g.

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:61

ID

public static final String ID
staticfinal

标识字段。声明为 public static final String ID。

Primary provider material identifier (MediaId / image_key / file_key / downloadCode), verbatim.

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:65

SECONDARY_ID

public static final String SECONDARY_ID
staticfinal

SECONDARY 标识字段。声明为 public static final String SECONDARY_ID。

Secondary material identifier when the platform provides one (thumbnail / cover image / picture-specific download code).

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:69

URL

public static final String URL
staticfinal

URL字段。声明为 public static final String URL。

Directly fetchable URL when the platform provides one alongside the material id (WeCom image PicUrl).

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:73

FILE_NAME

public static final String FILE_NAME
staticfinal

文件名称字段。声明为 public static final String FILE_NAME。

File name, when the platform reports one.

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:76

FORMAT

public static final String FORMAT
staticfinal

格式字段。声明为 public static final String FORMAT。

Container / format token (WeCom voice Format, DingTalk video videoType).

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:79

DURATION_MS

public static final String DURATION_MS
staticfinal

时长 MS字段。声明为 public static final String DURATION_MS。

Playback duration in milliseconds, as reported by the platform (Feishu and DingTalk both document the field in milliseconds for audio and video messages).

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:83

RECOGNITION

public static final String RECOGNITION
staticfinal

RECOGNITION字段。声明为 public static final String RECOGNITION。

Platform speech-to-text result for audio messages, when the platform provides one.

源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:86

方法详情Method Detail

markerText

public static String markerText(String kind, String fileName)
static

执行 markerText 方法。

Returns the neutral marker text used as the Msg text content of a mapped media message: "[image]", "[audio]", "[video]", or "[file: report.pdf]" when a file name is available.

参数Parameters
名称Name类型Type说明Description
kindString种类(类型 `String`)。normalized media kind, as in `#KIND`
fileNameString文件名称(类型 `String`)。optional file name; a sanitized copy is embedded when non-blank
返回Returns String
返回字符串结果。Returns a string.
抛出Throws
  • NullPointerException 可能抛出 `NullPointerException`。if `kind` is `null`
源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:105–115

putIfPresent

public static void putIfPresent(Map<String, Object> metadata, String key, String value)
static

执行 putIfPresent 方法。

Puts value under key only when value is neither null nor blank; a null/blank value is silently skipped.

参数Parameters
名称Name类型Type说明Description
metadataMap<String, Object>元数据(类型 `Map`)。The metadata.
keyString键(类型 `String`)。The key.
valueString值(类型 `String`)。The value.
抛出Throws
  • NullPointerException 当if`metadata`或`key`是`null`时抛出 `NullPointerException`。if `metadata` or `key` is `null`
源码Source io/agentscope/extensions/channel/common/ChannelMediaMetadata.java:146–152
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.