类class
agentscope.sopSOPEngine
class SOPEngine
源码Source
agentscope/sop/_engine.py:24–174SOP 引擎,把复杂任务拆分为可执行步骤并驱动流程。位于 agentscope.sop 包。核心成员包括 reply_stream、phase。
Feed it, watch the events, and when something needs a person the stream simply ends — nothing stays suspended. Come back with the answer and it picks up from the state.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(sop: SOP, state: SOPRunState | None = None) -> None | 初始化 `SOPEngine` 实例。 Initialize the engine. |
属性摘要Property Summary
| 属性Property | 说明Description |
|---|---|
phase | 获取阶段。 Where the run stands overall. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def reply_stream(inputs: Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultE…async | 流式回复输入消息,并逐个产出事件或消息。 Run the procedure, streaming what happens. |
构造器详情Constructor Detail
SOPEngine
def __init__(sop: SOP, state: SOPRunState | None = None) -> None
初始化 SOPEngine 实例。
Initialize the engine.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sop | SOP | SOP(类型 `SOP`)。The procedure to run. Never written to. |
state默认default None | SOPRunState | None | 状态对象(类型 `SOPRunState | None`)。A stored run to carry on from. Omit to start a new one. Only the SOP's own state is restored: an executor that keeps state of its own — an :class:`~..agent.Agent` does — is restored by whoever built it, before the SOP is handed here. |
- 可能抛出 `Exception`。`ValueError`:
- 可能抛出 `Exception`。If the state has a different number of steps than the
- 可能抛出 `Exception`。SOP, which means the procedure was edited since.
源码Source
agentscope/sop/_engine.py:32–64属性详情Property Detail
phase
def phase() -> SOPPhase
获取阶段。
Where the run stands overall.
SOPPhase
返回SOPPhase。`SOPPhase`:
源码Source
agentscope/sop/_engine.py:67–74方法详情Method Detail
reply_stream
async def reply_stream(inputs: Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None = None) -> AsyncGenerator[AgentEvent | Msg, None]
async
流式回复输入消息,并逐个产出事件或消息。
Named after :meth:~..agent.Agent.reply_stream so a SOP goes wherever an agent goes.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
inputs默认default None | Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None | 输入消息(类型 `Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None`)。What starts the run, or the answer a parked step was waiting for. |
AsyncGenerator[AgentEvent | Msg, None]
以异步流的形式返回AgentEvent|消息,None。`AgentEvent | Msg`:
源码Source
agentscope/sop/_engine.py:76–153