类class
agentscope.pipelineGoalPipeline
class GoalPipeline
源码Source
agentscope/pipeline/_goal_pipeline.py:55–370目标流水线,把复杂任务拆分为可执行步骤并驱动流程。位于 agentscope.pipeline 包。核心成员包括 reply_stream。
The goal pipeline class that run an executor and verifier in a loop until the goal is achieved. Declared in agentscope.pipeline.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(executor: Agent, verifier: Agent, verifier_reset_context: bool = True, max_iters: int = 10, max_retries: i… | 初始化 `GoalPipeline` 实例。 Initialize the goal pipeline. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def reply_stream(inputs: Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultE…async | 流式回复输入消息,并逐个产出事件或消息。 Run the goal pipeline. |
构造器详情Constructor Detail
GoalPipeline
def __init__(executor: Agent, verifier: Agent, verifier_reset_context: bool = True, max_iters: int = 10, max_retries: int = 3) -> None
初始化 GoalPipeline 实例。
Initialize the goal pipeline.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
executor | Agent | 执行器(类型 `Agent`)。The executor agent that performs the work. |
verifier | Agent | 校验器(类型 `Agent`)。The verifier agent that checks the goal achievement. |
verifier_reset_context默认default True | bool | 校验器重置上下文(类型 `bool`)。Whether to reset the verifier's context after each iteration. Defaults to `True`. |
max_iters默认default 10 | int | 最大迭代次数(类型 `int`)。The maximum number of goal achievement attempts. |
max_retries默认default 3 | int | 最大重试次数(类型 `int`)。The maximum number of retries for the executor and verifier agents to generate valid structured outputs. Defaults to `3`. |
源码Source
agentscope/pipeline/_goal_pipeline.py:59–94方法详情Method Detail
reply_stream
async def reply_stream(inputs: Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent) -> AsyncGenerator
async
流式回复输入消息,并逐个产出事件或消息。
Run the goal pipeline.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
inputs | Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | 输入消息(类型 `Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent`)。The inputs to the pipeline, which can be a message, a list of messages, a user confirmation result event, a user interrupt event, or an external execution result event. |
AsyncGenerator
返回AsyncGenerator。`AgentEvent`:
源码Source
agentscope/pipeline/_goal_pipeline.py:112–370