pub struct Message {
pub role: Option<String>,
pub content: Option<MessageContent>,
pub reasoning_content: Option<String>,
pub audio: Option<AudioContent>,
pub tool_calls: Option<Vec<ToolCallMessage>>,
}Expand description
Notes:
- Depending on the model/mode, only one of
content,audio, ortool_callsmay be set. - Prefer
contentfor final text;reasoning_contentmay contain internal traces (when available).
Assistant message payload
Fields§
§role: Option<String>Role of the message, defaults to “assistant”
content: Option<MessageContent>Current dialog content.
If function/tool calling is used, this may be null; otherwise contains
the inference result. For some models, content may include thinking
traces within <think> tags, with final output outside.
reasoning_content: Option<String>Reasoning chain content (only for specific models)
audio: Option<AudioContent>Audio payload for voice models (glm-4-voice)
tool_calls: Option<Vec<ToolCallMessage>>Generated tool/function calls
Implementations§
Source§impl Message
impl Message
Sourcepub fn content(&self) -> Option<&MessageContent>
pub fn content(&self) -> Option<&MessageContent>
Dialog content (may include <think> traces for some models).
Sourcepub fn content_str(&self) -> Option<&str>
pub fn content_str(&self) -> Option<&str>
Return the assistant text when content is a JSON string; None
otherwise (absent, null, or the array-of-parts form). Convenience over
content for the common case where the model returns a
plain string.
Sourcepub fn reasoning_content(&self) -> Option<&str>
pub fn reasoning_content(&self) -> Option<&str>
Reasoning-chain content, when the model exposes it.
Sourcepub fn audio(&self) -> Option<&AudioContent>
pub fn audio(&self) -> Option<&AudioContent>
Audio payload, for voice models.
Sourcepub fn tool_calls(&self) -> Option<&[ToolCallMessage]>
pub fn tool_calls(&self) -> Option<&[ToolCallMessage]>
Tool/function calls the model wants the caller to execute.