pub struct LLMChain<M: BaseChatModel> { /* private fields */ }Expand description
Implementations§
Source§impl<M: BaseChatModel> LLMChain<M>
impl<M: BaseChatModel> LLMChain<M>
Sourcepub fn new(llm: M, prompt_template: impl Into<String>) -> Self
pub fn new(llm: M, 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<M: BaseChatModel + Send + Sync + 'static> BaseChain for LLMChain<M>
impl<M: BaseChatModel + Send + Sync + 'static> BaseChain for LLMChain<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 LLMChain – token by token output.
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<M> Freeze for LLMChain<M>where
M: Freeze,
impl<M> RefUnwindSafe for LLMChain<M>where
M: RefUnwindSafe,
impl<M> Send for LLMChain<M>
impl<M> Sync for LLMChain<M>
impl<M> Unpin for LLMChain<M>where
M: Unpin,
impl<M> UnsafeUnpin for LLMChain<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for LLMChain<M>where
M: UnwindSafe,
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