pub enum Item {
Text {
text: String,
kind: TextKind,
},
Message(Message),
Bytes(Vec<u8>),
Tensor(Tensor),
Image(Image),
Audio(Audio),
ToolCall(ToolCall),
ToolResult(ToolResult),
SpeechSegment(SpeechSegment),
SpeechResult(SpeechResult),
}Expand description
A single unit of input or output data exchanged with a Session.
Item is a pure-data, owned value: it holds no native handle and is
Send + Sync + Clone. Construct items with the associated functions (e.g.
Item::text, Item::user_message, Item::image_data) or the struct
variants directly, and inspect them by pattern matching.
Variants§
Text
UTF-8 text of a given TextKind.
Message(Message)
A chat message with nested content parts.
Bytes(Vec<u8>)
An opaque byte buffer.
Tensor(Tensor)
A numeric tensor (e.g. an embedding vector).
Image(Image)
An image, inline or by URI.
Audio(Audio)
An audio clip, inline or by URI.
ToolCall(ToolCall)
A model-issued tool/function call.
ToolResult(ToolResult)
The result of executing a tool/function call.
SpeechSegment(SpeechSegment)
A speech-recognition segment (output-only).
SpeechResult(SpeechResult)
A speech-recognition result (output-only).
Implementations§
Source§impl Item
impl Item
Sourcepub fn text(text: impl Into<String>) -> Self
pub fn text(text: impl Into<String>) -> Self
A default-kind Item::Text.
Sourcepub fn reasoning(text: impl Into<String>) -> Self
pub fn reasoning(text: impl Into<String>) -> Self
A reasoning / chain-of-thought Item::Text.
Sourcepub fn message(role: MessageRole, content: impl Into<Vec<Item>>) -> Self
pub fn message(role: MessageRole, content: impl Into<Vec<Item>>) -> Self
A Item::Message with the given role and content parts.
Sourcepub fn system_message(content: impl Into<Vec<Item>>) -> Self
pub fn system_message(content: impl Into<Vec<Item>>) -> Self
A system Item::Message.
Sourcepub fn user_message(content: impl Into<Vec<Item>>) -> Self
pub fn user_message(content: impl Into<Vec<Item>>) -> Self
A user Item::Message.
Sourcepub fn assistant_message(content: impl Into<Vec<Item>>) -> Self
pub fn assistant_message(content: impl Into<Vec<Item>>) -> Self
An assistant Item::Message.
Sourcepub fn developer_message(content: impl Into<Vec<Item>>) -> Self
pub fn developer_message(content: impl Into<Vec<Item>>) -> Self
A developer Item::Message.
Sourcepub fn tool_message(content: impl Into<Vec<Item>>) -> Self
pub fn tool_message(content: impl Into<Vec<Item>>) -> Self
A tool Item::Message.
Sourcepub fn tensor(
data_type: TensorDataType,
shape: impl Into<Vec<i64>>,
data: impl Into<Vec<u8>>,
) -> Self
pub fn tensor( data_type: TensorDataType, shape: impl Into<Vec<i64>>, data: impl Into<Vec<u8>>, ) -> Self
An Item::Tensor from a data type, shape, and raw element bytes.
Sourcepub fn float_tensor(shape: impl Into<Vec<i64>>, data: &[f32]) -> Self
pub fn float_tensor(shape: impl Into<Vec<i64>>, data: &[f32]) -> Self
A TensorDataType::Float Item::Tensor from f32 elements.
Sourcepub fn image_data(
data: impl Into<Vec<u8>>,
format: Option<impl Into<String>>,
) -> Self
pub fn image_data( data: impl Into<Vec<u8>>, format: Option<impl Into<String>>, ) -> Self
An Item::Image from inline bytes and an optional format hint.
Sourcepub fn image_uri(
uri: impl Into<String>,
format: Option<impl Into<String>>,
) -> Self
pub fn image_uri( uri: impl Into<String>, format: Option<impl Into<String>>, ) -> Self
An Item::Image referencing external content by URI.
Sourcepub fn audio_data(
data: impl Into<Vec<u8>>,
format: Option<impl Into<String>>,
sample_rate: i32,
channels: i32,
) -> Self
pub fn audio_data( data: impl Into<Vec<u8>>, format: Option<impl Into<String>>, sample_rate: i32, channels: i32, ) -> Self
An Item::Audio from inline bytes, format hint, and PCM layout.
Sourcepub fn audio_uri(
uri: impl Into<String>,
format: Option<impl Into<String>>,
sample_rate: i32,
channels: i32,
) -> Self
pub fn audio_uri( uri: impl Into<String>, format: Option<impl Into<String>>, sample_rate: i32, channels: i32, ) -> Self
An Item::Audio referencing external content by URI.
Sourcepub fn tool_call(
call_id: impl Into<String>,
name: impl Into<String>,
arguments: impl Into<String>,
) -> Self
pub fn tool_call( call_id: impl Into<String>, name: impl Into<String>, arguments: impl Into<String>, ) -> Self
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
The text content, if this is a Item::Text.
Sourcepub fn as_message(&self) -> Option<&Message>
pub fn as_message(&self) -> Option<&Message>
The Message, if this is a Item::Message.
Sourcepub fn as_tool_call(&self) -> Option<&ToolCall>
pub fn as_tool_call(&self) -> Option<&ToolCall>
The ToolCall, if this is a Item::ToolCall.
Sourcepub fn as_speech_result(&self) -> Option<&SpeechResult>
pub fn as_speech_result(&self) -> Option<&SpeechResult>
The SpeechResult, if this is a Item::SpeechResult.