pub enum UserContent {
Text(Text),
ToolResult(ToolResult),
Image(Image),
Audio(Audio),
Video(Video),
Document(Document),
}Expand description
User text, tool results, or media. Supported source kinds and media types depend on the target provider.
Variants§
Text(Text)
Plain text user content.
ToolResult(ToolResult)
Result of a tool call returned as user-visible context to the model.
Image(Image)
Image content.
Audio(Audio)
Audio content.
Video(Video)
Video content.
Document(Document)
Document content.
Implementations§
Source§impl UserContent
impl UserContent
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
Creates user image content from base64-encoded data.
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
Creates user image content from unencoded bytes.
Sourcepub fn image_url(
data: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image_url( data: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Creates user image content referencing a URL.
Sourcepub fn audio(
data: impl Into<String>,
media_type: Option<AudioMediaType>,
) -> Self
pub fn audio( data: impl Into<String>, media_type: Option<AudioMediaType>, ) -> Self
Creates user audio content from base64-encoded data.
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
Creates user audio content from unencoded bytes.
Sourcepub fn audio_url(
data: impl Into<String>,
media_type: Option<AudioMediaType>,
) -> Self
pub fn audio_url( data: impl Into<String>, media_type: Option<AudioMediaType>, ) -> Self
Creates user audio content referencing a URL.
Sourcepub fn video(
data: impl Into<String>,
media_type: Option<VideoMediaType>,
) -> Self
pub fn video( data: impl Into<String>, media_type: Option<VideoMediaType>, ) -> Self
Creates user video content from base64-encoded data.
Sourcepub fn video_raw(
data: impl Into<Vec<u8>>,
media_type: Option<VideoMediaType>,
) -> Self
pub fn video_raw( data: impl Into<Vec<u8>>, media_type: Option<VideoMediaType>, ) -> Self
Creates user video content from unencoded bytes.
Sourcepub fn video_url(
data: impl Into<String>,
media_type: Option<VideoMediaType>,
) -> Self
pub fn video_url( data: impl Into<String>, media_type: Option<VideoMediaType>, ) -> Self
Creates user video content referencing a URL.
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
Creates user document content from unencoded bytes.
Sourcepub fn document_url(
data: impl Into<String>,
media_type: Option<DocumentMediaType>,
) -> Self
pub fn document_url( data: impl Into<String>, media_type: Option<DocumentMediaType>, ) -> Self
Creates user document content referencing 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
Creates document content from a string without decoding or fetching it.
Sourcepub fn tool_result(
call: CallId,
name: ToolName,
content: Vec<ToolResultContent>,
) -> Self
pub fn tool_result( call: CallId, name: ToolName, content: Vec<ToolResultContent>, ) -> Self
Creates a tool result answering the call call to the tool name.
Trait Implementations§
Source§impl Clone for UserContent
impl Clone for UserContent
Source§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 PartialEq for UserContent
impl PartialEq for UserContent
Source§impl Serialize for UserContent
impl Serialize for UserContent
impl StructuralPartialEq 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 Content
impl TryFrom<UserContent> for Content
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
Auto Trait Implementations§
impl Freeze for UserContent
impl RefUnwindSafe for UserContent
impl Send for UserContent
impl Sync for UserContent
impl Unpin for UserContent
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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