AS AgentScopeAPI 手册 / API Reference

TextAccumulator

public class TextAccumulator implements ContentAccumulator<TextBlock>
源码Source io/agentscope/core/agent/accumulator/TextAccumulator.java:27–89

文本 Accumulator,驱动智能体的推理、工具调用与会话执行。位于 io.agentscope.core.agent.accumulator 包,实现 ContentAccumulator<TextBlock>。核心成员包括 add、hasContent、buildAggregated、reset、getAccumulated、replace。

Text content accumulator for accumulating streaming text chunks.

This accumulator concatenates all text chunks in order to build the complete text content.

方法摘要Method Summary

方法Method说明Description
public void add(TextBlock block)
设置添加。
Performs the add operation.
public boolean hasContent()
判断是否具有内容。
Returns whether this has the content.
public ContentBlock buildAggregated()
构建 `buildAggregated`。
Builds the aggregated.
public void reset()
清空或重置内部状态。
Clears or resets internal state.
public String getAccumulated()
获取 `getAccumulated`。
Get the accumulated text content.
public void replace(String text)
设置该参数。
Replace the accumulated text with content reconstructed from the model-call event stream.

方法详情Method Detail

add

public void add(TextBlock block)

设置添加。

Performs the add operation.

参数Parameters
名称Name类型Type说明Description
blockTextBlock内容块(类型 `TextBlock`)。The block.
源码Source io/agentscope/core/agent/accumulator/TextAccumulator.java:34–39

hasContent

public boolean hasContent()

判断是否具有内容。

Returns whether this has the content.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/agent/accumulator/TextAccumulator.java:44–47

buildAggregated

public ContentBlock buildAggregated()

构建 buildAggregated。

Builds the aggregated.

返回Returns ContentBlock
返回ContentBlock。Returns content block.
源码Source io/agentscope/core/agent/accumulator/TextAccumulator.java:52–58

reset

public void reset()

清空或重置内部状态。

Clears or resets internal state.

源码Source io/agentscope/core/agent/accumulator/TextAccumulator.java:63–66

getAccumulated

public String getAccumulated()

获取 getAccumulated。

Get the accumulated text content.

返回Returns String
返回字符串结果。accumulated text as string
源码Source io/agentscope/core/agent/accumulator/TextAccumulator.java:74–76

replace

public void replace(String text)

设置该参数。

Replace the accumulated text with content reconstructed from the model-call event stream.

参数Parameters
名称Name类型Type说明Description
textString文本(类型 `String`)。The text.
源码Source io/agentscope/core/agent/accumulator/TextAccumulator.java:83–88
基于官方固定版本源码静态生成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.