pub struct CreateChatCompletionRequest {
pub model: Model,
pub messages: Vec<ChatMessage>,
pub temperature: Option<f64>,
pub top_p: Option<f64>,
pub n: Option<u32>,
pub stream: Option<bool>,
pub max_tokens: Option<u32>,
pub logit_bias: Option<HashMap<String, i32>>,
pub user: Option<String>,
}
Expand description
A request struct for creating chat completions with the OpenAI Chat Completions API.
§Fields
model
: The ID of the model to use (e.g., “gpt-3.5-turbo”).messages
: A list ofChatMessage
items providing the conversation history.stream
: Whether or not to stream responses via server-sent events.max_tokens
,temperature
,top_p
, etc.: Parameters controlling the generation.n
: Number of chat completion choices to generate.logit_bias
,user
: Additional advanced parameters.
Fields§
§model: Model
Required. The model used for this chat request. Examples: “Model::O1Mini”, “Model::Other(“gpt-4”.to_string)“.
messages: Vec<ChatMessage>
Required. The messages that make up the conversation so far.
temperature: Option<f64>
Controls the creativity of the output. 0 is the most deterministic, 2 is the most creative.
top_p: Option<f64>
The nucleus sampling parameter. Like temperature
, but a value like 0.1 means only
the top 10% probability mass is considered.
n: Option<u32>
How many chat completion choices to generate for each input message. Defaults to 1.
stream: Option<bool>
If set, partial message deltas are sent as data-only server-sent events (SSE) as they become available.
max_tokens: Option<u32>
The maximum number of tokens allowed for the generated answer. Defaults to the max tokens allowed by the model minus the prompt.
logit_bias: Option<HashMap<String, i32>>
A map between token (encoded as a string) and an associated bias from -100 to 100 that adjusts the likelihood of the token appearing.
user: Option<String>
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
Trait Implementations§
Source§impl Clone for CreateChatCompletionRequest
impl Clone for CreateChatCompletionRequest
Source§fn clone(&self) -> CreateChatCompletionRequest
fn clone(&self) -> CreateChatCompletionRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more