AS AgentScopeAPI 手册 / API Reference

ContentBlock

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = TextBlock.class, name = "text"), @JsonSubTypes.Type(value = ThinkingBlock.class, name = "thinking"), @JsonSubTypes.Type(value = ImageBlock.class, name = "image"), @JsonSubTypes.Type(value = AudioBlock.class, name = "audio"), @JsonSubTypes.Type(value = VideoBlock.class, name = "video"), @JsonSubTypes.Type(value = ToolUseBlock.class, name = "tool_use"), @JsonSubTypes.Type(value = ToolResultBlock.class, name = "tool_result"), @JsonSubTypes.Type(value = HintBlock.class, name = "hint"), @JsonSubTypes.Type(value = DataBlock.class, name = "data") }) public sealed class ContentBlock implements State permits TextBlock, ImageBlock, AudioBlock, VideoBlock, ThinkingBlock, ToolUseBlock, ToolResultBlock, HintBlock, DataBlock
源码Source io/agentscope/core/message/ContentBlock.java:46–67

内容块,在智能体、模型与前端之间传递结构化消息和事件。位于 io.agentscope.core.message 包,实现 State。

Base sealed class for all content blocks in messages.

Content blocks represent different types of content that can be included in a message, such as text, images, audio, video, or thinking content. This sealed hierarchy ensures type safety and enables exhaustive pattern matching.

Supported Content Types:

  • TextBlock - Plain text content

  • ThinkingBlock - Agent reasoning/thinking content

  • ImageBlock - Image content (URL or Base64)

  • AudioBlock - Audio content (URL or Base64)

  • VideoBlock - Video content (URL or Base64)

  • ToolUseBlock - Tool execution requests

  • ToolResultBlock - Tool execution results

  • HintBlock - Hints for LLM reasoning (e.g., from RAG)

  • DataBlock - Generic binary data block unifying image/audio/video

Uses Jackson annotations for polymorphic JSON serialization with the "type" discriminator field. The sealed modifier restricts subclasses to the specified permits list, enabling compile-time exhaustiveness checking in pattern matching.

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