Skip to content

seq_chain_builder

Sequential chain builder module

Attributes

Classes

SeqChainBuilder

Bases: BaseChainBuilder

Builds on the SimpleChainBuilder to create a chain with a sequence of consecutive steps.

Attributes

steps class-attribute instance-attribute
steps: List[IoCFactoryModel] = Field(
    ...,
    title="Steps",
    description="Steps to execute in sequence. Must be instances of eleanor.llm.chain.simple_chain_builder.SimpleChainBuilder",
)

Functions

build
build() -> RunnableSerializable

Builds the chain configuration.

This method is responsible for building the chain configuration based on the parameters provided in the configuration.

Returns:

  • RunnableSerializable ( RunnableSerializable ) –

    The chain configuration

create_step_chain
create_step_chain(
    step: IoCFactoryModel,
    step_index: int,
    echo_output_field_names: List[str] | None = None,
) -> Tuple[
    str, RunnableSerializable, Dict[str, RunnableLambda]
]

Creates a step chain for the given step.

Parameters:

  • step (IoCFactoryModel) –

    The step for which to create the chain.

  • step_index (int) –

    The index of the step.

  • echo_output_field_names (List[str] | None, default: None ) –

    The names of the output fields to echo. Defaults to None.

Returns:

  • Tuple[str, RunnableSerializable, Dict[str, RunnableLambda]]

    Tuple[str, RunnableSerializable, Dict[str, RunnableLambda]]: A tuple containing the step name, step chain, and step echo output fields.

derive_input_field_names
derive_input_field_names() -> List[str]

Determines the full set of input field names for the first step in the chain.

Returns:

  • List[str]

    A list of input field names for the first step in the chain. These will get piped to each subsequent step and

  • List[str]

    can be referenced by chain templates.

derive_stepwise_io
derive_stepwise_io(
    input_field_names: List[str],
) -> Tuple[List[List[str]], List[str]]

For each step in the sequential chain configuration, determine which fields need to be echoed and the proper response names.

Parameters:

  • input_field_names (List[str]) –

    The list of input field names.

Returns:

  • List[List[str]]

    Tuple[List[List[str]], List[str]]: A tuple containing the derived echo output field names

  • List[str]

    and the derived response field names.

validate_steps classmethod
validate_steps(
    value: List[IoCFactoryModel],
) -> List[IoCFactoryModel]