@@ -43,7 +43,9 @@ pub enum CompletionFinishReason {
43
43
pub struct Choice {
44
44
pub text : String ,
45
45
pub index : u32 ,
46
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
46
47
pub logprobs : Option < Logprobs > ,
48
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
47
49
pub finish_reason : Option < CompletionFinishReason > ,
48
50
}
49
51
@@ -94,8 +96,10 @@ pub struct CompletionUsage {
94
96
/// Total number of tokens used in the request (prompt + completion).
95
97
pub total_tokens : u32 ,
96
98
/// Breakdown of tokens used in the prompt.
99
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
97
100
pub prompt_tokens_details : Option < PromptTokensDetails > ,
98
101
/// Breakdown of tokens used in a completion.
102
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
99
103
pub completion_tokens_details : Option < CompletionTokensDetails > ,
100
104
}
101
105
@@ -414,21 +418,26 @@ pub struct ChatCompletionResponseMessageAudio {
414
418
#[ derive( Debug , Deserialize , Serialize , Clone , PartialEq ) ]
415
419
pub struct ChatCompletionResponseMessage {
416
420
/// The contents of the message.
421
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
417
422
pub content : Option < String > ,
418
423
/// The refusal message generated by the model.
424
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
419
425
pub refusal : Option < String > ,
420
426
/// The tool calls generated by the model, such as function calls.
427
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
421
428
pub tool_calls : Option < Vec < ChatCompletionMessageToolCall > > ,
422
429
423
430
/// The role of the author of this message.
424
431
pub role : Role ,
425
432
426
433
/// Deprecated and replaced by `tool_calls`.
427
434
/// The name and arguments of a function that should be called, as generated by the model.
435
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
428
436
#[ deprecated]
429
437
pub function_call : Option < FunctionCall > ,
430
438
431
439
/// 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).
440
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
432
441
pub audio : Option < ChatCompletionResponseMessageAudio > ,
433
442
}
434
443
@@ -931,8 +940,10 @@ pub struct ChatChoice {
931
940
/// `length` if the maximum number of tokens specified in the request was reached,
932
941
/// `content_filter` if content was omitted due to a flag from our content filters,
933
942
/// `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
943
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
934
944
pub finish_reason : Option < FinishReason > ,
935
945
/// Log probability information for the choice.
946
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
936
947
pub logprobs : Option < ChatChoiceLogprobs > ,
937
948
}
938
949
@@ -948,10 +959,12 @@ pub struct CreateChatCompletionResponse {
948
959
/// The model used for the chat completion.
949
960
pub model : String ,
950
961
/// The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request.
962
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
951
963
pub service_tier : Option < ServiceTierResponse > ,
952
964
/// This fingerprint represents the backend configuration that the model runs with.
953
965
///
954
966
/// Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
967
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
955
968
pub system_fingerprint : Option < String > ,
956
969
957
970
/// The object type, which is always `chat.completion`.
@@ -1015,8 +1028,10 @@ pub struct ChatChoiceStream {
1015
1028
/// content filters,
1016
1029
/// `tool_calls` if the model called a tool, or `function_call`
1017
1030
/// (deprecated) if the model called a function.
1031
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1018
1032
pub finish_reason : Option < FinishReason > ,
1019
1033
/// Log probability information for the choice.
1034
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1020
1035
pub logprobs : Option < ChatChoiceLogprobs > ,
1021
1036
}
1022
1037
0 commit comments