1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
4pub struct Message {
5 pub role: String,
6 pub content: String,
7}
8
9impl Message {
10 pub fn new(role: impl Into<String>, content: impl Into<String>) -> Self {
11 Self {
12 role: role.into(),
13 content: content.into(),
14 }
15 }
16
17 pub fn is_tool_call(&self) -> bool {
20 self.role == "assistant" && self.content.contains("\"type\":\"tool_use\"")
21 }
22
23 pub fn is_tool_result(&self) -> bool {
26 self.role == "user" && self.content.contains("\"type\":\"tool_result\"")
27 }
28}