Skip to main content

CreateChatCompletion

Struct CreateChatCompletion 

Source
pub struct CreateChatCompletion {
Show 14 fields pub model: Model, pub messages: Vec<Message>, pub max_tokens: Option<u64>, pub temperature: f32, pub top_p: f32, pub return_citations: bool, pub search_domain_filter: Option<Vec<String>>, pub return_images: bool, pub return_related_questions: bool, pub search_recency_filter: RecencyFilter, pub top_k: u16, pub stream: bool, pub presence_penalty: u8, pub frequency_penalty: f32,
}

Fields§

§model: Model

The name of the model that will complete your prompt.

§messages: Vec<Message>

The conversation messages.

§max_tokens: Option<u64>

The maximum number of completion tokens returned by the API. The total number of tokens requested in max_tokens plus the number of prompt tokens sent in messages must not exceed the context window token limit of model requested. If left unspecified, then the model will generate tokens until either it reaches its stop token or the end of its context window.

§temperature: f32

The amount of randomness in the response, valued between 0 inclusive and 2 exclusive. Higher values are more random, and lower values are more deterministic.

Defaults to 0.2.

§top_p: f32

The nucleus sampling threshold, valued between 0 and 1 inclusive. For each subsequent token, the model considers the results of the tokens with top_p probability mass.

Defaults to 0.9.

§return_citations: bool

Determines whether or not a request to an online model should return citations.

Defaults to false.

§search_domain_filter: Option<Vec<String>>

Given a list of domains, limit the citations used by the online model to URLs from the specified domains. Currently limited to only 3 domains for whitelisting and blacklisting. For blacklisting add a - to the beginning of the domain string.

§return_images: bool

Determines whether or not a request to an online model should return images.

Defaults to false.

§return_related_questions: bool

Determines whether or not a request to an online model should return related questions.

Defaults to false.

§search_recency_filter: RecencyFilter

Returns search results within the specified time interval - does not apply to images.

§top_k: u16

The number of tokens to keep for highest top-k filtering, specified as an integer between 0 and 2048 inclusive. If set to 0, top-k filtering is disabled.

Defaults to 0.

§stream: bool

Determines whether or not to incrementally stream the response with server-sent events.

Defaults to false.

§presence_penalty: u8

A value between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics. Incompatible with frequency_penalty.

Defaults to 0.

§frequency_penalty: f32

A multiplicative penalty greater than 0. Values greater than 1.0 penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim. A value of 1.0 means no penalty. Incompatible with presence_penalty.

Defaults to 1.

Implementations§

Source§

impl CreateChatCompletion

Source

pub fn new(model: Model, messages: Vec<Message>) -> Self

Source

pub fn with_model(self, model: Model) -> Self

Source

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

Source

pub fn with_max_tokens(self, max_tokens: u64) -> Self

Source

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

Source

pub fn with_top_k(self, top_k: u16) -> Self

Source

pub fn with_top_p(self, top_p: f32) -> Self

Source

pub fn with_frequency_penalty(self, frequency_penalty: f32) -> Self

Source

pub fn with_presence_penalty(self, presence_penalty: u8) -> Self

Source

pub fn with_images(self, return_images: bool) -> Self

Source

pub fn with_citations(self, return_citations: bool) -> Self

Source

pub fn with_search_domain_filter( self, search_domain_filter: Vec<String>, ) -> Self

Source

pub fn with_recency_filter(self, recency_filter: RecencyFilter) -> Self

Trait Implementations§

Source§

impl Clone for CreateChatCompletion

Source§

fn clone(&self) -> CreateChatCompletion

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CreateChatCompletion

Source§

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

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

impl Default for CreateChatCompletion

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for CreateChatCompletion

Source§

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 Serialize for CreateChatCompletion

Source§

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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
Source§

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

Source§

impl<T> From<T> for T

Source§

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
Source§

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

Source§

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: Sized + 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: Sized + 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
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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