pub enum UserContent {
Text(Text),
ToolResult(ToolResult),
Image(Image),
Audio(Audio),
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>) -> UserContent
pub fn text(text: impl Into<String>) -> UserContent
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>,
) -> UserContent
pub fn image( data: impl Into<String>, format: Option<ContentFormat>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> UserContent
Helper constructor to make creating user image content easier.
Sourcepub fn audio(
data: impl Into<String>,
format: Option<ContentFormat>,
media_type: Option<AudioMediaType>,
) -> UserContent
pub fn audio( data: impl Into<String>, format: Option<ContentFormat>, media_type: Option<AudioMediaType>, ) -> UserContent
Helper constructor to make creating user audio content easier.
Sourcepub fn document(
data: impl Into<String>,
format: Option<ContentFormat>,
media_type: Option<DocumentMediaType>,
) -> UserContent
pub fn document( data: impl Into<String>, format: Option<ContentFormat>, media_type: Option<DocumentMediaType>, ) -> UserContent
Helper constructor to make creating user document content easier.
Sourcepub fn tool_result(
id: impl Into<String>,
content: OneOrMany<ToolResultContent>,
) -> UserContent
pub fn tool_result( id: impl Into<String>, content: OneOrMany<ToolResultContent>, ) -> UserContent
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>,
) -> UserContent
pub fn tool_result_with_call_id( id: impl Into<String>, call_id: String, content: OneOrMany<ToolResultContent>, ) -> UserContent
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<UserContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<UserContent, <__D as Deserializer<'de>>::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§fn from(text: String) -> UserContent
fn from(text: String) -> UserContent
Converts to this type from the input type.
Source§impl From<UserContent> for Message
impl From<UserContent> for Message
Source§fn from(content: UserContent) -> Message
fn from(content: UserContent) -> Message
Converts to this type from the input type.
Source§impl From<UserContent> for UserContent
impl From<UserContent> for UserContent
Source§fn from(value: UserContent) -> UserContent
fn from(value: UserContent) -> UserContent
Converts to this type from the input type.
Source§impl From<UserContent> for UserContent
impl From<UserContent> for UserContent
Source§fn from(content: UserContent) -> UserContent
fn from(content: UserContent) -> UserContent
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§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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§fn try_from(
content: UserContent,
) -> Result<Part, <Part as TryFrom<UserContent>>::Error>
fn try_from( content: UserContent, ) -> Result<Part, <Part as TryFrom<UserContent>>::Error>
Performs the conversion.
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.
Source§fn try_from(
content: UserContent,
) -> Result<UserContent, <UserContent as TryFrom<UserContent>>::Error>
fn try_from( content: UserContent, ) -> Result<UserContent, <UserContent as TryFrom<UserContent>>::Error>
Performs the conversion.
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