ALF pipeline that assembles a conversation and adapts it into a protocol packet.
Summary
Functions
Pipeline stage that runs prompt assembly on the context's conversation and entries, attaching the assembly result to the context.
Pipeline stage that invokes the protocol adapter to convert the assembled context into a protocol packet.
Pipeline stage that extracts the final result from the pipeline state, returning either the assembled packet or an error.
Executes the ALF assembly pipeline: validates the context, assembles the prompt, builds a protocol packet, validates it, and returns the result.
Pipeline stage that validates the context has a valid conversation and entry list. Returns the state unchanged if valid, or sets an error result if invalid.
Pipeline stage that validates the assembled packet's structure, checking message format, sections, and token usage.
Functions
@spec assemble_prompt( CommBus.Protocol.Pipeline.State.t(), keyword() ) :: CommBus.Protocol.Pipeline.State.t()
Pipeline stage that runs prompt assembly on the context's conversation and entries, attaching the assembly result to the context.
@spec build_packet( CommBus.Protocol.Pipeline.State.t(), keyword() ) :: CommBus.Protocol.Pipeline.State.t()
Pipeline stage that invokes the protocol adapter to convert the assembled context into a protocol packet.
@spec components() :: [map()]
@spec finalize_result( CommBus.Protocol.Pipeline.State.t(), keyword() ) :: {:ok, CommBus.Protocol.Packet.t()} | {:error, term()}
Pipeline stage that extracts the final result from the pipeline state, returning either the assembled packet or an error.
@spec flow(map(), list(), Keyword.t()) :: Enumerable.t()
@spec run( CommBus.Protocol.Context.t() | tuple(), keyword() ) :: {:ok, CommBus.Protocol.Packet.t()} | {:error, term()}
Executes the ALF assembly pipeline: validates the context, assembles the prompt, builds a protocol packet, validates it, and returns the result.
Parameters
input— A%CommBus.Protocol.Context{}struct, or a tuple of{conversation, entries}or{conversation, entries, opts}.opts— Keyword options::adapter(protocol adapter module, defaults toCommBus.Protocol.LlmCoreAdapter).
Returns
{:ok, %CommBus.Protocol.Packet{}} on success or {:error, reason} on failure.
@spec start() :: :ok
@spec start(list()) :: :ok
@spec started?() :: true | false
@spec stream(Enumerable.t(), Keyword.t()) :: Enumerable.t()
@spec validate_context( CommBus.Protocol.Pipeline.State.t(), keyword() ) :: CommBus.Protocol.Pipeline.State.t()
Pipeline stage that validates the context has a valid conversation and entry list. Returns the state unchanged if valid, or sets an error result if invalid.
@spec validate_packet( CommBus.Protocol.Pipeline.State.t(), keyword() ) :: CommBus.Protocol.Pipeline.State.t()
Pipeline stage that validates the assembled packet's structure, checking message format, sections, and token usage.