OpenAI-API-dotnet icon indicating copy to clipboard operation
OpenAI-API-dotnet copied to clipboard

MostResentAPIResult.Usage is null

Open 771185858 opened this issue 1 year ago • 5 comments

After using Chat.StreamResponseEnumerableFromChatbotAsync() in Streaming, the Usage of Chat.MostResetAPIResult is always null. How can I obtain 'Usage' related information

var chat = _openAI.Client().Chat.CreateConversation(); chat.AppendUserInput("How to make bread ?"); await foreach (var res in chat.StreamResponseEnumerableFromChatbotAsync()). { await Clients.Client(connectionId).SendAsync("ChatGPTMessage", res); } var result = chat.MostResentAPIResult;

result.Usage is null

771185858 avatar Jul 21 '23 09:07 771185858

Can someone explain? Thank you very much

771185858 avatar Jul 31 '23 08:07 771185858

Look forward to your help @OkGoDoIt

771185858 avatar Jul 31 '23 08:07 771185858

Hoping this can get looked at as well.

I saw the 1.8 update changed some stuff, this is unfortunately still coming out null for me too.

DaxxTrias avatar Dec 12 '23 01:12 DaxxTrias

When streaming results, OpenAI does not provide usage details. Unfortunately this is a limitation of the OpenAI API and there's nothing I can do about it 😢 See this support thread: https://community.openai.com/t/openai-api-get-usage-tokens-in-response-when-set-stream-true/141866/18

OkGoDoIt avatar Dec 12 '23 05:12 OkGoDoIt

Thank you for the swift response and clarification

DaxxTrias avatar Dec 12 '23 21:12 DaxxTrias