pub trait ExecutorTokenCountExt: Executor {
// Provided method
fn split_to_fit(
&self,
step: &Step,
doc: &Parameters,
base_parameters: &Parameters,
chunk_overlap: Option<usize>,
) -> Result<Vec<Parameters>, PromptTokensError> { ... }
}
Expand description
An extension trait for the Executor
trait that provides additional methods for working
with token counts.
Provided Methods§
Sourcefn split_to_fit(
&self,
step: &Step,
doc: &Parameters,
base_parameters: &Parameters,
chunk_overlap: Option<usize>,
) -> Result<Vec<Parameters>, PromptTokensError>
fn split_to_fit( &self, step: &Step, doc: &Parameters, base_parameters: &Parameters, chunk_overlap: Option<usize>, ) -> Result<Vec<Parameters>, PromptTokensError>
Splits a Parameters
object into multiple smaller Parameters
objects that fit within
the context window size supported by the given model.
§Arguments
step
- The step that will process the Parameters. Has impact on tokenizer & text splitter useddoc
- The parameter object to split into multiple, smaller, parameterschunk_overlap
- The amount of tokens each split part should overlap with previous & next chunk
§Errors
Returns a PromptTokensError
if there is an issue computing the tokens.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl<E: Executor> ExecutorTokenCountExt for E
Blanket implementation of ExecutorTokenCountExt for all Executors