@@ -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
@@ -927,8 +936,10 @@ pub struct ChatChoice {
927
936
/// `length` if the maximum number of tokens specified in the request was reached,
928
937
/// `content_filter` if content was omitted due to a flag from our content filters,
929
938
/// `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
939
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
930
940
pub finish_reason : Option < FinishReason > ,
931
941
/// Log probability information for the choice.
942
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
932
943
pub logprobs : Option < ChatChoiceLogprobs > ,
933
944
}
934
945
@@ -944,10 +955,12 @@ pub struct CreateChatCompletionResponse {
944
955
/// The model used for the chat completion.
945
956
pub model : String ,
946
957
/// The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request.
958
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
947
959
pub service_tier : Option < ServiceTierResponse > ,
948
960
/// This fingerprint represents the backend configuration that the model runs with.
949
961
///
950
962
/// Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
963
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
951
964
pub system_fingerprint : Option < String > ,
952
965
953
966
/// The object type, which is always `chat.completion`.
@@ -1011,8 +1024,10 @@ pub struct ChatChoiceStream {
1011
1024
/// content filters,
1012
1025
/// `tool_calls` if the model called a tool, or `function_call`
1013
1026
/// (deprecated) if the model called a function.
1027
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1014
1028
pub finish_reason : Option < FinishReason > ,
1015
1029
/// Log probability information for the choice.
1030
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1016
1031
pub logprobs : Option < ChatChoiceLogprobs > ,
1017
1032
}
1018
1033
0 commit comments