pub fn detect_topic_shift(
current_tag: Option<&str>,
next_tag_number: u32,
new_message_embedding: &[f32],
recent_embeddings: &[Vec<f32>],
) -> TopicSegmentExpand description
Detect whether a new user message is a continuation of the current topic or a shift to a new one.
Uses embedding cosine similarity against recent assistant responses. Returns the topic tag to assign to this message.
current_tag: the topic tag of the most recent message (e.g. “topic-2”).
Pass None for the first message in a session.
next_tag_number: the next available topic number (e.g. 3 if “topic-2” is current).
new_message_embedding: embedding of the user’s new message.
recent_embeddings: embeddings of the most recent LOOKBACK_TURNS messages
(from newest to oldest).