diff --git a/Cargo.toml b/Cargo.toml index 25ae499..75cb547 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openai" -version = "1.1.0" +version = "1.1.1" authors = ["Lorenzo Fontoura ", "valentinegb"] edition = "2021" description = "An unofficial Rust library for the OpenAI API." diff --git a/src/chat.rs b/src/chat.rs index 5d423d2..aeba4ca 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -22,10 +22,15 @@ pub type ChatCompletionDelta = ChatCompletionGeneric; #[derive(Deserialize, Clone, Debug, Eq, PartialEq)] pub struct ChatCompletionGeneric { + #[serde(default)] pub id: String, + #[serde(default)] pub object: String, + #[serde(default)] pub created: u64, + #[serde(default)] pub model: String, + #[serde(default = "default_empty_vec")] pub choices: Vec, pub usage: Option, } @@ -603,6 +608,10 @@ impl Default for ChatCompletionMessageRole { } } +fn default_empty_vec() -> Vec { + Vec::new() +} + #[cfg(test)] mod tests { use super::*;