pub struct ChatCompletionMessage {
pub role: String,
pub content: Option<String>,
pub name: Option<String>,
pub tool_call_id: Option<String>,
pub tool_calls: Vec<ChatCompletionToolCall>,
pub refusal: Option<String>,
pub reasoning_content: Option<String>,
pub reasoning_details: Vec<ChatReasoningDetail>,
pub extra: BTreeMap<String, Value>,
}Expand description
表示聊天消息。
Fields§
§role: String角色。
content: Option<String>文本内容。
name: Option<String>可选名称。
tool_call_id: Option<String>工具调用关联 ID。
tool_calls: Vec<ChatCompletionToolCall>工具调用集合。
refusal: Option<String>拒绝回答文本。
reasoning_content: Option<String>推理内容。
reasoning_details: Vec<ChatReasoningDetail>推理细节。
extra: BTreeMap<String, Value>额外字段。
Implementations§
Source§impl ChatCompletionMessage
impl ChatCompletionMessage
Sourcepub fn user_content_parts(parts: Vec<ChatMessageContentPart>) -> Self
pub fn user_content_parts(parts: Vec<ChatMessageContentPart>) -> Self
创建包含多模态 content parts 的 user 消息。
Sourcepub fn with_content_parts(
role: impl Into<String>,
parts: Vec<ChatMessageContentPart>,
) -> Self
pub fn with_content_parts( role: impl Into<String>, parts: Vec<ChatMessageContentPart>, ) -> Self
创建包含多模态 content parts 的任意角色消息。
Sourcepub fn content_text(text: impl Into<String>) -> ChatMessageContentPart
pub fn content_text(text: impl Into<String>) -> ChatMessageContentPart
创建 text content part。
Sourcepub fn content_image_url(url: impl Into<String>) -> ChatMessageContentPart
pub fn content_image_url(url: impl Into<String>) -> ChatMessageContentPart
创建 image_url content part。
Sourcepub fn content_video_url(url: impl Into<String>) -> ChatMessageContentPart
pub fn content_video_url(url: impl Into<String>) -> ChatMessageContentPart
创建 video_url content part 预留结构。
Sourcepub fn content_file(file_id: impl Into<String>) -> ChatMessageContentPart
pub fn content_file(file_id: impl Into<String>) -> ChatMessageContentPart
创建 file 引用 content part 预留结构。
Sourcepub fn parse_content<T>(&self) -> Result<Option<T>>where
T: DeserializeOwned,
pub fn parse_content<T>(&self) -> Result<Option<T>>where
T: DeserializeOwned,
Sourcepub fn parse_tool_arguments<T>(&self) -> Result<Option<T>>where
T: DeserializeOwned,
pub fn parse_tool_arguments<T>(&self) -> Result<Option<T>>where
T: DeserializeOwned,
Sourcepub fn parse_tool_arguments_by_id<T>(
&self,
tool_call_id: &str,
) -> Result<Option<T>>where
T: DeserializeOwned,
pub fn parse_tool_arguments_by_id<T>(
&self,
tool_call_id: &str,
) -> Result<Option<T>>where
T: DeserializeOwned,
Trait Implementations§
Source§impl Clone for ChatCompletionMessage
impl Clone for ChatCompletionMessage
Source§fn clone(&self) -> ChatCompletionMessage
fn clone(&self) -> ChatCompletionMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ChatCompletionMessage
impl Debug for ChatCompletionMessage
Source§impl Default for ChatCompletionMessage
impl Default for ChatCompletionMessage
Source§fn default() -> ChatCompletionMessage
fn default() -> ChatCompletionMessage
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ChatCompletionMessage
impl<'de> Deserialize<'de> for ChatCompletionMessage
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 ChatCompletionMessage
impl RefUnwindSafe for ChatCompletionMessage
impl Send for ChatCompletionMessage
impl Sync for ChatCompletionMessage
impl Unpin for ChatCompletionMessage
impl UnsafeUnpin for ChatCompletionMessage
impl UnwindSafe for ChatCompletionMessage
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