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

Chat Streaming does not work #190

Closed
ysemenenko opened this issue Feb 1, 2024 · 2 comments
Closed

Chat Streaming does not work #190

ysemenenko opened this issue Feb 1, 2024 · 2 comments

Comments

@ysemenenko
Copy link

message = "Count to 100, with a comma between each number and no newlines. E.g., 1, 2, 3, ...";

var chat = _api.Chat.CreateConversation();
chat.Model = Model.ChatGPTTurbo;
chat.RequestParameters.MaxTokens = 1000;
chat.RequestParameters.Temperature = 0.7;
chat.AppendUserInput(message);

await foreach (var textResult in chat.StreamResponseEnumerableFromChatbotAsync())
{
MainThread.BeginInvokeOnMainThread(() =>
{
this.mainViewModel.OutputText += textResult;
});
}

var promptTokens = chat.MostRecentApiResult?.Usage?.PromptTokens ?? 0;
var completionTokens = chat.MostRecentApiResult?.Usage?.CompletionTokens ?? 0;

Usage object is null and impossible to receive tokens in usage

@OkGoDoIt
Copy link
Owner

OkGoDoIt commented Feb 1, 2024

Unfortunately OpenAI does not provide token usage information when streaming results. This is a limitation of OpenAI and there is unfortunately nothing I can do about it. See details in #166 and at https://community.openai.com/t/openai-api-get-usage-tokens-in-response-when-set-stream-true/. Sorry 🤷‍♂️

@OkGoDoIt OkGoDoIt closed this as completed Feb 1, 2024
@ysemenenko
Copy link
Author

Thank you very much for response.

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

2 participants