pub trait PromptEncoding {
// Required methods
fn encode(
&self,
conversation: &Conversation,
) -> Result<Vec<u32>, EncodingError>;
fn render_conversation(&self, conversation: &Conversation) -> RenderedPrompt;
}Expand description
Render model prompts and encode conversations into token IDs.
Required Methods§
Sourcefn encode(&self, conversation: &Conversation) -> Result<Vec<u32>, EncodingError>
fn encode(&self, conversation: &Conversation) -> Result<Vec<u32>, EncodingError>
Encode a conversation into model token IDs using the attached tokenizer.
The tokenizer must be attached to the encoding before this call, through
the encoding’s with_tokenizer method. Returns
EncodingError::MissingTokenizer when no tokenizer is attached.
Sourcefn render_conversation(&self, conversation: &Conversation) -> RenderedPrompt
fn render_conversation(&self, conversation: &Conversation) -> RenderedPrompt
Render the conversation and the prefix for the next assistant turn.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".