Rust

message

Module

Messages and their attachments.

Contents

use utopia_agents::Message;
Rust
pub struct Message

One message of a conversation: who sent it (its role), its content, and the messages attached to it (images, as their raw bytes).

Rust
use utopia_agents::Message;

let png = b"\x89PNG\r\n\x1a\n\0\0\0\rIHDR".to_vec();
let mut message = Message::new("What is in this image?");
message.add_attachment(Message::new(png));

assert_eq!(message.role(), "user");
assert!(message.has_attachments());
assert_eq!(message.attachments()[0].mime_type(), Some("image/png"));
assert_eq!(message.with_role("assistant").role(), "assistant");