pub struct LlamaTokenDataArray {
pub data: Vec<LlamaTokenData>,
pub selected: Option<usize>,
pub sorted: bool,
}Fields§
§data: Vec<LlamaTokenData>§selected: Option<usize>§sorted: boolImplementations§
Source§impl LlamaTokenDataArray
impl LlamaTokenDataArray
pub const fn new(data: Vec<LlamaTokenData>, sorted: bool) -> Self
pub fn from_iter<TIterator>(data: TIterator, sorted: bool) -> Selfwhere
TIterator: IntoIterator<Item = LlamaTokenData>,
pub fn selected_token(&self) -> Option<LlamaToken>
Source§impl LlamaTokenDataArray
impl LlamaTokenDataArray
Sourcepub unsafe fn modify_as_c_llama_token_data_array<TResult>(
&mut self,
modify: impl FnOnce(&mut llama_token_data_array) -> TResult,
) -> TResult
pub unsafe fn modify_as_c_llama_token_data_array<TResult>( &mut self, modify: impl FnOnce(&mut llama_token_data_array) -> TResult, ) -> TResult
§Panics
Panics if some of the safety conditions are not met. (we cannot check all of them at runtime so breaking them is UB)
§Safety
The returned array formed by the data pointer and the length must entirely consist of initialized token data and the length must be less than the capacity of this array’s data buffer. If the data is not sorted, sorted must be false.
Sourcepub fn apply_sampler(
&mut self,
sampler: &LlamaSampler,
) -> Result<(), SamplerApplyError>
pub fn apply_sampler( &mut self, sampler: &LlamaSampler, ) -> Result<(), SamplerApplyError>
§Errors
Returns SamplerApplyError if the sampler pointer is null, the vendored
sampler runs out of memory, or it throws a C++ exception while applying.
Sourcepub fn with_sampler(
self,
sampler: &mut LlamaSampler,
) -> Result<Self, SamplerApplyError>
pub fn with_sampler( self, sampler: &mut LlamaSampler, ) -> Result<Self, SamplerApplyError>
§Errors
Returns SamplerApplyError if applying the sampler fails.
Sourcepub fn sample_token(
&mut self,
seed: u32,
) -> Result<LlamaToken, TokenSamplingError>
pub fn sample_token( &mut self, seed: u32, ) -> Result<LlamaToken, TokenSamplingError>
§Errors
Returns TokenSamplingError::SamplerApply if applying the sampler fails, or
TokenSamplingError::NoTokenSelected if the sampler fails to select a token.
Sourcepub fn sample_token_greedy(&mut self) -> Result<LlamaToken, TokenSamplingError>
pub fn sample_token_greedy(&mut self) -> Result<LlamaToken, TokenSamplingError>
§Errors
Returns TokenSamplingError::SamplerApply if applying the sampler fails, or
TokenSamplingError::NoTokenSelected if the sampler fails to select a token.
Trait Implementations§
Source§impl Clone for LlamaTokenDataArray
impl Clone for LlamaTokenDataArray
Source§fn clone(&self) -> LlamaTokenDataArray
fn clone(&self) -> LlamaTokenDataArray
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LlamaTokenDataArray
impl Debug for LlamaTokenDataArray
Source§impl PartialEq for LlamaTokenDataArray
impl PartialEq for LlamaTokenDataArray
impl StructuralPartialEq for LlamaTokenDataArray
Auto Trait Implementations§
impl Freeze for LlamaTokenDataArray
impl RefUnwindSafe for LlamaTokenDataArray
impl Send for LlamaTokenDataArray
impl Sync for LlamaTokenDataArray
impl Unpin for LlamaTokenDataArray
impl UnsafeUnpin for LlamaTokenDataArray
impl UnwindSafe for LlamaTokenDataArray
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more