diff --git a/async-openai/src/types/chat.rs b/async-openai/src/types/chat.rs index 68c93e19..5494d410 100644 --- a/async-openai/src/types/chat.rs +++ b/async-openai/src/types/chat.rs @@ -951,10 +951,15 @@ pub struct CreateChatCompletionResponse { pub system_fingerprint: Option, /// The object type, which is always `chat.completion`. + #[serde(default="object_default_value")] pub object: String, pub usage: Option, } +pub fn object_default_value()->String{ + "chat.completion".to_string() +} + /// Parsed server side events stream until an \[DONE\] is received from server. pub type ChatCompletionResponseStream = Pin> + Send>>; diff --git a/async-openai/src/types/completion.rs b/async-openai/src/types/completion.rs index 3c15dd6b..d1c5d68b 100644 --- a/async-openai/src/types/completion.rs +++ b/async-openai/src/types/completion.rs @@ -132,10 +132,15 @@ pub struct CreateCompletionResponse { pub system_fingerprint: Option, /// The object type, which is always "text_completion" + #[serde(default="object_default_value")] pub object: String, pub usage: Option, } +pub fn object_default_value()->String{ + "text_completion".to_string() +} + /// Parsed server side events stream until an \[DONE\] is received from server. pub type CompletionResponseStream = Pin> + Send>>; diff --git a/examples/gemini-openai-compatibility/src/gemini_types.rs b/examples/gemini-openai-compatibility/src/gemini_types.rs index 6a245432..41400ee3 100644 --- a/examples/gemini-openai-compatibility/src/gemini_types.rs +++ b/examples/gemini-openai-compatibility/src/gemini_types.rs @@ -55,11 +55,16 @@ pub struct GeminiCreateChatCompletionResponse { /// The model used for the chat completion. pub model: String, /// The object type, which is always `chat.completion`. + #[serde(default="object_default_value")] pub object: String, /// usage statistics for the entire request. pub usage: Option, } +pub fn object_default_value()->String{ + "chat.completion".to_string() +} + #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct GeminiImagesResponse { pub data: Vec>,