pub struct LLMChain { /* private fields */ }Expand description
Implementations§
Source§impl LLMChain
impl LLMChain
Sourcepub fn new<L>(llm: L, prompt_template: impl Into<String>) -> Self
pub fn new<L>(llm: L, prompt_template: impl Into<String>) -> Self
Create a new LLMChain.
§Arguments
llm- LLM client (any type implementing BaseChatModel)prompt_template- Prompt template string with {variable} placeholders
Sourcepub fn with_input_key(self, key: impl Into<String>) -> Self
pub fn with_input_key(self, key: impl Into<String>) -> Self
Set input key name.
Sourcepub fn with_output_key(self, key: impl Into<String>) -> Self
pub fn with_output_key(self, key: impl Into<String>) -> Self
Set output key name.
Trait Implementations§
Source§impl BaseChain for LLMChain
impl BaseChain for LLMChain
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 callback propagation.
Fires on_chain_start → on_llm_start → LLM call → on_llm_end → on_chain_end.
On error, fires on_llm_error / on_chain_error instead.
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 LLMChain – token by token output.
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 with config propagation.
0.22.0 audit fix (H-C3): the chain’s RunnableConfig is threaded into
stream_chat, so sampling overrides / cancellation token / callbacks
reach the provider (providers consume config via apply_overrides)
instead of every streaming call being hardwired to None.
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 LLMChain
impl !UnwindSafe for LLMChain
impl Freeze for LLMChain
impl Send for LLMChain
impl Sync for LLMChain
impl Unpin for LLMChain
impl UnsafeUnpin for LLMChain
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