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_base64(
data: impl Into<String>,
media_type: Option<AudioMediaType>,
) -> Self
pub fn audio_base64( 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_base64(
data: impl Into<String>,
media_type: Option<VideoMediaType>,
) -> Self
pub fn video_base64( 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_base64(
data: impl Into<String>,
media_type: Option<DocumentMediaType>,
) -> Self
pub fn document_base64( data: impl Into<String>, media_type: Option<DocumentMediaType>, ) -> Self
Creates user document content from base64-encoded data.
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_text(
data: impl Into<String>,
media_type: Option<DocumentMediaType>,
) -> Self
pub fn document_text( data: impl Into<String>, media_type: Option<DocumentMediaType>, ) -> Self
Creates user document content from literal text, such as a plain
text or Markdown file. Binary formats belong in
Self::document_base64 or Self::document_raw.
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
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