类class
agentscope.agentTurnAggregator
class TurnAggregator
源码Source
agentscope/agent/_realtime/_aggregator.py:8–75轮次聚合器,驱动智能体的推理、工具调用与会话执行。位于 agentscope.agent 包。核心成员包括 take、merges_with_previous、reset。
Turn boundaries in speech are inferred, and inferred wrongly often enough to matter: one sentence gets split across two turns when the speaker pauses, and a stray "mm-hmm" gets promoted to a turn of its own. Neither is visible to the provider once it has answered, but both end up in our own context, where they outlive the call.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(merge_window_ms: int = 800, backchannels: frozenset[str] = frozenset(), min_chars: int = 1) -> None | 初始化 `TurnAggregator` 实例。 Initialize the aggregator. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
def take(transcript: str) -> str | None | 设置该参数。 Accept a settled transcript and decide whether it is a turn. |
def merges_with_previous() -> bool | 返回 `merges_with_previous` 结果。 Whether the last :meth:`take` continued the previous turn. |
def reset() -> None | 清空或重置内部状态。 Forget the previous turn, e.g. on reconnect. |
构造器详情Constructor Detail
TurnAggregator
def __init__(merge_window_ms: int = 800, backchannels: frozenset[str] = frozenset(), min_chars: int = 1) -> None
初始化 TurnAggregator 实例。
Initialize the aggregator.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
merge_window_ms默认default 800 | int | merge window ms(类型 `int`)。A transcript arriving this soon after the previous turn continues it rather than starting a new one. |
backchannels默认default frozenset() | frozenset[str] | backchannels(类型 `frozenset[str]`)。Acknowledgements that never constitute a turn. Language specific, so empty by default. |
min_chars默认default 1 | int | 最小字符数(类型 `int`)。Transcripts shorter than this are dropped. |
源码Source
agentscope/agent/_realtime/_aggregator.py:18–40方法详情Method Detail
take
def take(transcript: str) -> str | None
设置该参数。
Accept a settled transcript and decide whether it is a turn.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
transcript | str | transcript(类型 `str`)。The transcript the provider settled on. |
str | None
返回str|None。`str | None`:
源码Source
agentscope/agent/_realtime/_aggregator.py:42–66merges_with_previous
def merges_with_previous() -> bool
返回 merges_with_previous 结果。
Whether the last :meth:take continued the previous turn.
bool
返回布尔值,表示判断结果。Returns a boolean result.
源码Source
agentscope/agent/_realtime/_aggregator.py:68–70reset
def reset() -> None
清空或重置内部状态。
Forget the previous turn, e.g.
None
无返回值。No value is returned.
源码Source
agentscope/agent/_realtime/_aggregator.py:72–75