pub struct ChatTemplateEngine { /* private fields */ }Expand description
Chat template engine for formatting prompts
Implementations§
Source§impl ChatTemplateEngine
impl ChatTemplateEngine
Sourcepub fn new(format: TemplateFormat) -> Self
pub fn new(format: TemplateFormat) -> Self
Create a new template engine with the specified format
Sourcepub fn from_model(model_name: &str) -> Self
pub fn from_model(model_name: &str) -> Self
Create engine from model name (auto-detect format)
Sourcepub fn format(&self) -> TemplateFormat
pub fn format(&self) -> TemplateFormat
Get the template format
Sourcepub fn apply(&self, messages: &[ChatMessage]) -> String
pub fn apply(&self, messages: &[ChatMessage]) -> String
Apply template to a list of chat messages
Sourcepub fn apply_prompt(&self, prompt: &str) -> String
pub fn apply_prompt(&self, prompt: &str) -> String
Apply template to a simple prompt string
Trait Implementations§
Source§impl Clone for ChatTemplateEngine
impl Clone for ChatTemplateEngine
Source§fn clone(&self) -> ChatTemplateEngine
fn clone(&self) -> ChatTemplateEngine
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 ChatTemplateEngine
impl Debug for ChatTemplateEngine
Auto Trait Implementations§
impl Freeze for ChatTemplateEngine
impl RefUnwindSafe for ChatTemplateEngine
impl Send for ChatTemplateEngine
impl Sync for ChatTemplateEngine
impl Unpin for ChatTemplateEngine
impl UnwindSafe for ChatTemplateEngine
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> 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>
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