pub struct Message {
pub id: String,
pub role: Role,
pub content: String,
pub timestamp: i64,
pub tool_calls: Vec<ToolCall>,
pub tool_result: Option<ToolResult>,
pub token_count: Option<u32>,
pub pinned: bool,
}Expand description
A single message in the conversation.
Fields§
§id: StringStable identifier for the message (used to address pins and tool results).
role: RoleWho produced the message.
content: StringThe message text.
timestamp: i64Creation time as a Unix timestamp in milliseconds.
tool_calls: Vec<ToolCall>Tool calls made by the assistant (only when role = Assistant).
tool_result: Option<ToolResult>Tool execution result (only when role = ToolResult).
token_count: Option<u32>Token count for this message (populated after tokenization).
pinned: boolWhether this message is pinned. Pinned messages always survive context pruning, regardless of the token budget or prune strategy.
Implementations§
Source§impl Message
impl Message
Sourcepub fn system(id: impl Into<String>, content: impl Into<String>) -> Self
pub fn system(id: impl Into<String>, content: impl Into<String>) -> Self
Build a system message.
use orion_core::Message;
let sys = Message::system("msg-1", "You are helpful.");
assert_eq!(sys.content, "You are helpful.");Sourcepub fn assistant(id: impl Into<String>, content: impl Into<String>) -> Self
pub fn assistant(id: impl Into<String>, content: impl Into<String>) -> Self
Build an assistant message.
Sourcepub fn tool_result(
id: impl Into<String>,
tool_call_id: impl Into<String>,
tool_name: impl Into<String>,
content: impl Into<String>,
is_error: bool,
) -> Self
pub fn tool_result( id: impl Into<String>, tool_call_id: impl Into<String>, tool_name: impl Into<String>, content: impl Into<String>, is_error: bool, ) -> Self
Build a tool-result message, linking it back to the assistant’s
ToolCall via tool_call_id.
use orion_core::Message;
let result = Message::tool_result(
"msg-4", // message id
"call-1", // tool_call_id (links to the assistant's request)
"read_file", // tool name
"file contents...", // result content
false, // is_error
);
assert!(result.tool_result.is_some());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more