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.