pub struct CachePromptConfig {
pub enabled: bool,
pub min_content_length: usize,
pub cache_system_prompt: bool,
pub cache_last_n_messages: usize,
}Expand description
Configuration for automatic prompt cache control marking.
§Fields
enabled: Whether to apply cache control (default: true)min_content_length: Minimum message length to auto-cache (default: 1000)cache_system_prompt: Whether to cache system prompts (default: true)cache_last_n_messages: Number of recent user messages to cache (default: 3)
§Example
use edgequake_llm::cache_prompt::CachePromptConfig;
// Use defaults
let config = CachePromptConfig::default();
// Custom configuration
let config = CachePromptConfig {
enabled: true,
min_content_length: 500,
cache_system_prompt: true,
cache_last_n_messages: 5,
};Fields§
§enabled: boolWhether cache control marking is enabled.
min_content_length: usizeMinimum content length (in characters) to auto-cache user messages.
Messages shorter than this threshold are not automatically cached unless they are system prompts or in the last N messages.
cache_system_prompt: boolWhether to cache the system prompt.
System prompts rarely change and are excellent cache candidates.
cache_last_n_messages: usizeNumber of recent user messages to cache.
Caching recent messages helps with conversation context retention.
Implementations§
Source§impl CachePromptConfig
impl CachePromptConfig
Sourcepub fn system_only() -> Self
pub fn system_only() -> Self
Create a config that only caches system prompts.
Sourcepub fn aggressive() -> Self
pub fn aggressive() -> Self
Create an aggressive caching config.
Caches more content for maximum cost reduction.
Trait Implementations§
Source§impl Clone for CachePromptConfig
impl Clone for CachePromptConfig
Source§fn clone(&self) -> CachePromptConfig
fn clone(&self) -> CachePromptConfig
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 CachePromptConfig
impl Debug for CachePromptConfig
Source§impl Default for CachePromptConfig
impl Default for CachePromptConfig
Source§impl<'de> Deserialize<'de> for CachePromptConfig
impl<'de> Deserialize<'de> for CachePromptConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CachePromptConfig
impl RefUnwindSafe for CachePromptConfig
impl Send for CachePromptConfig
impl Sync for CachePromptConfig
impl Unpin for CachePromptConfig
impl UnsafeUnpin for CachePromptConfig
impl UnwindSafe for CachePromptConfig
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