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
@@ -486,9 +486,13 @@ class ServingTokens(GenerateBaseServing):
total_tokens=(num_prompt_tokens + num_generated_tokens[i]),
)
# Omit absent fields, like the Rust frontend and the
# final usage chunk below.
yield f"data: {chunk.model_dump_json(exclude_none=True)}\n\n"
# Omit absent prompt metadata (Rust skips None fields).
exclude = {
name
for name in ("prompt_token_ids", "mm_placeholders")
if getattr(chunk, name) is None
}
yield f"data: {chunk.model_dump_json(exclude=exclude)}\n\n"
total_completion_tokens = sum(num_generated_tokens)
final_usage_info = UsageInfo(