pub struct RouterChain { /* private fields */ }Expand description
Router Chain
Automatically routes to different Chains based on input content.
Implementations§
Source§impl RouterChain
impl RouterChain
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty RouterChain.
Sourcepub fn add_route(
self,
name: impl Into<String>,
description: impl Into<String>,
chain: Arc<dyn BaseChain>,
) -> Self
pub fn add_route( self, name: impl Into<String>, description: impl Into<String>, chain: Arc<dyn BaseChain>, ) -> Self
Add a route destination.
Sourcepub fn add_route_with_keywords(
self,
name: impl Into<String>,
description: impl Into<String>,
chain: Arc<dyn BaseChain>,
keywords: Vec<&str>,
) -> Self
pub fn add_route_with_keywords( self, name: impl Into<String>, description: impl Into<String>, chain: Arc<dyn BaseChain>, keywords: Vec<&str>, ) -> Self
Add a route destination with a keyword list for keyword-based routing.
Sourcepub fn with_default(self, chain: Arc<dyn BaseChain>) -> Self
pub fn with_default(self, chain: Arc<dyn BaseChain>) -> Self
Set the default chain used when no route matches.
Sourcepub fn with_input_key(self, key: impl Into<String>) -> Self
pub fn with_input_key(self, key: impl Into<String>) -> Self
Set the input key.
Sourcepub fn with_verbose(self, verbose: bool) -> Self
pub fn with_verbose(self, verbose: bool) -> Self
Set verbose mode.
Sourcepub fn destinations(&self) -> &[RouteDestination]
pub fn destinations(&self) -> &[RouteDestination]
Get the route destinations.
Sourcepub fn default_chain(&self) -> Option<&Arc<dyn BaseChain>>
pub fn default_chain(&self) -> Option<&Arc<dyn BaseChain>>
Get the default chain, if set.
Trait Implementations§
Source§impl BaseChain for RouterChain
impl BaseChain for RouterChain
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 into the routed destination chain via invoke_with_config.
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 RouterChain.
After routing (keyword matching), delegates to the selected chain’s
stream() method.
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.
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 validate_inputs(
&self,
inputs: &HashMap<String, Value>,
) -> Result<(), ChainError>
fn validate_inputs( &self, inputs: &HashMap<String, Value>, ) -> Result<(), ChainError>
Validate inputs.
Auto Trait Implementations§
impl !RefUnwindSafe for RouterChain
impl !UnwindSafe for RouterChain
impl Freeze for RouterChain
impl Send for RouterChain
impl Sync for RouterChain
impl Unpin for RouterChain
impl UnsafeUnpin for RouterChain
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