pub struct PromptContext { /* private fields */ }Expand description
Manages the cross-utterance prompt prefix fed to the streaming decoder.
Call update_after_eou immediately after an EOU fires, passing the full committed
token list from Committer::committed_tokens. Then pass prompt_tokens() into
DecodeContext::prompt_tokens for every window until the next EOU.
Implementations§
Source§impl PromptContext
impl PromptContext
Sourcepub fn new(max_prompt_tokens: usize, prevtext_token_id: Option<u32>) -> Self
pub fn new(max_prompt_tokens: usize, prevtext_token_id: Option<u32>) -> Self
prevtext_token_id: result of tokenizer.token_to_id("<|prevtext|>").
Pass None for English-only models that lack <|prevtext|> in their vocabulary.
Sourcepub fn update_after_eou(
&mut self,
committed_tokens: &[TokenEmit],
max_new_tokens: usize,
)
pub fn update_after_eou( &mut self, committed_tokens: &[TokenEmit], max_new_tokens: usize, )
Update the stored prompt after an EOU.
Extracts the last max_prompt_tokens regular-token IDs (filter: !is_special),
prepends <|prevtext|> when available and the tail is non-empty, and caps the total
so that prompt.len() + sot(1) + lang(1) + transcribe(1) + max_new_tokens ≤ 448.
Sourcepub fn prompt_tokens(&self) -> &[u32]
pub fn prompt_tokens(&self) -> &[u32]
Returns the prompt tokens to pass into DecodeContext::prompt_tokens.
Empty before the first EOU or after reset.
Auto Trait Implementations§
impl Freeze for PromptContext
impl RefUnwindSafe for PromptContext
impl Send for PromptContext
impl Sync for PromptContext
impl Unpin for PromptContext
impl UnsafeUnpin for PromptContext
impl UnwindSafe for PromptContext
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
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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> 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