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_base64(
data: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image_base64( data: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Helper constructor to make creating user image content easier.
Sourcepub fn image_raw(
data: impl Into<Vec<u8>>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image_raw( data: impl Into<Vec<u8>>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Helper constructor to make creating user image content from raw unencoded bytes easier.
Sourcepub fn image_url(
url: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image_url( url: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Helper constructor to make creating user image content easier.
Sourcepub fn audio(
data: impl Into<String>,
media_type: Option<AudioMediaType>,
) -> Self
pub fn audio( data: impl Into<String>, media_type: Option<AudioMediaType>, ) -> Self
Helper constructor to make creating user audio content easier.
Sourcepub fn audio_raw(
data: impl Into<Vec<u8>>,
media_type: Option<AudioMediaType>,
) -> Self
pub fn audio_raw( data: impl Into<Vec<u8>>, media_type: Option<AudioMediaType>, ) -> Self
Helper constructor to make creating user audio content from raw unencoded bytes easier.
Sourcepub fn audio_url(
url: impl Into<String>,
media_type: Option<AudioMediaType>,
) -> Self
pub fn audio_url( url: impl Into<String>, media_type: Option<AudioMediaType>, ) -> Self
Helper to create an audio resource from a URL
Sourcepub fn document(
data: impl Into<String>,
media_type: Option<DocumentMediaType>,
) -> Self
pub fn document( data: impl Into<String>, media_type: Option<DocumentMediaType>, ) -> Self
Helper constructor to make creating user document content easier.
Sourcepub fn document_raw(
data: impl Into<Vec<u8>>,
media_type: Option<DocumentMediaType>,
) -> Self
pub fn document_raw( data: impl Into<Vec<u8>>, media_type: Option<DocumentMediaType>, ) -> Self
Helper to create a document from raw unencoded bytes
Sourcepub fn document_url(
url: impl Into<String>,
media_type: Option<DocumentMediaType>,
) -> Self
pub fn document_url( url: impl Into<String>, media_type: Option<DocumentMediaType>, ) -> Self
Helper to create a document from a URL
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
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
Source§impl From<UserContent> for UserContent
impl From<UserContent> for UserContent
Source§fn from(value: UserContent) -> Self
fn from(value: UserContent) -> Self
Source§impl From<UserContent> for UserContent
impl From<UserContent> for UserContent
Source§fn from(content: UserContent) -> Self
fn from(content: UserContent) -> Self
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
Source§impl TryFrom<UserContent> for UserContent
impl TryFrom<UserContent> for UserContent
Source§type Error = MessageError
type Error = MessageError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more