pub struct SemanticLlmCache {
pub embedder: Arc<dyn Embedder>,
pub threshold: f32,
/* private fields */
}Fields§
§embedder: Arc<dyn Embedder>§threshold: f32Implementations§
Source§impl SemanticLlmCache
impl SemanticLlmCache
pub fn new(embedder: Arc<dyn Embedder>, threshold: f32) -> Self
pub fn len(&self) -> usize
Sourcepub async fn get_by_text(&self, text: &str) -> Result<Option<CachedTurn>>
pub async fn get_by_text(&self, text: &str) -> Result<Option<CachedTurn>>
Variant get keyed by the prompt text rather than the
hash-based CacheKey. Useful when the caller has the original
prompt available.
pub async fn put_with_text( &self, text: impl Into<String>, key: CacheKey, value: CachedTurn, ) -> Result<()>
Trait Implementations§
Source§impl LlmCache for SemanticLlmCache
impl LlmCache for SemanticLlmCache
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedTurn>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put<'life0, 'async_trait>(
&'life0 self,
_key: CacheKey,
_value: CachedTurn,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for SemanticLlmCache
impl !RefUnwindSafe for SemanticLlmCache
impl Send for SemanticLlmCache
impl Sync for SemanticLlmCache
impl Unpin for SemanticLlmCache
impl UnsafeUnpin for SemanticLlmCache
impl !UnwindSafe for SemanticLlmCache
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