-
Notifications
You must be signed in to change notification settings - Fork 141
Closed
Labels
kind/supportAdopter support requests.Adopter support requests.status/triageCollecting information required to triage the issue.Collecting information required to triage the issue.
Description
Question
Hi!
I'm generating code with the OpenAI OpenAPI specification and am iterating over streamed responses from the chat/completions
endpoint with asDecodedServerSentEventsWithJSONData()
.
The problem is that API returns ChatCompletionStreamResponse
JSON payloads until the stream is done, which is denoted by a simple [DONE]
payload.
Because [DONE]
isn't valid JSON, the last chunk of a successful stream will throw a DecodingError.dataCorrupted()
.
Currently, I'm just handling it with an empty catch block to avoid the crash, but that seems like a hacky workaround. So, I was wondering whether there was a better solution.
The following ideas haven't been successful so far:
- Use a
ClientMiddleware
to match incoming payloads for the[DONE]
bytes and toss the payload if they're found. - Add another schema to the OpenAPI spec that defines
[DONE]
and is connect with theChatCompletionStreamResponse
through ananyOf
.
Do you have any suggestions?
Metadata
Metadata
Assignees
Labels
kind/supportAdopter support requests.Adopter support requests.status/triageCollecting information required to triage the issue.Collecting information required to triage the issue.