Skip to main content

RunnableExt

Trait RunnableExt 

Source
pub trait RunnableExt<Input: Send + Sync + 'static, Output: Send + Sync + 'static>: Runnable<Input, Output>
where Self::Error: Into<LcelError>, Self: Sized + 'static,
{ // Provided methods fn pipe<O2, R2>(self, other: R2) -> RunnableSequence<Input, O2> where O2: Send + Sync + 'static, R2: Runnable<Output, O2> + Send + Sync + 'static, R2::Error: Into<LcelError> { ... } fn into_sequence(self) -> RunnableSequence<Input, Output> { ... } }
Expand description

Extension trait that provides LCEL composition methods for Runnable.

Automatically implemented for all Runnable<I, O> types where Self::Error: Into<LcelError>.

Provided Methods§

Source

fn pipe<O2, R2>(self, other: R2) -> RunnableSequence<Input, O2>
where O2: Send + Sync + 'static, R2: Runnable<Output, O2> + Send + Sync + 'static, R2::Error: Into<LcelError>,

Pipe the output of this runnable into another runnable.

This is the core LCEL composition operator. It creates a RunnableSequence that executes self first, then passes the output to other.

§Type Safety

The compiler ensures that the output type of self matches the input type of other. At runtime, intermediate types are erased via RunnableAny, but the type relationship was already proven at compile time.

§Example
let chain = prompt.pipe(llm).pipe(parser);
let result = chain.invoke("What is Rust?".to_string(), None).await?;
Source

fn into_sequence(self) -> RunnableSequence<Input, Output>

Create a RunnableSequence from this runnable as a single step.

Useful when you want to start building a pipeline and add steps later via pipe().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<I, O, R> RunnableExt<I, O> for R
where I: Send + Sync + 'static, O: Send + Sync + 'static, R: Runnable<I, O> + Sized + 'static, R::Error: Into<LcelError>,