AS AgentScopeAPI 手册 / API Reference

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
responseBuilderResponseBuilder响应构建器(类型 `ResponseBuilder`)。The response builder.
roleString角色(类型 `String`)。The role.
messageTypeString消息类型(类型 `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
contentTypeString内容类型(类型 `String`)。Content type ('text', 'image', 'data')
返回Returns ContentBuilder
返回ContentBuilder。Returns content builder.
源码Source io/agentscope/runtime/engine/helpers/ResponseBuilder.java:243–252

addContent

public void addContent(Content content)

添加内容。

Add content to message.

参数Parameters
名称Name类型Type说明Description
contentContent内容(类型 `Content`)。The content.
源码Source io/agentscope/runtime/engine/helpers/ResponseBuilder.java:257–281

getMessageData

public Message getMessageData()

获取消息数据。

Get dictionary representation of current message.

返回Returns Message
返回消息。Returns message.
源码Source io/agentscope/runtime/engine/helpers/ResponseBuilder.java:286–288

complete

public Message complete()

返回 complete 结果。

Complete message building.

返回Returns Message
返回消息。Returns message.
源码Source io/agentscope/runtime/engine/helpers/ResponseBuilder.java:293–298
基于官方固定版本源码静态生成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.