pub struct RunnableAssign { /* private fields */ }Expand description
A Runnable that adds new key-value pairs to a HashMap<String, Value>.
Each mapping runs a Runnable on the input HashMap and merges the
result back into the HashMap under the specified key.
This is the LCEL equivalent of Python’s RunnableAssign.
Implementations§
Source§impl RunnableAssign
impl RunnableAssign
Sourcepub fn with<O, R>(self, key: &str, runnable: R) -> Self
pub fn with<O, R>(self, key: &str, runnable: R) -> Self
Add a mapping that runs the given runnable and stores the result under the specified key.
The runnable takes HashMap<String, Value> as input and produces
any output that implements serde::Serialize. The output is
serialized to serde_json::Value and merged into the HashMap.
Trait Implementations§
Source§impl Debug for RunnableAssign
impl Debug for RunnableAssign
Source§impl Default for RunnableAssign
impl Default for RunnableAssign
Source§impl Runnable<HashMap<String, Value>, HashMap<String, Value>> for RunnableAssign
impl Runnable<HashMap<String, Value>, HashMap<String, Value>> for RunnableAssign
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
input: HashMap<String, Value>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Value>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: HashMap<String, Value>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Value>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute all mappings and merge results into the input HashMap.
Source§fn stream<'life0, 'async_trait>(
&'life0 self,
input: HashMap<String, Value>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<HashMap<String, Value>, LcelError>> + Send>>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
input: HashMap<String, Value>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<HashMap<String, Value>, LcelError>> + Send>>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream: invoke and return single-element stream.
Source§fn batch<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<HashMap<String, Value>>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn batch<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<HashMap<String, Value>>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>, LcelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Batch: invoke per input.
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,
Batch processing that returns results in completion order. Read more
Source§fn transform<'life0, 'async_trait>(
&'life0 self,
input: Pin<Box<dyn Stream<Item = Result<Input, Self::Error>> + Send>>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Output, Self::Error>> + Send + '_>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn transform<'life0, 'async_trait>(
&'life0 self,
input: Pin<Box<dyn Stream<Item = Result<Input, Self::Error>> + Send>>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Output, Self::Error>> + Send + '_>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream-to-stream transformation - the core of LCEL streaming. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for RunnableAssign
impl !UnwindSafe for RunnableAssign
impl Freeze for RunnableAssign
impl Send for RunnableAssign
impl Sync for RunnableAssign
impl Unpin for RunnableAssign
impl UnsafeUnpin for RunnableAssign
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
Mutably borrows from an owned value. Read more
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>
Pipe the output of this runnable into another runnable. Read more
Source§fn into_sequence(self) -> RunnableSequence<Input, Output>
fn into_sequence(self) -> RunnableSequence<Input, Output>
Create a
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>
Add fallback runnables that are tried if this one fails. Read more
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,
Wrap this runnable with retry logic using exponential backoff. Read more
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>
Route between a default runnable and named alternatives at invoke time. Read more
Source§fn configurable_fields(self) -> RunnableConfigurableFields<Input, Output>
fn configurable_fields(self) -> RunnableConfigurableFields<Input, Output>
Override recognized config fields at invoke time from
config.configurable (Python’s Runnable.configurable_fields). Read moreSource§impl<I, R> RunnablePick<I> for R
impl<I, R> RunnablePick<I> for R
Source§fn pick<K>(
self,
keys: impl IntoIterator<Item = K>,
) -> RunnableSequence<I, HashMap<String, Value>>
fn pick<K>( self, keys: impl IntoIterator<Item = K>, ) -> RunnableSequence<I, HashMap<String, Value>>
Keep only the given keys of the dict output, dropping everything else. Read more