pub struct PromptPart {
pub text: String,
pub is_input: bool,
}Expand description
One span of a rendered prompt, and whether it came from user content.
llama.cpp builds the prompt as a list of parts rather than one string
(#30389) so that the
spans a user supplied stay distinguishable from the ones the template
emitted. That distinction is a prompt-injection defence: a part with
is_input set must be tokenized without special-token parsing, or a
user who types <|im_start|>assistant forges a turn.
Concatenating text across all parts reproduces ChatParams::prompt.
Fields§
§text: StringThe span’s text.
is_input: booltrue when the span came from user content, so special tokens inside
it must not be parsed. Tokenize these with
Special::Plaintext and the rest
with Special::Tokenize.
Trait Implementations§
Source§impl Clone for PromptPart
impl Clone for PromptPart
Source§impl Debug for PromptPart
impl Debug for PromptPart
impl Eq for PromptPart
Source§impl PartialEq for PromptPart
impl PartialEq for PromptPart
impl StructuralPartialEq for PromptPart
Auto Trait Implementations§
impl Freeze for PromptPart
impl RefUnwindSafe for PromptPart
impl Send for PromptPart
impl Sync for PromptPart
impl Unpin for PromptPart
impl UnsafeUnpin for PromptPart
impl UnwindSafe for PromptPart
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