pub enum Content {
Text(String),
Json(Value),
Image {
url: Option<String>,
mime: Option<String>,
name: Option<String>,
},
Audio {
url: Option<String>,
mime: Option<String>,
},
}Expand description
Message content — moved to an enum to support multimodal and structured content
Variants§
Text(String)
Json(Value)
Generic JSON content for structured payloads (e.g. function call args)
Image
Reference to an image (url) or metadata; adapters may upload or inline as needed
Audio
Reference to audio content
Implementations§
Source§impl Content
impl Content
Sourcepub fn as_text(&self) -> String
pub fn as_text(&self) -> String
Return a best-effort textual representation for legacy code paths
Sourcepub fn new_image(
url: Option<String>,
mime: Option<String>,
name: Option<String>,
) -> Self
pub fn new_image( url: Option<String>, mime: Option<String>, name: Option<String>, ) -> Self
Convenience constructor for image content
Sourcepub fn new_audio(url: Option<String>, mime: Option<String>) -> Self
pub fn new_audio(url: Option<String>, mime: Option<String>) -> Self
Convenience constructor for audio content
Sourcepub fn from_image_file<P: AsRef<Path>>(path: P) -> Self
pub fn from_image_file<P: AsRef<Path>>(path: P) -> Self
Create image content from a file path - the file will be automatically processed (uploaded or inlined as data URL) by the AI client when used in a request
Sourcepub fn from_audio_file<P: AsRef<Path>>(path: P) -> Self
pub fn from_audio_file<P: AsRef<Path>>(path: P) -> Self
Create audio content from a file path - the file will be automatically processed (uploaded or inlined as data URL) by the AI client when used in a request
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Content
impl<'de> Deserialize<'de> for Content
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>,
Source§impl From<&str> for Content
Allow Into<Content> for &str to enable ergonomic Message::new(Role::User, "hello")
impl From<&str> for Content
Allow Into<Content> for &str to enable ergonomic Message::new(Role::User, "hello")