With php I implemented the ChatGPT API using StreamedResponse which worked fine so far but I started to encounter a strange behaviour I have no explanation for.
The first $data response is suddenly not a valid format anymore as the output is the first response and half of the second one.
First response:
data: {"id":"chatcmpl-8JMm7OUjW9DSVoSieJAnterQ3Lv2w","object":"chat.completion.chunk","created":1699626471,"model":"gpt-4-0613","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-8JMm7OUjW9DSVoSieJAnterQ3Lv2w","object":"chat.completion.chunk","created":1699626471,"model":"gpt
Second response:
-4-0613","choices":[{"index":0,"delta":{"content":"Gr"},"finish_reason":null}]}
The code did not change and worked before.
My assumption is that either there is some bug on OpenAis end or something changed I am not aware of.
I can rule out that it has something to do with my quota limits. Also the used model seems unlikely to me.
Any hints?
I found this post in their community.
It was a bug at OpenAIs end. The issue resolved itself.
My learning:
If an event source stream does not return proper data their isn't really anything you can do about it on your end.