pub enum UserContent {
Text(Text),
ToolResult(ToolResult),
Image(Image),
Audio(Audio),
Video(Video),
Document(Document),
}
Expand description
Describes the content of a message, which can be text, a tool result, an image, audio, or a document. Dependent on provider supporting the content type. Multimedia content is generally base64 (defined by it’s format) encoded but additionally supports urls (for some providers).
Variants§
Implementations§
Source§impl UserContent
impl UserContent
Sourcepub fn text(text: impl Into<String>) -> Self
pub fn text(text: impl Into<String>) -> Self
Helper constructor to make creating user text content easier.
Sourcepub fn image(
data: impl Into<String>,
format: Option<ContentFormat>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image( data: impl Into<String>, format: Option<ContentFormat>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Helper constructor to make creating user image content easier.
Sourcepub fn audio(
data: impl Into<String>,
format: Option<ContentFormat>,
media_type: Option<AudioMediaType>,
) -> Self
pub fn audio( data: impl Into<String>, format: Option<ContentFormat>, media_type: Option<AudioMediaType>, ) -> Self
Helper constructor to make creating user audio content easier.
Sourcepub fn document(
data: impl Into<String>,
format: Option<ContentFormat>,
media_type: Option<DocumentMediaType>,
) -> Self
pub fn document( data: impl Into<String>, format: Option<ContentFormat>, media_type: Option<DocumentMediaType>, ) -> Self
Helper constructor to make creating user document content easier.
Sourcepub fn tool_result(
id: impl Into<String>,
content: OneOrMany<ToolResultContent>,
) -> Self
pub fn tool_result( id: impl Into<String>, content: OneOrMany<ToolResultContent>, ) -> Self
Helper constructor to make creating user tool result content easier.
Sourcepub fn tool_result_with_call_id(
id: impl Into<String>,
call_id: String,
content: OneOrMany<ToolResultContent>,
) -> Self
pub fn tool_result_with_call_id( id: impl Into<String>, call_id: String, content: OneOrMany<ToolResultContent>, ) -> Self
Helper constructor to make creating user tool result content easier.
Trait Implementations§
Source§impl Clone for UserContent
impl Clone for UserContent
Source§fn clone(&self) -> UserContent
fn clone(&self) -> UserContent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UserContent
impl Debug for UserContent
Source§impl<'de> Deserialize<'de> for UserContent
impl<'de> Deserialize<'de> for UserContent
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
Source§impl From<String> for UserContent
impl From<String> for UserContent
Source§impl From<UserContent> for Message
impl From<UserContent> for Message
Source§fn from(content: UserContent) -> Self
fn from(content: UserContent) -> Self
Converts to this type from the input type.
Source§impl From<UserContent> for UserContent
impl From<UserContent> for UserContent
Source§fn from(value: UserContent) -> Self
fn from(value: UserContent) -> Self
Converts to this type from the input type.
Source§impl From<UserContent> for UserContent
impl From<UserContent> for UserContent
Source§fn from(content: UserContent) -> Self
fn from(content: UserContent) -> Self
Converts to this type from the input type.
Source§impl PartialEq for UserContent
impl PartialEq for UserContent
Source§impl Serialize for UserContent
impl Serialize for UserContent
Source§impl TryFrom<UserContent> for Part
impl TryFrom<UserContent> for Part
Source§type Error = MessageError
type Error = MessageError
The type returned in the event of a conversion error.
Source§impl TryFrom<UserContent> for UserContent
impl TryFrom<UserContent> for UserContent
Source§type Error = MessageError
type Error = MessageError
The type returned in the event of a conversion error.
impl StructuralPartialEq for UserContent
Auto Trait Implementations§
impl Freeze for UserContent
impl RefUnwindSafe for UserContent
impl Send for UserContent
impl Sync for UserContent
impl Unpin for UserContent
impl UnwindSafe for UserContent
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