#[non_exhaustive]pub struct CreateMessageResult {
pub model: String,
pub stop_reason: Option<String>,
pub message: SamplingMessage,
}Expand description
Result of sampling/createMessage (SEP-1577). The result of a sampling/createMessage request containing the generated response.
This structure contains the generated message along with metadata about how the generation was performed and why it stopped.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.model: StringThe identifier of the model that generated the response
stop_reason: Option<String>The reason why generation stopped (e.g., “endTurn”, “maxTokens”)
message: SamplingMessageThe generated message with role and content
Implementations§
Source§impl CreateMessageResult
impl CreateMessageResult
pub const STOP_REASON_END_TURN: &str = "endTurn"
pub const STOP_REASON_END_SEQUENCE: &str = "stopSequence"
pub const STOP_REASON_END_MAX_TOKEN: &str = "maxTokens"
pub const STOP_REASON_TOOL_USE: &str = "toolUse"
Sourcepub fn new(message: SamplingMessage, model: String) -> Self
pub fn new(message: SamplingMessage, model: String) -> Self
Create a new CreateMessageResult with required fields.
Sourcepub fn with_stop_reason(self, stop_reason: impl Into<String>) -> Self
pub fn with_stop_reason(self, stop_reason: impl Into<String>) -> Self
Set the stop reason.
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Set the model identifier.
Trait Implementations§
Source§impl Clone for CreateMessageResult
impl Clone for CreateMessageResult
Source§fn clone(&self) -> CreateMessageResult
fn clone(&self) -> CreateMessageResult
Returns a duplicate of the value. Read more
1.0.0 · 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 CreateMessageResult
impl Debug for CreateMessageResult
Source§impl<'de> Deserialize<'de> for CreateMessageResult
impl<'de> Deserialize<'de> for CreateMessageResult
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
Source§impl From<CreateMessageResult> for ClientResult
impl From<CreateMessageResult> for ClientResult
Source§fn from(value: CreateMessageResult) -> Self
fn from(value: CreateMessageResult) -> Self
Converts to this type from the input type.
Source§impl JsonSchema for CreateMessageResult
impl JsonSchema for CreateMessageResult
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for CreateMessageResult
impl PartialEq for CreateMessageResult
Source§impl Serialize for CreateMessageResult
impl Serialize for CreateMessageResult
impl StructuralPartialEq for CreateMessageResult
Auto Trait Implementations§
impl Freeze for CreateMessageResult
impl RefUnwindSafe for CreateMessageResult
impl Send for CreateMessageResult
impl Sync for CreateMessageResult
impl Unpin for CreateMessageResult
impl UnsafeUnpin for CreateMessageResult
impl UnwindSafe for CreateMessageResult
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