Struct llm_chain::chains::conversation::Chain
source · pub struct Chain<E: Executor> { /* private fields */ }Expand description
Chain represents a conversation between an entity and an LLM.
It holds the conversation state and provides methods for sending messages and receiving responses.
Implementations§
source§impl<E: Executor> Chain<E>
impl<E: Executor> Chain<E>
sourcepub fn new(state: PromptTemplate) -> Result<Chain<E>, Error<E::Error>>
pub fn new(state: PromptTemplate) -> Result<Chain<E>, Error<E::Error>>
Constructs a new Chain with the given conversation state.
Self,
Arguments
state- The initial prompt state to use.
sourcepub async fn send_message(
&mut self,
step: Step<E>,
parameters: &Parameters,
exec: &E
) -> Result<E::Output, Error<E::Error>>
pub async fn send_message( &mut self, step: Step<E>, parameters: &Parameters, exec: &E ) -> Result<E::Output, Error<E::Error>>
Sends a message to the LLM and returns the response.
This method sends a message to the LLM, adding it and the response to the internal state.
Arguments
step- The step to send.parameters- The parameters to use when formatting the step.exec- The executor to use.
Returns
A Result containing the LLM’s response as E::Output on success or an Error variant on failure.
sourcepub async fn send_message_raw(
&mut self,
options: Option<&<E as Executor>::PerInvocationOptions>,
prompt: &Prompt,
exec: &E
) -> Result<E::Output, Error<E::Error>>
pub async fn send_message_raw( &mut self, options: Option<&<E as Executor>::PerInvocationOptions>, prompt: &Prompt, exec: &E ) -> Result<E::Output, Error<E::Error>>
Sends a message to the LLM and returns the response.
This method takes a ready prompt and options and sends it to the LLM, adding it and the response to the internal state.
Arguments
options- The options to use when executing the prompt.prompt- The prompt to send.exec- The executor to use.
Returns
A Result containing the LLM’s response as E::Output on success or an Error variant on failure.
Trait Implementations§
Auto Trait Implementations§
impl<E> RefUnwindSafe for Chain<E>where E: RefUnwindSafe,
impl<E> Send for Chain<E>where E: Send,
impl<E> Sync for Chain<E>where E: Sync,
impl<E> Unpin for Chain<E>where E: Unpin,
impl<E> UnwindSafe for Chain<E>where E: 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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request