mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-08-22 23:25:39 +00:00
allow content to have empty text, which will not serialize it
This commit is contained in:
@ -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),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user