pub struct MessageRequest {
pub model: ClaudeModel,
pub max_tokens: u32,
pub messages: Vec<Message>,
pub metadata: Option<MessageMetadata>,
pub stop_sequences: Option<Vec<String>>,
pub stream: bool,
pub system: Option<System>,
pub temperature: Option<f32>,
pub top_k: Option<i8>,
pub top_p: Option<i8>,
}Fields§
§model: ClaudeModelThe model that will complete your prompt e.g. Claude 3.5 Sonnet
max_tokens: u32The maximum number of tokens to generate before stopping.
Defaults to 1000 tokens.
Note that models may stop before reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.
messages: Vec<Message>Input messages.
metadata: Option<MessageMetadata>An object describing metadata about the request.
stop_sequences: Option<Vec<String>>Custom text sequences that will cause the model to stop generating.
stream: boolWhether to incrementally stream the response using server-sent events.
system: Option<System>System prompt.
A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role.
temperature: Option<f32>Amount of randomness injected into the response.
Defaults to 1.0. Ranges from 0.0 to 1.0.
Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic.
top_k: Option<i8>Only sample from the top K options for each subsequent token.
Used to remove “long tail” low probability responses. Learn more technical details here.
top_p: Option<i8>Use nucleus sampling.
In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by top_p. You should either alter temperature or top_p, but not both.
Implementations§
Source§impl MessageRequest
impl MessageRequest
pub fn new(model: ClaudeModel, max_tokens: u32, messages: Vec<Message>) -> Self
pub fn with_metadata(self, metadata: MessageMetadata) -> Self
pub fn with_stop_sequences(self, stop_sequences: Vec<String>) -> Self
pub fn with_stream(self, stream: bool) -> Self
pub fn with_system(self, system: System) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
pub fn with_top_k(self, top_k: i8) -> Self
pub fn with_top_p(self, top_p: i8) -> Self
Trait Implementations§
Source§impl Clone for MessageRequest
impl Clone for MessageRequest
Source§fn clone(&self) -> MessageRequest
fn clone(&self) -> MessageRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more