pub struct ConversationAnalyzer;Expand description
Stateless analyser for conversation quality and engagement.
Implementations§
Source§impl ConversationAnalyzer
impl ConversationAnalyzer
Sourcepub fn analyze_turn(
&self,
text: &str,
role: &str,
_prev_text: Option<&str>,
) -> TurnMetrics
pub fn analyze_turn( &self, text: &str, role: &str, _prev_text: Option<&str>, ) -> TurnMetrics
Analyse a single turn and return its metrics.
prev_text is the text of the immediately preceding turn and is used
only for future response-time calculations; the caller is responsible
for supplying response_time_ms externally if known.
Sourcepub fn extract_keywords(&self, text: &str, top_n: usize) -> Vec<String>
pub fn extract_keywords(&self, text: &str, top_n: usize) -> Vec<String>
Extract the top top_n keywords from text using TF weighting with
stopword removal.
Sourcepub fn detect_topic_drift(
&self,
turns: &[TurnMetrics],
window: usize,
) -> Vec<TopicDrift>
pub fn detect_topic_drift( &self, turns: &[TurnMetrics], window: usize, ) -> Vec<TopicDrift>
Detect topic drift across turns using a sliding window of size
window. Returns one TopicDrift entry per window boundary where
drift is detected (Jaccard similarity < 0.5).
Sourcepub fn compute_engagement(&self, turns: &[TurnMetrics]) -> EngagementMetrics
pub fn compute_engagement(&self, turns: &[TurnMetrics]) -> EngagementMetrics
Compute aggregate engagement metrics across all turns.
Sourcepub fn assess_quality(
&self,
turns: &[TurnMetrics],
has_resolution: bool,
) -> ConversationQuality
pub fn assess_quality( &self, turns: &[TurnMetrics], has_resolution: bool, ) -> ConversationQuality
Assess the overall quality of a conversation.
Sourcepub fn sentiment_score(&self, text: &str) -> f64
pub fn sentiment_score(&self, text: &str) -> f64
Compute a simple sentiment score in [-1.0, 1.0] by counting positive
and negative words.
Sourcepub fn topic_coherence(&self, turns: &[TurnMetrics]) -> f64
pub fn topic_coherence(&self, turns: &[TurnMetrics]) -> f64
Compute average Jaccard similarity between consecutive turns’ keyword
sets. Returns 1.0 for single-turn conversations.
Sourcepub fn identify_questions(&self, text: &str) -> usize
pub fn identify_questions(&self, text: &str) -> usize
Count interrogative patterns in text.
Sourcepub fn analyze_full(
&self,
conversation: &[(String, String)],
) -> (EngagementMetrics, ConversationQuality, Vec<TopicDrift>)
pub fn analyze_full( &self, conversation: &[(String, String)], ) -> (EngagementMetrics, ConversationQuality, Vec<TopicDrift>)
Analyse a full conversation given as (role, text) pairs and return
engagement metrics, quality assessment, and detected topic drifts.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConversationAnalyzer
impl RefUnwindSafe for ConversationAnalyzer
impl Send for ConversationAnalyzer
impl Sync for ConversationAnalyzer
impl Unpin for ConversationAnalyzer
impl UnsafeUnpin for ConversationAnalyzer
impl UnwindSafe for ConversationAnalyzer
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request