agentscope.pipelines package

Module contents

Import all pipeline related modules in the package.

class SequentialPipeline(operators: list[Callable[[None | Msg | list[Msg]], None | Msg | list[Msg]]])[源代码]

基类:object

A sequential pipeline class, which executes a sequence of operators sequentially. Compared with functional pipeline, this class can be re-used.

sequential_pipeline(operators: list[Callable[[None | Msg | list[Msg]], None | Msg | list[Msg]]], x: Msg | list[Msg] | None = None) None | Msg | list[Msg][源代码]

A syntactic sugar pipeline that executes a sequence of operators sequentially. The output of the previous operator will be passed as the input to the next operator. The final output will be the output of the last operator.

示例

agent1 = DialogAgent(...)
agent2 = DialogAgent(...)
agent3 = DialogAgent(...)

msg_input = Msg("user", "Hello", "user")

msg_output = sequential_pipeline(
    [agent1, agent2, agent3],
    msg_input
)
参数:
  • (`list[Callable[[Union[None (operators) --

  • Msg

  • list[Msg]]]

:param : :param Union[None: A list of operators, which can be agent, pipeline or any callable

that takes Msg object(s) as input and returns Msg object or None

参数:
  • Msg -- A list of operators, which can be agent, pipeline or any callable that takes Msg object(s) as input and returns Msg object or None

  • list[Msg]]]`) -- A list of operators, which can be agent, pipeline or any callable that takes Msg object(s) as input and returns Msg object or None

  • x (Optional[Union[Msg, list[Msg]]], defaults to None) -- The initial input that will be passed to the first operator.

返回:

The output of the last operator in the sequence.

返回类型:

Union[None, Msg, list[Msg]]