From 1e66487920d6a4953e63d322d6c0485bc5f05ac9 Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Tue, 10 Sep 2024 19:28:59 -0500 Subject: [PATCH] Fix content, refusal serialization for CreateChatCompletionRequest (#267) They are optional per the openai docs. --- async-openai/src/types/chat.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/async-openai/src/types/chat.rs b/async-openai/src/types/chat.rs index 0e964d8..6217b4c 100644 --- a/async-openai/src/types/chat.rs +++ b/async-openai/src/types/chat.rs @@ -245,8 +245,10 @@ pub struct ChatCompletionRequestUserMessage { #[builder(build_fn(error = "OpenAIError"))] pub struct ChatCompletionRequestAssistantMessage { /// The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. + #[serde(skip_serializing_if = "Option::is_none")] pub content: Option, /// The refusal message by the assistant. + #[serde(skip_serializing_if = "Option::is_none")] pub refusal: Option, /// An optional name for the participant. Provides the model information to differentiate between participants of the same role. #[serde(skip_serializing_if = "Option::is_none")]