use crate::provider::{ContentPart, Message};
use serde_json::{Value, json};
pub(super) fn collect_text(m: &Message) -> String {
m.content
.iter()
.filter_map(|p| match p {
ContentPart::Text { text } => Some(text.clone()),
_ => None,
})
.collect()
}
pub(super) fn collect_thinking(m: &Message) -> String {
m.content
.iter()
.filter_map(|p| match p {
ContentPart::Thinking { text } => Some(text.clone()),
_ => None,
})
.collect()
}
pub(super) fn collect_calls(m: &Message) -> Vec<Value> {
m.content
.iter()
.filter_map(|p| match p {
ContentPart::ToolCall {
id,
name,
arguments,
..
} => Some(json!({
"id": id,
"type": "function",
"function": {"name": name, "arguments": arguments}
})),
_ => None,
})
.collect()
}