mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-09-02 07:09:36 +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,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
match *self {
|
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),
|
Content::ImageUrl(ref image_url) => image_url.serialize(serializer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user