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 |
|---|---|---|
block | TextBlock | 内容块(类型 `TextBlock`)。The block. |
源码Source
io/agentscope/core/agent/accumulator/TextAccumulator.java:34–39hasContent
public boolean hasContent()
判断是否具有内容。
Returns whether this has the content.
boolean返回布尔值,表示判断结果。Returns a boolean result.
源码Source
io/agentscope/core/agent/accumulator/TextAccumulator.java:44–47buildAggregated
public ContentBlock buildAggregated()
构建 buildAggregated。
Builds the aggregated.
ContentBlock返回ContentBlock。Returns content block.
源码Source
io/agentscope/core/agent/accumulator/TextAccumulator.java:52–58reset
public void reset()
清空或重置内部状态。
Clears or resets internal state.
源码Source
io/agentscope/core/agent/accumulator/TextAccumulator.java:63–66getAccumulated
public String getAccumulated()
获取 getAccumulated。
Get the accumulated text content.
String返回字符串结果。accumulated text as string
源码Source
io/agentscope/core/agent/accumulator/TextAccumulator.java:74–76replace
public void replace(String text)
设置该参数。
Replace the accumulated text with content reconstructed from the model-call event stream.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text. |
源码Source
io/agentscope/core/agent/accumulator/TextAccumulator.java:83–88