Revert "[Frontend] Omit absent fields from /inference/v1/generate stream chunks" (#57302)

This commit is contained in:
aoshen02
2026-09-16 23:31:59 -07:00
committed by GitHub
parent 8538017f4b
commit b978df3299
3 changed files with 7 additions and 67 deletions
@@ -679,36 +679,6 @@ mod tests {
assert!(response.mm_placeholders.is_none());
}
#[test]
fn stream_chunk_omits_absent_fields() {
// Contract shared with the Python frontend: absent optional fields
// are omitted from stream chunks, not serialized as null.
let chunk = GenerateStreamResponse {
request_id: "raw-1".to_string(),
choices: vec![GenerateResponseStreamChoice {
index: 0,
logprobs: None,
finish_reason: None,
token_ids: vec![1],
}],
usage: None,
prompt_token_ids: None,
mm_placeholders: None,
};
let json = serde_json::to_value(&chunk).expect("serialize chunk");
for key in ["usage", "prompt_token_ids", "mm_placeholders"] {
assert!(json.get(key).is_none(), "{key} should be omitted");
}
for key in ["logprobs", "finish_reason"] {
assert!(
json["choices"][0].get(key).is_none(),
"{key} should be omitted"
);
}
}
#[test]
fn extract_mm_placeholders_returns_none_without_features() {
assert!(extract_mm_placeholders(None).is_none());