pub struct RunnableSequence<I: Send + Sync + 'static, O: Send + Sync + 'static> { /* private fields */ }Expand description
A sequence of Runnable steps composed into a pipeline.
Created via the pipe() method on RunnableExt, or directly
with from_single / from_pair.
§Type Safety
The I and O type parameters represent the pipeline’s overall
input and output types. Intermediate types are erased at runtime
via RunnableAny, but the compiler guarantees type compatibility
at each pipe() call site.
§Flattening
When two RunnableSequence values are piped together, their
internal steps are merged (flattened) rather than nested,
avoiding unnecessary indirection.
Implementations§
Source§impl<I: Send + Sync + 'static, O: Send + Sync + 'static> RunnableSequence<I, O>
impl<I: Send + Sync + 'static, O: Send + Sync + 'static> RunnableSequence<I, O>
Sourcepub fn from_single<R>(runnable: R) -> Self
pub fn from_single<R>(runnable: R) -> Self
Create a sequence from a single runnable step.
Sourcepub fn from_pair<R1, R2, M>(first: R1, second: R2) -> RunnableSequence<I, O>
pub fn from_pair<R1, R2, M>(first: R1, second: R2) -> RunnableSequence<I, O>
Create a sequence from two runnable steps.
The output type of the first must match the input type of the second.
Sourcepub fn pipe<O2, R>(self, other: R) -> RunnableSequence<I, O2>
pub fn pipe<O2, R>(self, other: R) -> RunnableSequence<I, O2>
Append a step to this sequence, returning a new sequence with the updated output type.
Sourcepub fn steps(&self) -> &[Box<dyn RunnableAny>]
pub fn steps(&self) -> &[Box<dyn RunnableAny>]
Access the steps as a slice.
Trait Implementations§
Source§impl<I: Send + Sync + 'static, O: Send + Sync + 'static> Runnable<I, O> for RunnableSequence<I, O>
impl<I: Send + Sync + 'static, O: Send + Sync + 'static> Runnable<I, O> for RunnableSequence<I, O>
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
input: I,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<O, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: I,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<O, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the pipeline: feed input through each step sequentially.
Source§fn batch<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<I>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<O>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn batch<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<I>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<O>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Batch processing: each step processes all inputs before passing to the next step. This allows LLM providers to optimize batch requests.
Source§fn stream<'life0, 'async_trait>(
&'life0 self,
input: I,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<O, LcelError>> + Send>>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
input: I,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<O, LcelError>> + Send>>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Streaming: the first step runs through stream_any (single input →
item stream) and every following step runs through transform_any.
Steps that override stream (e.g. LLMs) therefore emit a real token
stream instead of being collapsed to a single invoke.
Source§fn transform<'life0, 'async_trait>(
&'life0 self,
input: Pin<Box<dyn Stream<Item = Result<I, LcelError>> + Send>>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<O, LcelError>> + Send + '_>>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn transform<'life0, 'async_trait>(
&'life0 self,
input: Pin<Box<dyn Stream<Item = Result<I, LcelError>> + Send>>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<O, LcelError>> + Send + '_>>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Transform: chain each step’s transform to enable stream-to-stream pipeline processing.
Source§fn batch_as_completed<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<Input>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(usize, Output)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn batch_as_completed<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<Input>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(usize, Output)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<I, O> !RefUnwindSafe for RunnableSequence<I, O>
impl<I, O> !UnwindSafe for RunnableSequence<I, O>
impl<I, O> Freeze for RunnableSequence<I, O>
impl<I, O> Send for RunnableSequence<I, O>
impl<I, O> Sync for RunnableSequence<I, O>
impl<I, O> Unpin for RunnableSequence<I, O>
impl<I, O> UnsafeUnpin for RunnableSequence<I, O>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<I, O, R> RunnableExt<I, O> for R
impl<I, O, R> RunnableExt<I, O> for R
Source§fn pipe<O2, R2>(self, other: R2) -> RunnableSequence<Input, O2>
fn pipe<O2, R2>(self, other: R2) -> RunnableSequence<Input, O2>
Source§fn into_sequence(self) -> RunnableSequence<Input, Output>
fn into_sequence(self) -> RunnableSequence<Input, Output>
RunnableSequence from this runnable as a single step. Read moreSource§fn with_fallbacks<R>(
self,
fallbacks: Vec<R>,
) -> RunnableWithFallbacks<Input, Output>
fn with_fallbacks<R>( self, fallbacks: Vec<R>, ) -> RunnableWithFallbacks<Input, Output>
Source§fn with_retry(self, retry_config: RetryConfig) -> RunnableRetry<Input, Output>where
Input: Clone,
fn with_retry(self, retry_config: RetryConfig) -> RunnableRetry<Input, Output>where
Input: Clone,
Source§fn configurable_alternatives<K, R>(
self,
which: impl Into<String>,
default_key: impl Into<String>,
alternatives: Vec<(K, R)>,
) -> RunnableConfigurable<Input, Output>
fn configurable_alternatives<K, R>( self, which: impl Into<String>, default_key: impl Into<String>, alternatives: Vec<(K, R)>, ) -> RunnableConfigurable<Input, Output>
Source§fn configurable_fields(self) -> RunnableConfigurableFields<Input, Output>
fn configurable_fields(self) -> RunnableConfigurableFields<Input, Output>
config.configurable (Python’s Runnable.configurable_fields). Read more