1use adk_core::Part;
4use std::collections::HashSet;
5
6pub fn extract_text(content: &adk_core::Content) -> String {
11 content
12 .parts
13 .iter()
14 .filter_map(|part| match part {
15 Part::Text { text } => Some(text.as_str()),
16 _ => None,
17 })
18 .collect::<Vec<_>>()
19 .join(" ")
20}
21
22pub fn extract_words(text: &str) -> HashSet<String> {
24 text.split_whitespace().filter(|s| !s.is_empty()).map(|s| s.to_lowercase()).collect()
25}
26
27pub fn extract_words_from_content(content: &adk_core::Content) -> HashSet<String> {
29 let mut words = HashSet::new();
30 for part in &content.parts {
31 if let Part::Text { text } = part {
32 words.extend(extract_words(text));
33 }
34 }
35 words
36}