OpenAI-API-dotnet
OpenAI-API-dotnet copied to clipboard
A Task Was cancelled
I raises when I call, CreateCompletionAsync It began when I exceded the free plan, but I set a payment method and still the same,
System.Threading.Tasks.TaskCanceledException: A task was canceled
Any Ideas?
@kikores , can you show the relavant section of code, how you are using CreateCompletionAsync, for example.
Hi, Here is some code, and Yes, I am using CreateCompletionAsync(),
int promptTokens = completion.Prompt.Trim().Split().Length;
completion.MaxTokens = 4096 - (promptTokens + 200);
var result = openAI.Completions.CreateCompletionAsync(completion).GetAwaiter().GetResult();
if (result != null && result.Completions.Count > 0)
{
return result.Completions.FirstOrDefault()?.Text;
}
return null;
Sometimes it works... but other times I have the error...