| 107 | |
| 108 | impl SessionMessage { |
| 109 | pub fn user(session_id: impl Into<String>, text: impl Into<String>) -> Self { |
| 110 | Self { |
| 111 | id: format!("msg_{}", uuid::Uuid::new_v4()), |
| 112 | session_id: session_id.into(), |
| 113 | role: MessageRole::User, |
| 114 | parts: vec![MessagePart { |
| 115 | id: format!("prt_{}", uuid::Uuid::new_v4()), |
| 116 | part_type: PartType::Text { text: text.into(), synthetic: None, ignored: None }, |
| 117 | created_at: Utc::now(), |
| 118 | message_id: None, |
| 119 | }], |
| 120 | created_at: Utc::now(), |
| 121 | metadata: HashMap::new(), |
| 122 | usage: None, |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | pub fn assistant(session_id: impl Into<String>) -> Self { |
| 127 | Self { |