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 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 config propagation.
Dispatches this chain’s on_chain_start/on_chain_end and threads
config (and thus callbacks) into every sub-chain via
invoke_with_config — previously sub-chains were called with plain
invoke, dropping the config at the composition boundary.
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; its output_mapping
names the global output keys that stream stands for (validated in
Self::stream_steps so a broken mapping fails loudly, P2-3).
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 config propagation.
Dispatches this chain’s on_chain_start/on_chain_end and threads
config into every sub-chain (invoke for intermediate steps,
stream for the last step).