pub enum ContentPart {
Text(TextContentPart),
Image(ImageContentPart),
ImageFile(ImageFileContentPart),
ToolCall(ToolCallContentPart),
ToolResult(ToolResultContentPart),
}Expand description
A part of message content - can be text, image, image_file, tool_call, or tool_result
This is the canonical content part type used across the system. API layer enables the “openapi” feature to add ToSchema derive.
Variants§
Text(TextContentPart)
Text content
Image(ImageContentPart)
Image content (base64 or URL)
ImageFile(ImageFileContentPart)
Image file content (reference to uploaded image by ID)
ToolCall(ToolCallContentPart)
Tool call content (assistant requesting tool execution)
ToolResult(ToolResultContentPart)
Tool result content (result of tool execution)
Implementations§
Source§impl ContentPart
impl ContentPart
Sourcepub fn image_file(image_id: ImageId) -> Self
pub fn image_file(image_id: ImageId) -> Self
Create an image file content part (reference to uploaded image)
Sourcepub fn tool_call(
id: impl Into<String>,
name: impl Into<String>,
arguments: Value,
) -> Self
pub fn tool_call( id: impl Into<String>, name: impl Into<String>, arguments: Value, ) -> Self
Create a tool call content part
Sourcepub fn tool_result(
tool_call_id: impl Into<String>,
result: Option<Value>,
error: Option<String>,
) -> Self
pub fn tool_result( tool_call_id: impl Into<String>, result: Option<Value>, error: Option<String>, ) -> Self
Create a tool result content part
Sourcepub fn is_image_file(&self) -> bool
pub fn is_image_file(&self) -> bool
Check if this is an ImageFile part
Sourcepub fn content_type(&self) -> ContentType
pub fn content_type(&self) -> ContentType
Get the content type
Sourcepub fn to_openai_format(&self) -> Option<Value>
pub fn to_openai_format(&self) -> Option<Value>
Convert content part to OpenAI-compatible format
Returns None for content types that aren’t valid in user/system messages
(ImageFile, ToolCall, ToolResult are handled at message level).
Trait Implementations§
Source§impl Clone for ContentPart
impl Clone for ContentPart
Source§fn clone(&self) -> ContentPart
fn clone(&self) -> ContentPart
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentPart
impl Debug for ContentPart
Source§impl<'de> Deserialize<'de> for ContentPart
impl<'de> Deserialize<'de> for ContentPart
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<InputContentPart> for ContentPart
impl From<InputContentPart> for ContentPart
Source§fn from(input: InputContentPart) -> Self
fn from(input: InputContentPart) -> Self
Source§impl PartialEq for ContentPart
impl PartialEq for ContentPart
Source§fn eq(&self, other: &ContentPart) -> bool
fn eq(&self, other: &ContentPart) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ContentPart
impl Serialize for ContentPart
impl StructuralPartialEq for ContentPart
Auto Trait Implementations§
impl Freeze for ContentPart
impl RefUnwindSafe for ContentPart
impl Send for ContentPart
impl Sync for ContentPart
impl Unpin for ContentPart
impl UnsafeUnpin for ContentPart
impl UnwindSafe for ContentPart
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request