language_models: Skip empty delta text content in OpenAI and OpenAI compatible provider (#37626)
Umesh Yadav
created
Closes #37302
Related: #37614
In case of open_ai_compatible providers like Zhipu AI and z.ai they
return empty content along with usage data. below is the example json
captured from z.ai. We now ignore empty content returned by providers
now to avoid this issue where we would return the same empty content
back to provider which would error out.
```
OpenAI Stream Response JSON:
{
"id": "2025090518465610d80dc21e66426d",
"created": 1757069216,
"model": "glm-4.5",
"choices": [
{
"index": 0,
"finish_reason": "tool_calls",
"delta": {
"role": "assistant",
"content": ""
}
}
],
"usage": {
"prompt_tokens": 7882,
"completion_tokens": 150,
"total_tokens": 8032,
"prompt_tokens_details": {
"cached_tokens": 7881
}
}
}
```
Release Notes:
- Skip empty delta text content in OpenAI and OpenAI compatible provider
Signed-off-by: Umesh Yadav <git@umesh.dev>