pub struct PromptCompressor { /* private fields */ }Expand description
Prompt compressor for optimizing token usage
Implementations§
Source§impl PromptCompressor
impl PromptCompressor
Sourcepub fn with_whitespace_removal(self, remove: bool) -> Self
pub fn with_whitespace_removal(self, remove: bool) -> Self
Configure whitespace removal
Sourcepub fn with_empty_line_removal(self, remove: bool) -> Self
pub fn with_empty_line_removal(self, remove: bool) -> Self
Configure empty line removal
Sourcepub fn with_line_trimming(self, trim: bool) -> Self
pub fn with_line_trimming(self, trim: bool) -> Self
Configure line trimming
Sourcepub fn estimate_tokens(text: &str) -> u32
pub fn estimate_tokens(text: &str) -> u32
Estimate token count for a text
Uses a simple heuristic: ~4 characters per token for English text. This is approximate and may vary by language and tokenizer.
Sourcepub fn compress(&self, text: &str) -> (String, CompressionStats)
pub fn compress(&self, text: &str) -> (String, CompressionStats)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PromptCompressor
impl RefUnwindSafe for PromptCompressor
impl Send for PromptCompressor
impl Sync for PromptCompressor
impl Unpin for PromptCompressor
impl UnwindSafe for PromptCompressor
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