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)
pub fn apply_sampler(&mut self, sampler: &LlamaSampler)
§Panics
Panics if the vendored sampler throws a C++ exception. llama_sampler_apply is
documented to be a pure logit transform and is not expected to throw; if it does
the failure is propagated as a panic per the crash-fast invariant.
pub fn with_sampler(self, sampler: &mut LlamaSampler) -> Self
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::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::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
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LlamaTokenDataArray
impl Debug for LlamaTokenDataArray
Source§impl PartialEq for LlamaTokenDataArray
impl PartialEq for LlamaTokenDataArray
Source§fn eq(&self, other: &LlamaTokenDataArray) -> bool
fn eq(&self, other: &LlamaTokenDataArray) -> bool
Tests for
self and other values to be equal, and is used by ==.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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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