Skip to content

Commit 0fd6e41

Browse files
authored
Merge pull request tjardoo#44 from tjardoo/add-logprobs-seed-to-chat-completion-params
Add logprobs + seed fields to ChatCompletionParameters
2 parents ad1e097 + 8d1df54 commit 0fd6e41

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/v1/resources/chat.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ pub struct ChatCompletionParameters {
5757
/// Modify the likelihood of specified tokens appearing in the completion.
5858
#[serde(skip_serializing_if = "Option::is_none")]
5959
pub logit_bias: Option<HashMap<String, i32>>,
60+
/// Whether to return log probabilities of the output tokens or not.
61+
/// If true, returns the log probabilities of each output token returned in the 'content' of 'message'.
62+
/// This option is currently not available on the 'gpt-4-vision-preview' model.
63+
#[serde(skip_serializing_if = "Option::is_none")]
64+
pub logprobs: Option<bool>,
65+
/// An integer between 0 and 5 specifying the number of most likely tokens to return at each token position,
66+
/// each with an associated log probability. 'logprobs' must be set to 'true' if this parameter is used.
67+
#[serde(skip_serializing_if = "Option::is_none")]
68+
pub top_logprobs: Option<u32>,
6069
/// The maximum number of tokens to generate in the chat completion.
6170
#[serde(skip_serializing_if = "Option::is_none")]
6271
pub max_tokens: Option<u32>,
@@ -71,6 +80,11 @@ pub struct ChatCompletionParameters {
7180
/// Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON.
7281
#[serde(skip_serializing_if = "Option::is_none")]
7382
pub response_format: Option<ChatCompletionResponseFormat>,
83+
/// This feature is in Beta. If specified, our system will make a best effort to sample deterministically,
84+
/// such that repeated requests with the same seed and parameters should return the same result.
85+
/// Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.
86+
#[serde(skip_serializing_if = "Option::is_none")]
87+
pub seed: Option<u32>,
7488
/// Up to 4 sequences where the API will stop generating further tokens.
7589
#[serde(skip_serializing_if = "Option::is_none")]
7690
pub stop: Option<StopToken>,
@@ -318,10 +332,13 @@ impl Default for ChatCompletionParameters {
318332
model: Gpt35Engine::Gpt35Turbo1106.to_string(),
319333
frequency_penalty: None,
320334
logit_bias: None,
335+
logprobs: None,
336+
top_logprobs: None,
321337
max_tokens: None,
322338
n: None,
323339
presence_penalty: None,
324340
response_format: None,
341+
seed: None,
325342
stop: None,
326343
temperature: None,
327344
top_p: None,

0 commit comments

Comments
 (0)