pub struct SequentialChain { /* private fields */ }Expand description
Sequential Chain
Executes multiple chains sequentially, where the output of one chain can be used as the input of the next.
Implementations§
Source§impl SequentialChain
impl SequentialChain
Sourcepub fn add_chain(
self,
chain: Arc<dyn BaseChain>,
input_keys: Vec<&str>,
output_keys: Vec<&str>,
) -> Self
pub fn add_chain( self, chain: Arc<dyn BaseChain>, input_keys: Vec<&str>, output_keys: Vec<&str>, ) -> Self
Add a Chain.
§Arguments
chain- Chain to addinput_keys- Input keys (from global input)output_keys- Output keys (to global result)
Sourcepub fn add_chain_with_mapping(
self,
chain: Arc<dyn BaseChain>,
input_mapping: HashMap<String, String>,
output_mapping: HashMap<String, String>,
) -> Self
pub fn add_chain_with_mapping( self, chain: Arc<dyn BaseChain>, input_mapping: HashMap<String, String>, output_mapping: HashMap<String, String>, ) -> Self
Add a Chain with mapping.
§Arguments
chain- Chain to addinput_mapping- Input mapping {chain_input_key: global_key}output_mapping- Output mapping {chain_output_key: global_key}
Trait Implementations§
Source§impl BaseChain for SequentialChain
impl BaseChain for SequentialChain
Source§fn stream<'life0, 'async_trait>(
&'life0 self,
inputs: HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<ChainStream, ChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
inputs: HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<ChainStream, ChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream execution for SequentialChain.
Runs all chains except the last via invoke (since their output feeds
into subsequent chains). The last chain’s output is streamed token
by token by delegating to its stream() method.
Source§fn input_keys(&self) -> Vec<&str>
fn input_keys(&self) -> Vec<&str>
Get input keys.
Source§fn output_keys(&self) -> Vec<&str>
fn output_keys(&self) -> Vec<&str>
Get output keys.
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
inputs: HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<ChainResult, ChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
inputs: HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<ChainResult, ChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the Chain. Read more
Source§fn invoke_with_config<'life0, 'async_trait>(
&'life0 self,
inputs: HashMap<String, Value>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<ChainResult, ChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke_with_config<'life0, 'async_trait>(
&'life0 self,
inputs: HashMap<String, Value>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<ChainResult, ChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the Chain with a RunnableConfig. Read more
Source§fn stream_with_config<'life0, 'async_trait>(
&'life0 self,
inputs: HashMap<String, Value>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<ChainStream, ChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream_with_config<'life0, 'async_trait>(
&'life0 self,
inputs: HashMap<String, Value>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<ChainStream, ChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream execute the Chain with a RunnableConfig. Read more
Source§fn validate_inputs(
&self,
inputs: &HashMap<String, Value>,
) -> Result<(), ChainError>
fn validate_inputs( &self, inputs: &HashMap<String, Value>, ) -> Result<(), ChainError>
Validate inputs.
Source§impl Debug for SequentialChain
impl Debug for SequentialChain
Auto Trait Implementations§
impl !RefUnwindSafe for SequentialChain
impl !UnwindSafe for SequentialChain
impl Freeze for SequentialChain
impl Send for SequentialChain
impl Sync for SequentialChain
impl Unpin for SequentialChain
impl UnsafeUnpin for SequentialChain
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