pub enum ChatTemplate {
ChatML,
Llama3,
Qwen,
Raw,
}Expand description
Chat template format.
Variants§
ChatML
SmolLM/Llama-style: <|im_start|>role\ncontent<|im_end|>
Llama3
Llama 3 style: <|start_header_id|>role<|end_header_id|>\n\ncontent<|eot_id|>
Qwen
Qwen style (same as ChatML)
Raw
Raw: just concatenate messages with no special formatting
Implementations§
Source§impl ChatTemplate
impl ChatTemplate
Sourcepub fn from_architecture(arch: &str) -> Self
pub fn from_architecture(arch: &str) -> Self
Detect the appropriate template from a model architecture name.
Sourcepub fn format(&self, messages: &[ChatMessage]) -> String
pub fn format(&self, messages: &[ChatMessage]) -> String
Format a list of messages into a prompt string.
Sourcepub fn format_prompt(&self, prompt: &str) -> String
pub fn format_prompt(&self, prompt: &str) -> String
Format a single user prompt as a chat conversation.
Sourcepub fn format_with_system(&self, system: &str, prompt: &str) -> String
pub fn format_with_system(&self, system: &str, prompt: &str) -> String
Format a single user prompt with a system message.
Trait Implementations§
Source§impl Clone for ChatTemplate
impl Clone for ChatTemplate
Source§fn clone(&self) -> ChatTemplate
fn clone(&self) -> ChatTemplate
Returns a duplicate of the value. Read more
1.0.0 · 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 ChatTemplate
impl Debug for ChatTemplate
Source§impl PartialEq for ChatTemplate
impl PartialEq for ChatTemplate
impl Copy for ChatTemplate
impl StructuralPartialEq for ChatTemplate
Auto Trait Implementations§
impl Freeze for ChatTemplate
impl RefUnwindSafe for ChatTemplate
impl Send for ChatTemplate
impl Sync for ChatTemplate
impl Unpin for ChatTemplate
impl UnsafeUnpin for ChatTemplate
impl UnwindSafe for ChatTemplate
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