-
Notifications
You must be signed in to change notification settings - Fork 20
feat: Add utility functionality to get the entire stream response #852
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?
Conversation
8e6ce0c
to
e3fe4c1
Compare
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.
Already lgtm! I will wait for the unit tests to check the merge functions' logic correctness. Some minor suggestions left.
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.
Perhaps I am lost with what we want to achieve with this PR. I thought we do stream lock. If _openStream
is not meant for stream lock and this will happen in the other PR, I would remove try catch and add it when we implement stream lock and then you can ignore the relevant comments. The stream response level check for _openStream
when calling utilities is indeed helpful.
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.
Thanks a lot for unifying the functionality for streaming and non-streaming variants.
Added few comments, review is still ongoing.
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.
Walked through the code again. Mostly lgtm, left some suggestions for improvements.
); | ||
}); | ||
|
||
it('should handle aborted requests gracefully', async () => { |
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.
[q] I don't understand what you mean by gracefully
? Don't we throw error? It doesn't feel graceful? I am a bit confused with the purpose of this test. Which part of the code would you like to test with this?
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.
Renamed the test.
sourceModule: string, | ||
sourceChoice: number | undefined | ||
): void { | ||
if (!message.role) { |
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.
[pp] I don't mind having validations. But some of them are testing if a mandatory field is really there. This feels unnecessary since if we implement everything correctly, user should never see these warnings, at least not without seeing some error first (like stream ended unexpectedly). Other places like choice.index
, choice.message
are IMO also unnecessary. Can you walk through those cases and remove them if you also feel the same?
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.
Changeset missing
Context
Part of SAP/ai-sdk-js-backlog#315.
What this PR does and why it is needed
With this PR we concatenate and validate the entire stream response, thus making it available like a regular completion response, once the stream ends.
This way, we can make the same utility functionality available for stream responses as we do already for "normal" completion responses.
Additionally, our validation layer is now always applied at the stream's end.
This functionality can then be used for our upcoming message history feature.