pub fn normalize_chat_completion_body(
body: &mut Value,
dialect: Option<&DialectSpec>,
) -> Vec<NormalizationError>Expand description
Normalize a complete (non-streaming) chat.completion response body in
place, using the parser for the model’s resolved dialect.
Only message.content strings are processed; a null, absent, or
non-string content is left untouched, as is everything else in the body.
For models with no dialect the parser is the identity passthrough and
the body comes back byte-identical.
When markup is extracted:
message.contentbecomes the remaining text, ornullwhen a tool call consumed all of it (theOpenAIshape for tool-call turns);- extracted calls are appended to
message.tool_calls,argumentsserialized to a compact JSON string exactly as the streaming encoder does; - reasoning captured by the parser is appended to
message.reasoning_content; - a
finish_reasonofstop/null is upgraded to"tool_calls".
Returns every NormalizationError the parser surfaced; the caller
decides whether to log them or surface the raw bytes to the client, as
the streaming path does.