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>, ) -> MessageRequest
pub fn with_metadata(self, metadata: MessageMetadata) -> MessageRequest
pub fn with_stop_sequences(self, stop_sequences: Vec<String>) -> MessageRequest
pub fn with_stream(self, stream: bool) -> MessageRequest
pub fn with_system(self, system: System) -> MessageRequest
pub fn with_temperature(self, temperature: f32) -> MessageRequest
pub fn with_top_k(self, top_k: i8) -> MessageRequest
pub fn with_top_p(self, top_p: i8) -> MessageRequest
Trait Implementations§
Source§impl Clone for MessageRequest
impl Clone for MessageRequest
Source§fn clone(&self) -> MessageRequest
fn clone(&self) -> MessageRequest
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessageRequest
impl Debug for MessageRequest
Source§impl Default for MessageRequest
impl Default for MessageRequest
Source§fn default() -> MessageRequest
fn default() -> MessageRequest
Source§impl<'de> Deserialize<'de> for MessageRequest
impl<'de> Deserialize<'de> for MessageRequest
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MessageRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MessageRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for MessageRequest
impl Serialize for MessageRequest
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,
Auto Trait Implementations§
impl Freeze for MessageRequest
impl RefUnwindSafe for MessageRequest
impl Send for MessageRequest
impl Sync for MessageRequest
impl Unpin for MessageRequest
impl UnwindSafe for MessageRequest
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)