agentscope.pipelines.pipeline module
Base class for Pipeline
- class ForLoopPipeline(loop_body_operators: ~agentscope.agents.operator.Operator | ~typing.Sequence[~agentscope.agents.operator.Operator], max_loop: int, break_func: ~typing.Callable[[dict], bool] = <function ForLoopPipeline.<lambda>>)[source]
Bases:
PipelineBase
A template pipeline for implementing control flow like for-loop
ForLoopPipeline(loop_body_operators, max_loop) represents the following workflow:
for i in range(max_loop): x = loop_body_operators(x)
ForLoopPipeline(loop_body_operators, max_loop, break_func) represents the following workflow:
for i in range(max_loop): x = loop_body_operators(x) if break_func(x): break
- class IfElsePipeline(condition_func: ~typing.Callable[[dict], bool], if_body_operators: ~agentscope.agents.operator.Operator | ~typing.Sequence[~agentscope.agents.operator.Operator], else_body_operators: ~agentscope.agents.operator.Operator | ~typing.Sequence[~agentscope.agents.operator.Operator] = <function placeholder>)[source]
Bases:
PipelineBase
A template pipeline for implementing control flow like if-else.
IfElsePipeline(condition_func, if_body_operators, else_body_operators) represents the following workflow:
if condition_func(x): if_body_operators(x) else: else_body_operators(x)
- class PipelineBase[source]
Bases:
Operator
Base interface of all pipelines.
The pipeline is a special kind of operator that includes multiple operators and the interaction logic among them.
- class SequentialPipeline(operators: Sequence[Operator])[source]
Bases:
PipelineBase
A template pipeline for implementing sequential logic.
Sequential(operators) represents the following workflow:
x = operators[0](x) x = operators[1](x) ... x = operators[n](x)
- class SwitchPipeline(condition_func: ~typing.Callable[[dict], ~typing.Any], case_operators: ~typing.Mapping[~typing.Any, ~agentscope.agents.operator.Operator | ~typing.Sequence[~agentscope.agents.operator.Operator]], default_operators: ~agentscope.agents.operator.Operator | ~typing.Sequence[~agentscope.agents.operator.Operator] = <function placeholder>)[source]
Bases:
PipelineBase
A template pipeline for implementing control flow like switch-case.
SwitchPipeline(condition_func, case_operators, default_operators) represents the following workflow:
switch condition_func(x): case k1: return case_operators[k1](x) case k2: return case_operators[k2](x) ... default: return default_operators(x)
- class WhileLoopPipeline(loop_body_operators: ~agentscope.agents.operator.Operator | ~typing.Sequence[~agentscope.agents.operator.Operator], condition_func: ~typing.Callable[[int, dict], bool] = <function WhileLoopPipeline.<lambda>>)[source]
Bases:
PipelineBase
A template pipeline for implementing control flow like while-loop
WhileLoopPipeline(loop_body_operators, condition_operator, condition_func) represents the following workflow:
i = 0 while (condition_func(i, x)) x = loop_body_operators(x) i += 1