agentscope.pipelines

Import all pipeline related modules in the package.

class SequentialPipeline(operators: list[Callable[[None | Msg | list[Msg]], None | Msg | list[Msg]]])[source]

Bases: 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][source]

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.

Example

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

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

msg_output = sequential_pipeline(
    [agent1, agent2, agent3],
    msg_input
)
Parameters:
  • (`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

Parameters:
  • 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.

Returns:

The output of the last operator in the sequence.

Return type:

Union[None, Msg, list[Msg]]