-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for stream usage in Azure OpenAi #2858
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
Add support for stream usage in Azure OpenAi #2858
Conversation
0c8ce47
to
8fa1dbc
Compare
} | ||
|
||
public void setStreamUsage(Boolean enableStreamUsage) { | ||
this.streamOptions = (enableStreamUsage) ? new ChatCompletionStreamOptions().setIncludeUsage(true) : null; |
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.
We need an explicit property to set the enableStreamUsage
value.
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.
This explicit property needs to drive how the usage is included in AzureOpenAiChatModel. Please check OpenAIChatModel StreamOptions#includeUsage for reference.
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.
Thank you for your review and feedback, @ilayaperumalg!
Based on your comments, I have made the following changes:
- Introduced an explicit property (
enableStreamUsage
) inAzureOpenAiChatOptions
. - Updated the setter so it no longer modifies
streamOptions
directly. - Adjusted the logic in
AzureOpenAiChatModel
to use theenableStreamUsage
property to determine whether to include usage information in streaming responses, following the pattern ofOpenAiChatModel
.
Could you please check if the current implementation meets the expectations?
Thanks again for your guidance!
Signed-off-by: Andres da Silva Santos <[email protected]>
Signed-off-by: Andres da Silva Santos <[email protected]>
Signed-off-by: Andres da Silva Santos <[email protected]>
ffe2bed
to
9b81f11
Compare
Hi @ilayaperumalg, this looks good to me as well. |
Thank you @andresssantos for the follow up with the PR and @mkheck for the review. We'll get this reviewed and merged soon. |
Rebased, squashed and merged as 7bb553e @andresssantos Thanks very much for the contribution! |
Description
Related issue: spring-ai#1724
This PR introduces support for streamUsage in the
AzureOpenAiChatOptions
class. Additionally:AzureOpenAiChatOptionsTests
to reflect the changes.azure-openai-chat.adoc
.