pub struct Message {
pub id: String,
pub container: Option<ContainerInfo>,
pub content: Vec<ContentBlock>,
pub model: Model,
pub role: MessageRole,
pub stop_reason: Option<StopReason>,
pub stop_sequence: Option<String>,
pub type: String,
pub usage: Usage,
}anthropic-client only.Expand description
A message generated by the assistant.
Fields§
§id: StringUnique object identifier.
The format and length of IDs may change over time.
container: Option<ContainerInfo>Container information for code execution tool reuse.
content: Vec<ContentBlock>Content generated by the model.
This is an array of content blocks, each of which has a type that determines
its shape.
model: ModelThe model that generated the message.
role: MessageRoleConversational role of the generated message.
This will always be “assistant”.
stop_reason: Option<StopReason>The reason that generation stopped.
This may be null in streaming responses until completion.
stop_sequence: Option<String>Which custom stop sequence was generated, if any.
This value will be a non-null string if one of your custom stop sequences was generated.
type: StringObject type, which is always “message”.
usage: UsageBilling and rate-limit usage information.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(
id: String,
content: Vec<ContentBlock>,
model: Model,
usage: Usage,
) -> Message
pub fn new( id: String, content: Vec<ContentBlock>, model: Model, usage: Usage, ) -> Message
Create a new Message with the given parameters.
Sourcepub fn with_stop_reason(self, stop_reason: StopReason) -> Message
pub fn with_stop_reason(self, stop_reason: StopReason) -> Message
Set the stop reason.
Sourcepub fn with_stop_sequence(self, stop_sequence: String) -> Message
pub fn with_stop_sequence(self, stop_sequence: String) -> Message
Set the stop sequence.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<Message> for MessageParam
impl From<Message> for MessageParam
Source§fn from(message: Message) -> MessageParam
fn from(message: Message) -> MessageParam
Source§impl Serialize for Message
impl Serialize for Message
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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> 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 moreSource§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