pub struct LLMRouterChain<M: BaseChatModel> { /* private fields */ }Expand description
LLM Router Chain
Uses an LLM to intelligently determine the routing destination.
Implementations§
Source§impl<M: BaseChatModel> LLMRouterChain<M>
impl<M: BaseChatModel> LLMRouterChain<M>
pub fn new(llm: M) -> Self
pub fn add_route( self, name: impl Into<String>, description: impl Into<String>, chain: Arc<dyn BaseChain>, ) -> Self
pub fn add_route_with_keywords( self, name: impl Into<String>, description: impl Into<String>, chain: Arc<dyn BaseChain>, keywords: Vec<&str>, ) -> Self
pub fn with_default(self, chain: Arc<dyn BaseChain>) -> Self
pub fn with_input_key(self, key: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_verbose(self, verbose: bool) -> Self
pub fn destinations(&self) -> &[RouteDestination]
pub fn default_chain(&self) -> Option<&Arc<dyn BaseChain>>
Trait Implementations§
Source§impl<M: BaseChatModel + Send + Sync + 'static> BaseChain for LLMRouterChain<M>
impl<M: BaseChatModel + Send + Sync + 'static> BaseChain for LLMRouterChain<M>
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 LLMRouterChain.
The routing LLM call must complete first (to determine the destination),
then delegates to the selected chain’s 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.
Auto Trait Implementations§
impl<M> !RefUnwindSafe for LLMRouterChain<M>
impl<M> !UnwindSafe for LLMRouterChain<M>
impl<M> Freeze for LLMRouterChain<M>where
M: Freeze,
impl<M> Send for LLMRouterChain<M>
impl<M> Sync for LLMRouterChain<M>
impl<M> Unpin for LLMRouterChain<M>where
M: Unpin,
impl<M> UnsafeUnpin for LLMRouterChain<M>where
M: UnsafeUnpin,
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