ContentAccumulator
public interface ContentAccumulator<T extends ContentBlock>
源码Source
io/agentscope/core/agent/accumulator/ContentAccumulator.java:29–60定义内容 Accumulator契约的接口。位于 io.agentscope.core.agent.accumulator 包。核心成员包括 add、hasContent、buildAggregated、reset。
Content accumulator interface for accumulating streaming content blocks.
This interface defines the contract for accumulating content blocks from streaming responses. Different content types (text, thinking, tool calls) have different accumulation strategies.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void add(T block) | 设置添加。 Add a content block chunk to the accumulator. |
public boolean hasContent() | 判断是否具有内容。 Check if the accumulator has any accumulated content. |
public ContentBlock buildAggregated() | 构建 `buildAggregated`。 Build the aggregated content block from all accumulated chunks. |
public void reset() | 清空或重置内部状态。 Clears or resets internal state. |
方法详情Method Detail
add
public void add(T block)
设置添加。
Add a content block chunk to the accumulator.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
block | T | 内容块分块到添加。The content block chunk to add |
源码Source
io/agentscope/core/agent/accumulator/ContentAccumulator.java:37hasContent
public boolean hasContent()
判断是否具有内容。
Check if the accumulator has any accumulated content.
boolean返回布尔值,表示判断结果。true if there is accumulated content, false otherwise
源码Source
io/agentscope/core/agent/accumulator/ContentAccumulator.java:45buildAggregated
public ContentBlock buildAggregated()
构建 buildAggregated。
Build the aggregated content block from all accumulated chunks.
ContentBlock返回ContentBlock。The aggregated content block, or null if no content
源码Source
io/agentscope/core/agent/accumulator/ContentAccumulator.java:53reset
public void reset()
清空或重置内部状态。
Clears or resets internal state.
源码Source
io/agentscope/core/agent/accumulator/ContentAccumulator.java:59