use ainl_semantic_tagger::{tag_turn, SemanticTag, TagNamespace};
pub fn extract_turn_semantic_tags_for_memory(
user_message: &str,
assistant_response: Option<&str>,
tools: &[String],
) -> Vec<SemanticTag> {
tag_turn(user_message, assistant_response, tools)
.into_iter()
.filter(|t| {
!matches!(
t.namespace,
TagNamespace::Tool | TagNamespace::Tone
)
})
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn turn_extract_includes_topic_rust() {
let tags = extract_turn_semantic_tags_for_memory(
"I need help with cargo, serde, and async fn in my rust project",
Some("We can use tokio for that."),
&[],
);
assert!(
tags.iter().any(|t| t.namespace == TagNamespace::Topic && t.value == "rust"),
"expected rust topic, got {tags:?}"
);
}
#[test]
fn turn_extract_filters_tools_and_tone() {
let tags = extract_turn_semantic_tags_for_memory("Hello", Some("Hi there"), &["bash".into()]);
assert!(!tags.iter().any(|t| t.namespace == TagNamespace::Tool));
assert!(!tags.iter().any(|t| t.namespace == TagNamespace::Tone));
}
}