MessageRequest

Struct MessageRequest 

Source
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: ClaudeModel

The model that will complete your prompt e.g. Claude 3.5 Sonnet

§max_tokens: u32

The 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: bool

Whether 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

Source

pub fn new( model: ClaudeModel, max_tokens: u32, messages: Vec<Message>, ) -> MessageRequest

Source

pub fn with_metadata(self, metadata: MessageMetadata) -> MessageRequest

Source

pub fn with_stop_sequences(self, stop_sequences: Vec<String>) -> MessageRequest

Source

pub fn with_stream(self, stream: bool) -> MessageRequest

Source

pub fn with_system(self, system: System) -> MessageRequest

Source

pub fn with_temperature(self, temperature: f32) -> MessageRequest

Source

pub fn with_top_k(self, top_k: i8) -> MessageRequest

Source

pub fn with_top_p(self, top_p: i8) -> MessageRequest

Trait Implementations§

Source§

impl Clone for MessageRequest

Source§

fn clone(&self) -> MessageRequest

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for MessageRequest

Source§

fn default() -> MessageRequest

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MessageRequest

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<MessageRequest, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MessageRequest

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,