Skip to main content

Runnable

Trait Runnable 

Source
pub trait Runnable<I, O>: Send + Sync
where I: Send + 'static, O: Send + 'static,
{ // Required method fn invoke<'life0, 'life1, 'async_trait>( &'life0 self, input: I, config: &'life1 RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<O, SynapseError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn batch<'life0, 'life1, 'async_trait>( &'life0 self, inputs: Vec<I>, config: &'life1 RunnableConfig, ) -> Pin<Box<dyn Future<Output = Vec<Result<O, SynapseError>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn stream<'a>( &'a self, input: I, config: &'a RunnableConfig, ) -> RunnableOutputStream<'a, O> where I: 'a { ... } fn boxed(self) -> BoxRunnable<I, O> where Self: Sized + 'static { ... } }
Expand description

The core composition trait. All LCEL components implement this.

Implementors only need to provide invoke. Default implementations are provided for batch (sequential), stream (wraps invoke), and boxed (type-erased wrapper).

Required Methods§

Source

fn invoke<'life0, 'life1, 'async_trait>( &'life0 self, input: I, config: &'life1 RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<O, SynapseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute this runnable on a single input.

Provided Methods§

Source

fn batch<'life0, 'life1, 'async_trait>( &'life0 self, inputs: Vec<I>, config: &'life1 RunnableConfig, ) -> Pin<Box<dyn Future<Output = Vec<Result<O, SynapseError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute this runnable on multiple inputs sequentially.

Source

fn stream<'a>( &'a self, input: I, config: &'a RunnableConfig, ) -> RunnableOutputStream<'a, O>
where I: 'a,

Stream the output. Default wraps invoke as a single-item stream. Override for true streaming (e.g., token-by-token from an LLM).

Source

fn boxed(self) -> BoxRunnable<I, O>
where Self: Sized + 'static,

Wrap this runnable into a type-erased BoxRunnable for composition via |.

Implementors§

Source§

impl Runnable<Value, Value> for RunnableAssign

Source§

impl Runnable<Value, Value> for RunnablePick

Source§

impl<I, M, O> Runnable<I, O> for RunnableSequence<I, M, O>
where I: Send + 'static, M: Send + 'static, O: Send + 'static,

Source§

impl<I: Send + 'static, O: Send + 'static> Runnable<Vec<I>, Vec<O>> for RunnableEach<I, O>

Source§

impl<I: Send + 'static, O: Send + 'static> Runnable<I, Vec<O>> for RunnableGenerator<I, O>

Source§

impl<I: Send + 'static, O: Send + 'static> Runnable<I, O> for BoxRunnable<I, O>

Source§

impl<I: Send + 'static, O: Send + 'static> Runnable<I, O> for RunnableBranch<I, O>

Source§

impl<I: Send + 'static, O: Send + 'static> Runnable<I, O> for RunnableLambda<I, O>

Source§

impl<I: Send + Clone + 'static> Runnable<I, Value> for RunnableParallel<I>

Source§

impl<I: Send + Clone + 'static, O: Send + 'static> Runnable<I, O> for RunnableRetry<I, O>

Source§

impl<I: Send + Clone + 'static, O: Send + 'static> Runnable<I, O> for RunnableWithFallbacks<I, O>

Source§

impl<T> Runnable<T, T> for RunnablePassthrough
where T: Send + Sync + 'static,