CompletionChoice

data class CompletionChoice(val text: String, val index: Int, val logprobs: List<Float>?, val finishReason: FinishReason)

The OpenAI API returns a list of CompletionChoice. Each choice has a generated message (CompletionChoice.text) and a finish reason (CompletionChoice.finishReason). For most use cases, you only need the generated text.

By default, only 1 choice is generated (since CompletionRequest.n == 1). When you increase n or provide a list of prompts (called batching), there will be multiple choices.

See also

Constructors

Link copied to clipboard
constructor(text: String, index: Int, logprobs: List<Float>?, finishReason: FinishReason)

Create empty Completion choice, for internal usage.

Properties

Link copied to clipboard

The reason the bot stopped generating tokens.

Link copied to clipboard
val index: Int

The index in the list... This is 0 for most use cases.

Link copied to clipboard

List of logarithmic probabilities for each token in the generated text.

Link copied to clipboard

The generated text.