Class Choice

java.lang.Object
com.azure.ai.openai.models.Choice
All Implemented Interfaces:
com.azure.json.JsonSerializable<Choice>

public final class Choice extends Object implements com.azure.json.JsonSerializable<Choice>
The representation of a single prompt completion as part of an overall completions request. Generally, `n` choices are generated per provided prompt with a default value of 1. Token limits and other settings may limit the number of choices generated.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Choice
    fromJson(com.azure.json.JsonReader jsonReader)
    Reads an instance of Choice from the JsonReader.
    Get the contentFilterResults property: Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not.
    Get the finishReason property: Reason for finishing.
    int
    Get the index property: The ordered index associated with this completions choice.
    Get the logprobs property: The log probabilities model for tokens associated with this completions choice.
    Get the text property: The generated text for a given completions prompt.
    com.azure.json.JsonWriter
    toJson(com.azure.json.JsonWriter jsonWriter)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.azure.json.JsonSerializable

    toJson, toJson, toJsonBytes, toJsonString
  • Method Details

    • getText

      public String getText()
      Get the text property: The generated text for a given completions prompt.
      Returns:
      the text value.
    • getIndex

      public int getIndex()
      Get the index property: The ordered index associated with this completions choice.
      Returns:
      the index value.
    • getLogprobs

      public CompletionsLogProbabilityModel getLogprobs()
      Get the logprobs property: The log probabilities model for tokens associated with this completions choice.
      Returns:
      the logprobs value.
    • getFinishReason

      public CompletionsFinishReason getFinishReason()
      Get the finishReason property: Reason for finishing.
      Returns:
      the finishReason value.
    • getContentFilterResults

      public ContentFilterResultsForChoice getContentFilterResults()
      Get the contentFilterResults property: Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not.
      Returns:
      the contentFilterResults value.
    • toJson

      public com.azure.json.JsonWriter toJson(com.azure.json.JsonWriter jsonWriter) throws IOException
      Specified by:
      toJson in interface com.azure.json.JsonSerializable<Choice>
      Throws:
      IOException
    • fromJson

      public static Choice fromJson(com.azure.json.JsonReader jsonReader) throws IOException
      Reads an instance of Choice from the JsonReader.
      Parameters:
      jsonReader - The JsonReader being read.
      Returns:
      An instance of Choice if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.
      Throws:
      IllegalStateException - If the deserialized JSON object was missing any required properties.
      IOException - If an error occurs while reading the Choice.