Struct llm_chain::chains::sequential::Chain
source · pub struct Chain<E: Executor> { /* private fields */ }
Expand description
A sequential chain is a chain where each step is executed in order, with the output of the previous step being available to the next step.
Implementations§
source§impl<E: Executor> Chain<E>
impl<E: Executor> Chain<E>
sourcepub fn new(steps: Vec<Step<E>>) -> Chain<E>
pub fn new(steps: Vec<Step<E>>) -> Chain<E>
Creates a new Chain
instance with the given sequence of steps.
Arguments
steps
- A vector ofStep<E>
objects that define the sequence of steps for the chain.
sourcepub fn of_one(step: Step<E>) -> Chain<E>
pub fn of_one(step: Step<E>) -> Chain<E>
Creates a new Chain
instance with a single step.
Arguments
step
- AStep<E>
object that defines the single step for the chain.
sourcepub async fn run(
&self,
parameters: Parameters,
executor: &E
) -> Result<E::Output, SequentialChainError<E::Error>>
pub async fn run( &self, parameters: Parameters, executor: &E ) -> Result<E::Output, SequentialChainError<E::Error>>
Executes the chain with the given parameters and executor.
This method runs each step in the chain in sequence, passing the output of the previous step to the next step. If the chain is empty, an error is returned.
Arguments
parameters
- AParameters
object containing the input parameters for the chain.executor
- A reference to an executor that implements theExecutor
trait.
Returns
Ok(E::Output)
- If the chain executes successfully, the output of the last step is returned.Err(SequentialChainError<E::Error>)
- If an error occurs during the execution of the chain, the error is returned.
Trait Implementations§
source§impl<'de, E: Executor> Deserialize<'de> for Chain<E>
impl<'de, E: Executor> Deserialize<'de> for Chain<E>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<E: Executor> StorableEntity for Chain<E>
impl<E: Executor> StorableEntity for Chain<E>
fn get_metadata() -> Vec<(String, String)>
fn to_envelope(self) -> Envelope<Self>where Self: Sized,
fn from_envelope(envelope: Envelope<Self>) -> Self
fn read_file_sync(path: &str) -> Result<Self, EnvelopeError>
fn write_file_sync(self, path: &str) -> Result<(), EnvelopeError>
Auto Trait Implementations§
impl<E> RefUnwindSafe for Chain<E>where <E as Executor>::PerInvocationOptions: RefUnwindSafe,
impl<E> Send for Chain<E>
impl<E> Sync for Chain<E>
impl<E> Unpin for Chain<E>where <E as Executor>::PerInvocationOptions: Unpin,
impl<E> UnwindSafe for Chain<E>where <E as Executor>::PerInvocationOptions: 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