MessageBuilder
public class MessageBuilder
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:216–299消息构建器,用于构建并配置目标实例。位于 io.agentscope.runtime.engine.helpers 包。核心成员包括 createContentBuilder、addContent、getMessageData、complete、MessageBuilder。
Responsible for building and managing individual Message objects and updating associated Response.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public MessageBuilder(ResponseBuilder responseBuilder, String role, String messageType) | 初始化 `MessageBuilder` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public ContentBuilder createContentBuilder(String contentType) | 创建内容构建器。 Create Content Builder. |
public void addContent(Content content) | 添加内容。 Add content to message. |
public Message getMessageData() | 获取消息数据。 Get dictionary representation of current message. |
public Message complete() | 返回 `complete` 结果。 Complete message building. |
构造器详情Constructor Detail
MessageBuilder
public MessageBuilder(ResponseBuilder responseBuilder, String role, String messageType)
初始化 MessageBuilder 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
responseBuilder | ResponseBuilder | 响应构建器(类型 `ResponseBuilder`)。The response builder. |
role | String | 角色(类型 `String`)。The role. |
messageType | String | 消息类型(类型 `String`)。The message type. |
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:223–236方法详情Method Detail
createContentBuilder
public ContentBuilder createContentBuilder(String contentType)
创建内容构建器。
Create Content Builder.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
contentType | String | 内容类型(类型 `String`)。Content type ('text', 'image', 'data') |
ContentBuilder返回ContentBuilder。Returns content builder.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:243–252addContent
public void addContent(Content content)
添加内容。
Add content to message.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
content | Content | 内容(类型 `Content`)。The content. |
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:257–281getMessageData
public Message getMessageData()
获取消息数据。
Get dictionary representation of current message.
Message返回消息。Returns message.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:286–288complete
public Message complete()
返回 complete 结果。
Complete message building.
Message返回消息。Returns message.
源码Source
io/agentscope/runtime/engine/helpers/ResponseBuilder.java:293–298