AS AgentScopeAPI 手册 / API Reference

MessageContent

@JsonDeserialize(using = MessageContentDeserializer.class) @JsonSerialize(using = MessageContentSerializer.class) public sealed interface MessageContent permits MessageContent.Text, MessageContent.Blocks
源码Source io/agentscope/core/agui/model/MessageContent.java:45–72

定义消息内容契约的接口。位于 io.agentscope.core.agui.model 包。

Type-safe union representing the content field of an AG-UI message.

In the AG-UI protocol, message content can be either a plain string or an array of structured InputContent parts. This sealed interface models that union without resorting to Object, providing compile-time type safety and exhaustive pattern matching.

JSON forms:

  • Text → JSON string: "Hello"

  • Blocks → JSON array: [{"type":"text","text":"Hi"},{"type":"image",...}]

Custom Jackson serialization/deserialization handles the non-object JSON shape (scalar vs. array) via MessageContentDeserializer and MessageContentSerializer.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Text记录record
承载文本数据的记录类型。
Plain text content, serialized as a JSON string.
Blocks记录record
承载 Blocks数据的记录类型。
Structured content blocks, serialized as a JSON array of `InputContent`.

嵌套类详情Nested Class Detail

Text

record Text(String value) implements MessageContent

承载文本数据的记录类型。位于 io.agentscope.core.agui.model 包,实现 MessageContent。核心成员包括 value。

Plain text content, serialized as a JSON string.

Blocks

record Blocks(List<InputContent> parts) implements MessageContent

承载 Blocks数据的记录类型。位于 io.agentscope.core.agui.model 包,实现 MessageContent。核心成员包括 parts、Blocks。

Structured content blocks, serialized as a JSON array of InputContent.

基于官方固定版本源码静态生成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.