Struct llm_chain::chains::map_reduce::Chain
source · pub struct Chain<E: Executor> { /* private fields */ }Expand description
The Chain struct represents a map-reduce chain, consisting of a map step and a reduce step.
The struct is generic over the type of the Step and provides methods for constructing and
executing the chain using a given Executor.
Implementations§
source§impl<E: Executor> Chain<E>
impl<E: Executor> Chain<E>
sourcepub fn new(map: Step<E>, reduce: Step<E>) -> Chain<E>
pub fn new(map: Step<E>, reduce: Step<E>) -> Chain<E>
Constructs a new Chain with the given map and reduce steps.
The new function takes two instances of Step and returns a new Chain instance.
sourcepub async fn run(
&self,
documents: Vec<Parameters>,
base_parameters: Parameters,
executor: &E
) -> Result<E::Output, MapReduceChainError<E::Error>>
pub async fn run( &self, documents: Vec<Parameters>, base_parameters: Parameters, executor: &E ) -> Result<E::Output, MapReduceChainError<E::Error>>
Executes the map-reduce chain using the provided Executor.
The run function takes a vector of input documents, a base set of parameters, and a reference
to an Executor. It processes the input documents using the map step and the reduce step,
and returns the result as an Option<E::Output>.
The function is asynchronous and must be awaited.
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>,
source§impl<E> StorableEntity for Chain<E>where
E: Executor,
impl<E> StorableEntity for Chain<E>where E: Executor,
Implements the StorableEntity trait for the Chain struct.
This implementation provides a method for extracting metadata from a Chain instance, in order to identify it
source§fn get_metadata() -> Vec<(String, String)>
fn get_metadata() -> Vec<(String, String)>
Returns metadata about the Chain instance.
The metadata is returned as a vector of tuples, where each tuple contains a key-value pair representing a metadata field and its value.
This method also extracts metadata from the Step instances associated with the Chain.
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
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>
T in a tonic::Request