pub struct ContextManager { /* private fields */ }Expand description
Manager for handling context in a smart, efficient way
Implementations§
Source§impl ContextManager
impl ContextManager
Sourcepub fn new() -> ContextManager
pub fn new() -> ContextManager
Create a new context manager
Sourcepub fn with_tool_provider(
self,
provider: Box<dyn Fn() -> Vec<(String, String)> + Sync + Send>,
) -> ContextManager
pub fn with_tool_provider( self, provider: Box<dyn Fn() -> Vec<(String, String)> + Sync + Send>, ) -> ContextManager
Set a tool provider callback that supplies available tool name/summary pairs.
Sourcepub fn with_max_tokens(self, max_tokens: usize) -> ContextManager
pub fn with_max_tokens(self, max_tokens: usize) -> ContextManager
Set maximum context tokens
Sourcepub fn with_history_threshold(self, threshold: usize) -> ContextManager
pub fn with_history_threshold(self, threshold: usize) -> ContextManager
Set history summarization threshold
Sourcepub fn without_tool_schemas(self) -> ContextManager
pub fn without_tool_schemas(self) -> ContextManager
Disable tool schema inclusion for simpler contexts
Sourcepub fn analyze(&self, request: &str) -> RequestAnalysis
pub fn analyze(&self, request: &str) -> RequestAnalysis
Analyze a request to determine what context is needed
Sourcepub fn resolve_context<M>(
&self,
_request: &str,
analysis: &RequestAnalysis,
history: &[M],
workspace_dir: Option<&Path>,
) -> ResolvedContext
pub fn resolve_context<M>( &self, _request: &str, analysis: &RequestAnalysis, history: &[M], workspace_dir: Option<&Path>, ) -> ResolvedContext
Resolve context for a request
Sourcepub fn resolve_simple(
&self,
request: &str,
workspace_dir: Option<&Path>,
) -> ResolvedContext
pub fn resolve_simple( &self, request: &str, workspace_dir: Option<&Path>, ) -> ResolvedContext
Simple resolve without history
Sourcepub fn resolve_for_analysis_with_history<M>(
&self,
analysis: &RequestAnalysis,
history: &[M],
workspace_dir: Option<&Path>,
) -> ResolvedContext
pub fn resolve_for_analysis_with_history<M>( &self, analysis: &RequestAnalysis, history: &[M], workspace_dir: Option<&Path>, ) -> ResolvedContext
Resolve context for a pre-analyzed request with history
Sourcepub fn summarize_history<M>(&self, history: &[M]) -> String
pub fn summarize_history<M>(&self, history: &[M]) -> String
Summarize history with intelligent threshold (LOW-1)
Sourcepub fn resolve_for_analysis(
&self,
analysis: &RequestAnalysis,
workspace_dir: Option<&Path>,
) -> ResolvedContext
pub fn resolve_for_analysis( &self, analysis: &RequestAnalysis, workspace_dir: Option<&Path>, ) -> ResolvedContext
Resolve context for a pre-analyzed request (no history)
Sourcepub fn cache_stats(&self) -> ContextManagerStats
pub fn cache_stats(&self) -> ContextManagerStats
Get cache statistics
Sourcepub fn clear_caches(&self)
pub fn clear_caches(&self)
Clear all caches
Sourcepub fn compute_request_hash(&self, analysis: &RequestAnalysis) -> u64
pub fn compute_request_hash(&self, analysis: &RequestAnalysis) -> u64
Compute a hash for a request based on categories and key entities
Sourcepub fn get_cached_response(
&self,
analysis: &RequestAnalysis,
) -> Option<CachedResponse>
pub fn get_cached_response( &self, analysis: &RequestAnalysis, ) -> Option<CachedResponse>
Check if we have a cached response for a similar request
Sourcepub fn cache_response(&self, analysis: &RequestAnalysis, response: String)
pub fn cache_response(&self, analysis: &RequestAnalysis, response: String)
Cache a response for potential reuse
Sourcepub fn is_similar_to_recent(&self, analysis: &RequestAnalysis) -> bool
pub fn is_similar_to_recent(&self, analysis: &RequestAnalysis) -> bool
Check if a request is similar to a recent one (for deduplication)
Trait Implementations§
Source§impl Default for ContextManager
impl Default for ContextManager
Source§fn default() -> ContextManager
fn default() -> ContextManager
Auto Trait Implementations§
impl Freeze for ContextManager
impl !RefUnwindSafe for ContextManager
impl Send for ContextManager
impl Sync for ContextManager
impl Unpin for ContextManager
impl !UnwindSafe for ContextManager
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().