Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions async-openai/src/types/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ pub enum CompletionFinishReason {
pub struct Choice {
pub text: String,
pub index: u32,
#[serde(skip_serializing_if = "Option::is_none")]
pub logprobs: Option<Logprobs>,
#[serde(skip_serializing_if = "Option::is_none")]
pub finish_reason: Option<CompletionFinishReason>,
}

Expand Down Expand Up @@ -94,8 +96,10 @@ pub struct CompletionUsage {
/// Total number of tokens used in the request (prompt + completion).
pub total_tokens: u32,
/// Breakdown of tokens used in the prompt.
#[serde(skip_serializing_if = "Option::is_none")]
pub prompt_tokens_details: Option<PromptTokensDetails>,
/// Breakdown of tokens used in a completion.
#[serde(skip_serializing_if = "Option::is_none")]
pub completion_tokens_details: Option<CompletionTokensDetails>,
}

Expand Down Expand Up @@ -414,21 +418,26 @@ pub struct ChatCompletionResponseMessageAudio {
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
pub struct ChatCompletionResponseMessage {
/// The contents of the message.
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<String>,
/// The refusal message generated by the model.
#[serde(skip_serializing_if = "Option::is_none")]
pub refusal: Option<String>,
/// The tool calls generated by the model, such as function calls.
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_calls: Option<Vec<ChatCompletionMessageToolCall>>,

/// The role of the author of this message.
pub role: Role,

/// Deprecated and replaced by `tool_calls`.
/// The name and arguments of a function that should be called, as generated by the model.
#[serde(skip_serializing_if = "Option::is_none")]
#[deprecated]
pub function_call: Option<FunctionCall>,

/// If the audio output modality is requested, this object contains data about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
#[serde(skip_serializing_if = "Option::is_none")]
pub audio: Option<ChatCompletionResponseMessageAudio>,
}

Expand Down Expand Up @@ -927,8 +936,10 @@ pub struct ChatChoice {
/// `length` if the maximum number of tokens specified in the request was reached,
/// `content_filter` if content was omitted due to a flag from our content filters,
/// `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
#[serde(skip_serializing_if = "Option::is_none")]
pub finish_reason: Option<FinishReason>,
/// Log probability information for the choice.
#[serde(skip_serializing_if = "Option::is_none")]
pub logprobs: Option<ChatChoiceLogprobs>,
}

Expand All @@ -944,10 +955,12 @@ pub struct CreateChatCompletionResponse {
/// The model used for the chat completion.
pub model: String,
/// The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request.
#[serde(skip_serializing_if = "Option::is_none")]
pub service_tier: Option<ServiceTierResponse>,
/// This fingerprint represents the backend configuration that the model runs with.
///
/// Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
#[serde(skip_serializing_if = "Option::is_none")]
pub system_fingerprint: Option<String>,

/// The object type, which is always `chat.completion`.
Expand Down Expand Up @@ -1011,8 +1024,10 @@ pub struct ChatChoiceStream {
/// content filters,
/// `tool_calls` if the model called a tool, or `function_call`
/// (deprecated) if the model called a function.
#[serde(skip_serializing_if = "Option::is_none")]
pub finish_reason: Option<FinishReason>,
/// Log probability information for the choice.
#[serde(skip_serializing_if = "Option::is_none")]
pub logprobs: Option<ChatChoiceLogprobs>,
}

Expand Down