pub struct HuggingFaceTemplate { /* private fields */ }Expand description
Jinja2-based Chat Template Engine
Implementations§
Source§impl HuggingFaceTemplate
impl HuggingFaceTemplate
pub fn new( template_str: String, special_tokens: SpecialTokens, format: TemplateFormat, ) -> Result<HuggingFaceTemplate, AprenderError>
pub fn from_tokenizer_config( path: &Path, ) -> Result<HuggingFaceTemplate, AprenderError>
pub fn from_json(json: &str) -> Result<HuggingFaceTemplate, AprenderError>
Trait Implementations§
Source§impl ChatTemplateEngine for HuggingFaceTemplate
impl ChatTemplateEngine for HuggingFaceTemplate
Source§fn format_message(
&self,
role: &str,
content: &str,
) -> Result<String, AprenderError>
fn format_message( &self, role: &str, content: &str, ) -> Result<String, AprenderError>
Format a single message with role and content (for streaming/partial)
Source§fn format_conversation(
&self,
messages: &[ChatMessage],
) -> Result<String, AprenderError>
fn format_conversation( &self, messages: &[ChatMessage], ) -> Result<String, AprenderError>
Format a complete conversation
Source§fn special_tokens(&self) -> &SpecialTokens
fn special_tokens(&self) -> &SpecialTokens
Get special tokens for this template
Source§fn format(&self) -> TemplateFormat
fn format(&self) -> TemplateFormat
Get the detected template format
Source§fn supports_system_prompt(&self) -> bool
fn supports_system_prompt(&self) -> bool
Check if this template supports system prompts
Auto Trait Implementations§
impl !Freeze for HuggingFaceTemplate
impl !RefUnwindSafe for HuggingFaceTemplate
impl !UnwindSafe for HuggingFaceTemplate
impl Send for HuggingFaceTemplate
impl Sync for HuggingFaceTemplate
impl Unpin for HuggingFaceTemplate
impl UnsafeUnpin for HuggingFaceTemplate
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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