pub struct ChatTemplateResult {
pub prompt: String,
pub grammar: Option<String>,
pub grammar_lazy: bool,
pub grammar_triggers: Vec<GrammarTrigger>,
pub preserved_tokens: Vec<String>,
pub additional_stops: Vec<String>,
pub chat_format: i32,
pub parser: Option<String>,
pub thinking_forced_open: bool,
pub parse_tool_calls: bool,
}Expand description
Result of applying a chat template with tool grammar support.
Fields§
§prompt: StringRendered chat prompt.
grammar: Option<String>Optional grammar generated from tool definitions.
grammar_lazy: boolWhether to use lazy grammar sampling.
grammar_triggers: Vec<GrammarTrigger>Lazy grammar triggers derived from the template.
preserved_tokens: Vec<String>Tokens that should be preserved for sampling.
additional_stops: Vec<String>Additional stop sequences added by the template.
chat_format: i32Chat format used for parsing responses.
parser: Option<String>Optional serialized PEG parser for tool-call parsing.
thinking_forced_open: boolWhether the parser expects a forced-open thinking block.
parse_tool_calls: boolWhether tool calls should be parsed from the response.
Implementations§
Source§impl ChatTemplateResult
impl ChatTemplateResult
Sourcepub fn parse_response_oaicompat(
&self,
text: &str,
is_partial: bool,
) -> Result<String, ChatParseError>
pub fn parse_response_oaicompat( &self, text: &str, is_partial: bool, ) -> Result<String, ChatParseError>
Parse a generated response into an OpenAI-compatible message JSON string.
Sourcepub fn streaming_state_oaicompat(
&self,
) -> Result<ChatParseStateOaicompat, ChatParseError>
pub fn streaming_state_oaicompat( &self, ) -> Result<ChatParseStateOaicompat, ChatParseError>
Initialize a streaming parser for OpenAI-compatible chat deltas.
Trait Implementations§
Source§impl Clone for ChatTemplateResult
impl Clone for ChatTemplateResult
Source§fn clone(&self) -> ChatTemplateResult
fn clone(&self) -> ChatTemplateResult
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 ChatTemplateResult
impl Debug for ChatTemplateResult
Source§impl PartialEq for ChatTemplateResult
impl PartialEq for ChatTemplateResult
impl Eq for ChatTemplateResult
impl StructuralPartialEq for ChatTemplateResult
Auto Trait Implementations§
impl Freeze for ChatTemplateResult
impl RefUnwindSafe for ChatTemplateResult
impl Send for ChatTemplateResult
impl Sync for ChatTemplateResult
impl Unpin for ChatTemplateResult
impl UnwindSafe for ChatTemplateResult
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