Skip to content

Commit

Permalink
allow content to have empty text, which will not serialize it
Browse files Browse the repository at this point in the history
  • Loading branch information
hanselke committed Jul 17, 2024
1 parent 9b8aecb commit 55b4b78
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/v1/chat_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ impl serde::Serialize for Content {
S: serde::Serializer,
{
match *self {
Content::Text(ref text) => serializer.serialize_str(text),
Content::Text(ref text) => {
if text.is_empty() {
serializer.serialize_none()
} else {
serializer.serialize_str(text)
}
}
Content::ImageUrl(ref image_url) => image_url.serialize(serializer),
}
}
Expand Down

0 comments on commit 55b4b78

Please sign in to comment.