Struct llm_chain::chains::map_reduce::Chain
source · pub struct Chain<S: Step> { /* 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<S: Step> Chain<S>
impl<S: Step> Chain<S>
sourcepub fn new(map: S, reduce: S) -> Chain<S>
pub fn new(map: S, reduce: S) -> Chain<S>
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<E>(
&self,
documents: Vec<Parameters>,
base_parameters: Parameters,
executor: &E
) -> Result<E::Output, MapReduceChainError<E::Error>>where
E: Executor<Step = S>,
pub async fn run<E>( &self, documents: Vec<Parameters>, base_parameters: Parameters, executor: &E ) -> Result<E::Output, MapReduceChainError<E::Error>>where E: Executor<Step = S>,
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, S: Step + Deserialize<'de>> Deserialize<'de> for Chain<S>
impl<'de, S: Step + Deserialize<'de>> Deserialize<'de> for Chain<S>
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<S> StorableEntity for Chain<S>where
S: Step + StorableEntity,
impl<S> StorableEntity for Chain<S>where S: Step + StorableEntity,
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.
Auto Trait Implementations§
impl<S> RefUnwindSafe for Chain<S>where S: RefUnwindSafe,
impl<S> Send for Chain<S>where S: Send,
impl<S> Sync for Chain<S>where S: Sync,
impl<S> Unpin for Chain<S>where S: Unpin,
impl<S> UnwindSafe for Chain<S>where S: UnwindSafe,
Blanket Implementations§
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