pub struct ChatMlCodec { /* private fields */ }Implementations§
Source§impl ChatMlCodec
impl ChatMlCodec
pub fn load(model_path: &Path) -> Result<ChatMlCodec, Status>
pub fn from_tokenizer(tok: Arc<dyn Tokenizer>) -> Result<ChatMlCodec, Status>
pub fn with_thinking(self, enabled: bool) -> ChatMlCodec
Trait Implementations§
Source§impl TextCodec for ChatMlCodec
impl TextCodec for ChatMlCodec
fn encode(&self, text: &str) -> Vec<u32>
fn token_bytes(&self, token: u32) -> Vec<u8> ⓘ
fn chat_template_source(&self) -> Option<String>
fn behavior_fingerprint(&self) -> Option<BehaviorFingerprint>
fn encode_content(&self, text: &str) -> Vec<u32>
fn encode_pieces(&self, pieces: &[(&str, bool)]) -> Vec<u32>
fn render_message(&self, role: u32, text: &str) -> Option<Vec<u32>>
fn render_turn_with_tokens( &self, role: u32, pre_text: &str, inner: &[u32], post_text: &str, ) -> Option<Vec<u32>>
fn render_fim(&self, prefix: &str, suffix: &str, mode: u8) -> Option<Vec<u32>>
fn empty_think_tokens(&self) -> Option<Vec<u32>>
fn generation_prefix(&self, state: TurnState) -> Option<Vec<u32>>
fn generation_prefix_with( &self, state: TurnState, thinking: Option<bool>, ) -> Option<Vec<u32>>
fn channel_markers(&self) -> Vec<(u32, u32, u32)>
fn turn_separator(&self) -> Option<Vec<u32>>
fn render_system_with_tools( &self, system: Option<&str>, tool_jsons: &[String], ) -> Option<Vec<u32>>
fn tool_envelope(&self) -> ToolEnvelope
fn tool_call_delimiters(&self) -> Option<(String, String)>
fn marker_literal(&self, token: u32) -> String
fn structural_tag( &self, tool_jsons: &[String], at_least_one: bool, ) -> Option<String>
fn call_grammar(&self, tool_jsons: &[String]) -> Option<String>
fn named_tool_call(&self, raw: &str) -> Option<(String, String)>
fn parse_tool_call_with( &self, raw: &str, schemas: Option<&ToolSchemas>, ) -> Option<(String, String)>
fn validate_template_kwargs( &self, kwargs: &Map<String, Value>, ) -> Result<(), String>
fn supports_reasoning_effort(&self) -> bool
fn reasoning_effort_levels(&self) -> Vec<&'static str>
fn supports_enable_thinking(&self) -> bool
fn render_system_full( &self, system: Option<&str>, tool_jsons: &[String], kwargs: &Map<String, Value>, ) -> Option<Vec<u32>>
fn render_prompt_structured_with( &self, messages: &[ChatMessage], tools: &[String], kwargs: &Map<String, Value>, ) -> Option<Vec<u32>>
fn render_tool_result(&self, _name: &str, content: &str) -> Option<Vec<u32>>
fn render_assistant_with_tool_calls( &self, content: &str, calls: &[(String, String)], ) -> Option<Vec<u32>>
Source§fn render_assistant_with_tool_calls_after_query(
&self,
content: &str,
calls: &[(String, String)],
) -> Option<Vec<u32>>
fn render_assistant_with_tool_calls_after_query( &self, content: &str, calls: &[(String, String)], ) -> Option<Vec<u32>>
The same turn where no user query follows it in the conversation (a
step of a tool loop): some templates render that turn differently from
one a later query put in history (Qwen’s open its reasoning block).
fn decode(&self, tokens: &[u32]) -> String
fn stream_prologue(&self) -> Vec<u32>
fn trailing_generation_prompt( &self, _messages: &[ChatMessage], _tools: &[String], kwargs: &Map<String, Value>, span: &[u32], ) -> usize
fn template_refusal( &self, _messages: &[ChatMessage], _tools: &[String], _kwargs: &Map<String, Value>, ) -> Option<String>
fn render_block(&self, role: u32, kind: u32, payload: &str) -> Option<Vec<u32>>
fn channelizer(&self) -> Box<dyn Channelizer>
fn turn_terminators(&self) -> Vec<u32>
fn render_prompt_structured( &self, messages: &[ChatMessage], tools: &[String], ) -> Option<Vec<u32>>
fn render_prompt( &self, messages: &[(u32, String)], tools: &[String], ) -> Option<Vec<u32>>
fn renders_per_message(&self) -> bool
fn tool_fragment_mode(&self) -> ToolFragmentMode
fn response_format_tag(&self, json_schema: &str) -> Option<String>
fn parse_tool_call(&self, raw: &str) -> Option<(String, String)>
Auto Trait Implementations§
impl !Freeze for ChatMlCodec
impl !RefUnwindSafe for ChatMlCodec
impl !UnwindSafe for ChatMlCodec
impl Send for ChatMlCodec
impl Sync for ChatMlCodec
impl Unpin for ChatMlCodec
impl UnsafeUnpin for ChatMlCodec
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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