azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[BUG] StreamOptions is always set to null - it makes it impossible to get token usage with streaming mode

Open klinki opened this issue 1 year ago • 2 comments

Library name and version

Azure.AI.OpenAI 2.0.0

Describe the bug

{ "stream_options": { "include_usage": true }}

is never sent to OpenAI API.

Please check CompleteChatStreamingAsync method in AzureChatClient. It contains call to PostfixClearStreamOptions which always sets ChatCompletionOptions StreamOptions to null.

https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs#L66

As it is internal API, it is impossible to set the value.

Expected behavior

PostfixClearStreamOptions should not be called.

And ideally, setting StreamOptions should be possible with public API.

Actual behavior

PostfixClearStreamOptions is called and StreamOptions is always set to null.

Reproduction Steps

Call ChatClient.CompleteChatStreamingAsync

Environment

No response

klinki avatar Oct 03 '24 10:10 klinki

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @ralph-msft @trrwilson.

github-actions[bot] avatar Oct 03 '24 10:10 github-actions[bot]

Hi @klinki,

Thank you for raising this issue! Hang tight while we take a look. Feel free to add more details if you have any.

AngelosP avatar Oct 18 '24 20:10 AngelosP