Response Retrieve streamed
What:
- [ ] Bug Fix
- [x] New Feature
Description:
Adds ability to resume a background stream from a response id and cursor:
$stream = OpenAI::responses()->retrieveStreamed($rid, [
'starting_after' => $cursor,
]);
Related:
https://platform.openai.com/docs/guides/background#streaming-a-background-response
With a new method like this - I don't exactly remember it all by heart but you'll need to touch the interface, the mock and a simple test to keep the coverage.
Yes this is more of a working draft now. To have discussion over I guess.
@iBotPeaches improved code, added interface methods, docs and tests.
Do you have any further context on the string true? I read the docs and it seems its a regular bool like the other stream endpoints. Rest looks solid - just trying to understand the string/true.
Do you have any further context on the string
true? I read the docs and it seems its a regularboollike the other stream endpoints. Rest looks solid - just trying to understand the string/true.
When we use the boolean it is being used as ?stream=1 instead of ?stream=true. This is because retrieve is a GET request. Apparently the OpenAI API wants this to be "true" instead of "1". It fails when passing 1 with an error message (out of the top of my head) of "cannot parse stream as boolean"
We could also adjust the Payload::toRequest method to handle this, but I'm not sure if it applies to every endpoint.
Also see https://www.php.net/manual/en/function.http-build-query.php#122232
Ahh interesting. Thanks for all the info. Let me mess with this a bit (see impact on other endpoints, etc) and see.
thanks!