-
-
Notifications
You must be signed in to change notification settings - Fork 148
[Platform] Streamline RawHttpResult for streaming
#1191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Platform] Streamline RawHttpResult for streaming
#1191
Conversation
RawHttpResult for streaming
|
Can you please rebase? |
a325bd0 to
9ac792b
Compare
Fix: - Skip SSE comments - Skip SSE errors - Drop manual JSON convert process - Use JSON decode from the ServerSentEvent
9ac792b to
1645be2
Compare
done. The workflow errors are not related to my changes... |
|
Lets merge #1204 first, rebase and adjust the testcase |
This PR was merged into the main branch. Discussion ---------- [Platform] Add test for `RawHttpResult` | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | -- | License | MIT Should be merged before #1191 Commits ------- ff0ec93 [Platform] Add test for RawHttpResult
|
I merged my PR, can you please update the test? thanks |
| // Split in case of multiple JSON objects | ||
| $deltas = explode(",\r\n", $jsonDelta); | ||
|
|
||
| foreach ($deltas as $delta) { | ||
| if ('' === trim($delta)) { | ||
| continue; | ||
| } | ||
|
|
||
| yield json_decode($delta, true, flags: \JSON_THROW_ON_ERROR); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason for removing this?
there is no replacement for this part or do i miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
background for having this was gemini api streaming parts of a larger json document - which cannot be decoded right away - testing with examples/gemini/stream.php might help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check this. The "delta"split is part of the SSE integration and is handled via the symfony/http-client (I think so): https://github.com/symfony/http-client/blob/4f420c441088fc3364647565701f34ace5ba0d5f/EventSourceHttpClient.php#L136 Only complete SSE events create ServerSentEvent objects. But I will check the specification, symfony/http-client and gemini API again. I will share my information in the next days...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and the json_decord part is included in the $chunk->getArrayData() call. I will check this too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, so we might need to patch there if there's an issue - fair enough 👍
Fix:
: OPENROUTER PROCESSINGhttps://openrouter.ai/docs/api/reference/streaming#additional-information