Add Filter for Modifying Response Body in OpenAiApi#chatCompletionStream
Expected Behavior
The OpenAiApi#chatCompletionStream method should provide a way to filter and modify the returned body before it is processed. This would allow developers to adapt responses from API providers that claim to be OpenAI-compatible but have partial deviations.
Current Behavior
Currently, the response from chatCompletionStream is directly processed using ModelOptionsUtils.jsonToObject(content, ChatCompletionChunk.class). However, some third-party API providers do not fully adhere to OpenAI's API response format, causing deserialization failures.
Context
This issue affects users integrating with third-party APIs that claim OpenAI compatibility but have subtle differences in response formatting.
A filtering mechanism would allow developers to preprocess the response body and adjust it before it is parsed into ChatCompletionChunk.
There are currently no known workarounds other than modifying the library code itself.