-
-
Notifications
You must be signed in to change notification settings - Fork 529
Completions Stream
Tolga Kayhan edited this page Feb 16, 2023
·
1 revision
var completionResult = sdk.Completions.CreateCompletionAsStream(new CompletionCreateRequest()
{
Prompt = "Once upon a time",
MaxTokens = 500, // optional
Model = Models.Davinci
});
await foreach (var completion in completionResult)
{
if (completion.Successful)
{
Console.Write(completion.Choices.FirstOrDefault()?.Text);
}
else
{
if (completion.Error == null)
{
throw new Exception("Unknown Error");
}
Console.WriteLine($"{completion.Error.Code}: {completion.Error.Message}");
}
}