pub struct UserPromptHandler {
confidence_threshold: f32,
search_intent_threshold: f32,
context_config: AdaptiveContextConfig,
recall_service: Option<RecallService>,
llm_provider: Option<Arc<dyn LlmProvider>>,
search_intent_config: SearchIntentConfig,
capture_service: Option<CaptureService>,
auto_capture_enabled: bool,
}Expand description
Handles UserPromptSubmit hook events.
Detects signals for memory capture in user prompts and search intent. When auto-capture is enabled, automatically captures memories when high-confidence signals are detected.
Fields§
§confidence_threshold: f32Minimum confidence threshold for capture.
search_intent_threshold: f32Minimum confidence threshold for search intent injection.
context_config: AdaptiveContextConfigConfiguration for adaptive context injection.
recall_service: Option<RecallService>Optional recall service for memory retrieval.
llm_provider: Option<Arc<dyn LlmProvider>>Optional LLM provider for enhanced intent classification.
search_intent_config: SearchIntentConfigConfiguration for search intent detection.
capture_service: Option<CaptureService>Optional capture service for auto-capture.
auto_capture_enabled: boolWhether auto-capture is enabled.
Implementations§
Source§impl UserPromptHandler
impl UserPromptHandler
Sourcepub const fn with_confidence_threshold(self, threshold: f32) -> Self
pub const fn with_confidence_threshold(self, threshold: f32) -> Self
Sets the confidence threshold for capture.
Sourcepub const fn with_search_intent_threshold(self, threshold: f32) -> Self
pub const fn with_search_intent_threshold(self, threshold: f32) -> Self
Sets the confidence threshold for search intent injection.
Sourcepub fn with_context_config(self, config: AdaptiveContextConfig) -> Self
pub fn with_context_config(self, config: AdaptiveContextConfig) -> Self
Sets the adaptive context configuration.
Sourcepub fn with_recall_service(self, service: RecallService) -> Self
pub fn with_recall_service(self, service: RecallService) -> Self
Sets the recall service for memory retrieval.
Sourcepub fn with_llm_provider(self, provider: Arc<dyn LlmProvider>) -> Self
pub fn with_llm_provider(self, provider: Arc<dyn LlmProvider>) -> Self
Sets the LLM provider for enhanced intent classification.
Sourcepub fn with_search_intent_config(self, config: SearchIntentConfig) -> Self
pub fn with_search_intent_config(self, config: SearchIntentConfig) -> Self
Sets the search intent configuration.
Sourcepub fn with_capture_service(self, service: CaptureService) -> Self
pub fn with_capture_service(self, service: CaptureService) -> Self
Sets the capture service for auto-capture.
Sourcepub const fn with_auto_capture(self, enabled: bool) -> Self
pub const fn with_auto_capture(self, enabled: bool) -> Self
Enables or disables auto-capture.
Sourcefn build_memory_context(&self, intent: &SearchIntent) -> MemoryContext
fn build_memory_context(&self, intent: &SearchIntent) -> MemoryContext
Builds memory context from a search intent using the SearchContextBuilder.
Sourcefn detect_search_intent(&self, prompt: &str) -> Option<SearchIntent>
fn detect_search_intent(&self, prompt: &str) -> Option<SearchIntent>
Detects search intent from the prompt.
Uses LLM-based classification when an LLM provider is configured, otherwise falls back to keyword-based detection.
Sourcefn classify_intent(&self, prompt: &str) -> SearchIntent
fn classify_intent(&self, prompt: &str) -> SearchIntent
Classifies intent using the appropriate detection method.
Sourcefn classify_without_llm(&self, prompt: &str) -> SearchIntent
fn classify_without_llm(&self, prompt: &str) -> SearchIntent
Classifies intent without an LLM provider.
Sourcefn detect_signals(&self, prompt: &str) -> Vec<CaptureSignal>
fn detect_signals(&self, prompt: &str) -> Vec<CaptureSignal>
Detects capture signals in the prompt.
Sourcefn check_patterns(
&self,
patterns: &[Regex],
namespace: Namespace,
prompt: &str,
signals: &mut Vec<CaptureSignal>,
)
fn check_patterns( &self, patterns: &[Regex], namespace: Namespace, prompt: &str, signals: &mut Vec<CaptureSignal>, )
Checks patterns for a specific namespace and adds matching signals.
Sourcefn extract_content(&self, prompt: &str) -> String
fn extract_content(&self, prompt: &str) -> String
Extracts the content to capture from the prompt.
fn serialize_response(response: &Value) -> Result<String>
Sourcefn try_auto_capture(
&self,
content: &str,
signal: &CaptureSignal,
metadata: &mut Value,
) -> Option<CaptureResult>
fn try_auto_capture( &self, content: &str, signal: &CaptureSignal, metadata: &mut Value, ) -> Option<CaptureResult>
Attempts to auto-capture a memory if enabled and conditions are met.
Returns the capture result if successful, and updates metadata with outcome.
fn handle_inner( &self, input: &str, prompt_len: &mut usize, intent_detected: &mut bool, ) -> Result<String>
Trait Implementations§
Source§impl Default for UserPromptHandler
impl Default for UserPromptHandler
Source§impl HookHandler for UserPromptHandler
impl HookHandler for UserPromptHandler
Auto Trait Implementations§
impl !Freeze for UserPromptHandler
impl !RefUnwindSafe for UserPromptHandler
impl Send for UserPromptHandler
impl Sync for UserPromptHandler
impl Unpin for UserPromptHandler
impl !UnwindSafe for UserPromptHandler
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> 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].