Skip to content
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

MostResentAPIResult.Usage is null #166

Open
771185858 opened this issue Jul 21, 2023 · 5 comments
Open

MostResentAPIResult.Usage is null #166

771185858 opened this issue Jul 21, 2023 · 5 comments

Comments

@771185858
Copy link

771185858 commented Jul 21, 2023

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
Copy link
Author

Can someone explain? Thank you very much

@771185858
Copy link
Author

Look forward to your help @OkGoDoIt

@DaxxTrias
Copy link

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.

@OkGoDoIt
Copy link
Owner

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

@DaxxTrias
Copy link

Thank you for the swift response and clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants