ContentBuilder
public class ContentBuilder
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:305–541内容构建器,用于构建并配置目标实例。位于 io.agentscope.runtime.engine.helpers 包。核心成员包括 addTextDelta、setText、setImageUrl、setData、addDataDelta、complete。
Responsible for building and managing individual Content objects, supporting Text, Image, and Data content types.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public ContentBuilder(MessageBuilder messageBuilder, String contentType, int index) | 初始化 `ContentBuilder` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public TextContent addTextDelta(String text) | 添加文本增量。 Add text delta (only applicable to text type). |
public TextContent setText(String text) | 设置设置文本。 Set complete text content (only applicable to text type). |
public ImageContent setImageUrl(String imageUrl) | 设置设置图像 URL。 Set image URL (only applicable to image type). |
public DataContent setData(Map<String, Object> data) | 设置设置数据。 Set data content (only applicable to data type). |
public DataContent addDataDelta(Map<String, Object> deltaData) | 添加数据增量。 Add data delta (only applicable to data type). |
public Message complete() | 返回 `complete` 结果。 Complete content building. |
public Content getContentData() | 获取内容数据。 Get dictionary representation of current content. |
public TextContent addDelta(String text) | 添加增量。 Add text delta (backward compatibility method). |
构造器详情Constructor Detail
ContentBuilder
public ContentBuilder(MessageBuilder messageBuilder, String contentType, int index)
初始化 ContentBuilder 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messageBuilder | MessageBuilder | 消息构建器(类型 `MessageBuilder`)。The message builder. |
contentType | String | 内容类型(类型 `String`)。The content type. |
index | int | 索引(类型 `int`)。The index. |
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:313–337方法详情Method Detail
addTextDelta
public TextContent addTextDelta(String text)
添加文本增量。
Add text delta (only applicable to text type).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text. |
TextContent返回TextContent。Returns text content.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:342–359setText
public TextContent setText(String text)
设置设置文本。
Set complete text content (only applicable to text type).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text. |
TextContent返回TextContent。Returns text content.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:364–374setImageUrl
public ImageContent setImageUrl(String imageUrl)
设置设置图像 URL。
Set image URL (only applicable to image type).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
imageUrl | String | 图像 URL(类型 `String`)。The image url. |
ImageContent返回ImageContent。Returns image content.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:379–389setData
public DataContent setData(Map<String, Object> data)
设置设置数据。
Set data content (only applicable to data type).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
data | Map<String, Object> | 数据(类型 `Map`)。The data. |
DataContent返回DataContent。Returns data content.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:394–404addDataDelta
public DataContent addDataDelta(Map<String, Object> deltaData)
添加数据增量。
Add data delta (only applicable to data type).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
deltaData | Map<String, Object> | 增量数据(类型 `Map`)。The delta data. |
DataContent返回DataContent。Returns data content.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:409–426complete
public Message complete()
返回 complete 结果。
Complete content building.
Message返回消息。Returns message.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:431–467getContentData
public Content getContentData()
获取内容数据。
Get dictionary representation of current content.
Content返回内容。Returns content.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:531–533addDelta
public TextContent addDelta(String text)
添加增量。
Add text delta (backward compatibility method).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text. |
TextContent返回TextContent。Returns text content.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:538–540