pub struct Part {
pub kind: PartKind,
pub thought: Option<bool>,
pub thought_signature: Option<Vec<u8>>,
pub media_resolution: Option<PartMediaResolution>,
pub video_metadata: Option<VideoMetadata>,
}Expand description
内容部分。
Fields§
§kind: PartKind具体内容变体。
thought: Option<bool>是否为思考内容。
thought_signature: Option<Vec<u8>>思考签名(base64 编码)。
media_resolution: Option<PartMediaResolution>媒体分辨率设置(按 part)。
video_metadata: Option<VideoMetadata>视频元数据。
Implementations§
Source§impl Part
impl Part
Sourcepub fn file_data(
file_uri: impl Into<String>,
mime_type: impl Into<String>,
) -> Self
pub fn file_data( file_uri: impl Into<String>, mime_type: impl Into<String>, ) -> Self
创建文件 URI Part。
Sourcepub const fn function_call(function_call: FunctionCall) -> Self
pub const fn function_call(function_call: FunctionCall) -> Self
创建函数调用 Part。
Sourcepub const fn function_response(function_response: FunctionResponse) -> Self
pub const fn function_response(function_response: FunctionResponse) -> Self
创建函数响应 Part。
Sourcepub fn executable_code(code: impl Into<String>, language: Language) -> Self
pub fn executable_code(code: impl Into<String>, language: Language) -> Self
创建可执行代码 Part。
Sourcepub fn code_execution_result(
outcome: Outcome,
output: impl Into<String>,
) -> Self
pub fn code_execution_result( outcome: Outcome, output: impl Into<String>, ) -> Self
创建代码执行结果 Part。
Sourcepub const fn with_thought(self, thought: bool) -> Self
pub const fn with_thought(self, thought: bool) -> Self
设置是否为思考内容。
Sourcepub fn with_thought_signature(self, signature: Vec<u8>) -> Self
pub fn with_thought_signature(self, signature: Vec<u8>) -> Self
设置 thought signature。
Sourcepub const fn with_media_resolution(
self,
resolution: PartMediaResolution,
) -> Self
pub const fn with_media_resolution( self, resolution: PartMediaResolution, ) -> Self
设置媒体分辨率。
Sourcepub fn with_video_metadata(self, metadata: VideoMetadata) -> Self
pub fn with_video_metadata(self, metadata: VideoMetadata) -> Self
设置视频元数据。
Sourcepub const fn text_value(&self) -> Option<&str>
pub const fn text_value(&self) -> Option<&str>
获取文本内容(仅当为 Text Part)。
Sourcepub const fn function_call_ref(&self) -> Option<&FunctionCall>
pub const fn function_call_ref(&self) -> Option<&FunctionCall>
获取函数调用引用(仅当为 FunctionCall Part)。
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Part
impl<'de> Deserialize<'de> for Part
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Part
impl RefUnwindSafe for Part
impl Send for Part
impl Sync for Part
impl Unpin for Part
impl UnsafeUnpin for Part
impl UnwindSafe for Part
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