Class CompletionsOptions

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

public final class CompletionsOptions extends Object implements com.azure.json.JsonSerializable<CompletionsOptions>
The configuration information for a completions request. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of CompletionsOptions class.
  • Method Summary

    Modifier and Type
    Method
    Description
    fromJson(com.azure.json.JsonReader jsonReader)
    Reads an instance of CompletionsOptions from the JsonReader.
    Get the bestOf property: A value that controls how many completions will be internally generated prior to response formulation.
    Get the frequencyPenalty property: A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text.
    Get the logitBias property: A map between GPT token IDs and bias scores that influences the probability of specific tokens appearing in a completions response.
    Get the logprobs property: A value that controls the emission of log probabilities for the provided number of most likely tokens within a completions response.
    Get the maxTokens property: The maximum number of tokens to generate.
    Get the model property: The model name to provide as part of this completions request.
    Get the n property: The number of completions choices that should be generated per provided prompt as part of an overall completions response.
    Get the presencePenalty property: A value that influences the probability of generated tokens appearing based on their existing presence in generated text.
    Get the prompt property: The prompts to generate completions from.
    Get the seed property: If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
    Get the stop property: A collection of textual sequences that will end completions generation.
    Get the streamOptions property: Options for streaming response.
    Get the suffix property: The suffix that comes after a completion of inserted text.
    Get the temperature property: The sampling temperature to use that controls the apparent creativity of generated completions.
    Get the topP property: An alternative to sampling with temperature called nucleus sampling.
    Get the user property: An identifier for the caller or end user of the operation.
    Get the echo property: A value specifying whether completions responses should include input prompts as prefixes to their generated output.
    Get the stream property: A value indicating whether chat completions should be streamed for this request.
    Set the bestOf property: A value that controls how many completions will be internally generated prior to response formulation.
    Set the echo property: A value specifying whether completions responses should include input prompts as prefixes to their generated output.
    setFrequencyPenalty(Double frequencyPenalty)
    Set the frequencyPenalty property: A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text.
    Set the logitBias property: A map between GPT token IDs and bias scores that influences the probability of specific tokens appearing in a completions response.
    setLogprobs(Integer logprobs)
    Set the logprobs property: A value that controls the emission of log probabilities for the provided number of most likely tokens within a completions response.
    setMaxTokens(Integer maxTokens)
    Set the maxTokens property: The maximum number of tokens to generate.
    Set the model property: The model name to provide as part of this completions request.
    Set the n property: The number of completions choices that should be generated per provided prompt as part of an overall completions response.
    setPresencePenalty(Double presencePenalty)
    Set the presencePenalty property: A value that influences the probability of generated tokens appearing based on their existing presence in generated text.
    Set the seed property: If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
    Set the stop property: A collection of textual sequences that will end completions generation.
    setSuffix(String suffix)
    Set the suffix property: The suffix that comes after a completion of inserted text.
    setTemperature(Double temperature)
    Set the temperature property: The sampling temperature to use that controls the apparent creativity of generated completions.
    Set the topP property: An alternative to sampling with temperature called nucleus sampling.
    Set the user property: An identifier for the caller or end user of the operation.
    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
  • Constructor Details

    • CompletionsOptions

      public CompletionsOptions(List<String> prompt)
      Creates an instance of CompletionsOptions class.
      Parameters:
      prompt - the prompt value to set.
  • Method Details

    • getPrompt

      public List<String> getPrompt()
      Get the prompt property: The prompts to generate completions from.
      Returns:
      the prompt value.
    • getMaxTokens

      public Integer getMaxTokens()
      Get the maxTokens property: The maximum number of tokens to generate.
      Returns:
      the maxTokens value.
    • setMaxTokens

      public CompletionsOptions setMaxTokens(Integer maxTokens)
      Set the maxTokens property: The maximum number of tokens to generate.
      Parameters:
      maxTokens - the maxTokens value to set.
      Returns:
      the CompletionsOptions object itself.
    • getTemperature

      public Double getTemperature()
      Get the temperature property: The sampling temperature to use that controls the apparent creativity of generated completions. Higher values will make output more random while lower values will make results more focused and deterministic. It is not recommended to modify temperature and top_p for the same completions request as the interaction of these two settings is difficult to predict.
      Returns:
      the temperature value.
    • setTemperature

      public CompletionsOptions setTemperature(Double temperature)
      Set the temperature property: The sampling temperature to use that controls the apparent creativity of generated completions. Higher values will make output more random while lower values will make results more focused and deterministic. It is not recommended to modify temperature and top_p for the same completions request as the interaction of these two settings is difficult to predict.
      Parameters:
      temperature - the temperature value to set.
      Returns:
      the CompletionsOptions object itself.
    • getTopP

      public Double getTopP()
      Get the topP property: An alternative to sampling with temperature called nucleus sampling. This value causes the model to consider the results of tokens with the provided probability mass. As an example, a value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be considered. It is not recommended to modify temperature and top_p for the same completions request as the interaction of these two settings is difficult to predict.
      Returns:
      the topP value.
    • setTopP

      public CompletionsOptions setTopP(Double topP)
      Set the topP property: An alternative to sampling with temperature called nucleus sampling. This value causes the model to consider the results of tokens with the provided probability mass. As an example, a value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be considered. It is not recommended to modify temperature and top_p for the same completions request as the interaction of these two settings is difficult to predict.
      Parameters:
      topP - the topP value to set.
      Returns:
      the CompletionsOptions object itself.
    • getLogitBias

      public Map<String,Integer> getLogitBias()
      Get the logitBias property: A map between GPT token IDs and bias scores that influences the probability of specific tokens appearing in a completions response. Token IDs are computed via external tokenizer tools, while bias scores reside in the range of -100 to 100 with minimum and maximum values corresponding to a full ban or exclusive selection of a token, respectively. The exact behavior of a given bias score varies by model.
      Returns:
      the logitBias value.
    • setLogitBias

      public CompletionsOptions setLogitBias(Map<String,Integer> logitBias)
      Set the logitBias property: A map between GPT token IDs and bias scores that influences the probability of specific tokens appearing in a completions response. Token IDs are computed via external tokenizer tools, while bias scores reside in the range of -100 to 100 with minimum and maximum values corresponding to a full ban or exclusive selection of a token, respectively. The exact behavior of a given bias score varies by model.
      Parameters:
      logitBias - the logitBias value to set.
      Returns:
      the CompletionsOptions object itself.
    • getUser

      public String getUser()
      Get the user property: An identifier for the caller or end user of the operation. This may be used for tracking or rate-limiting purposes.
      Returns:
      the user value.
    • setUser

      public CompletionsOptions setUser(String user)
      Set the user property: An identifier for the caller or end user of the operation. This may be used for tracking or rate-limiting purposes.
      Parameters:
      user - the user value to set.
      Returns:
      the CompletionsOptions object itself.
    • getN

      public Integer getN()
      Get the n property: The number of completions choices that should be generated per provided prompt as part of an overall completions response. Because this setting can generate many completions, it may quickly consume your token quota. Use carefully and ensure reasonable settings for max_tokens and stop.
      Returns:
      the n value.
    • setN

      public CompletionsOptions setN(Integer n)
      Set the n property: The number of completions choices that should be generated per provided prompt as part of an overall completions response. Because this setting can generate many completions, it may quickly consume your token quota. Use carefully and ensure reasonable settings for max_tokens and stop.
      Parameters:
      n - the n value to set.
      Returns:
      the CompletionsOptions object itself.
    • getLogprobs

      public Integer getLogprobs()
      Get the logprobs property: A value that controls the emission of log probabilities for the provided number of most likely tokens within a completions response.
      Returns:
      the logprobs value.
    • setLogprobs

      public CompletionsOptions setLogprobs(Integer logprobs)
      Set the logprobs property: A value that controls the emission of log probabilities for the provided number of most likely tokens within a completions response.
      Parameters:
      logprobs - the logprobs value to set.
      Returns:
      the CompletionsOptions object itself.
    • isEcho

      public Boolean isEcho()
      Get the echo property: A value specifying whether completions responses should include input prompts as prefixes to their generated output.
      Returns:
      the echo value.
    • setEcho

      public CompletionsOptions setEcho(Boolean echo)
      Set the echo property: A value specifying whether completions responses should include input prompts as prefixes to their generated output.
      Parameters:
      echo - the echo value to set.
      Returns:
      the CompletionsOptions object itself.
    • getStop

      public List<String> getStop()
      Get the stop property: A collection of textual sequences that will end completions generation.
      Returns:
      the stop value.
    • setStop

      public CompletionsOptions setStop(List<String> stop)
      Set the stop property: A collection of textual sequences that will end completions generation.
      Parameters:
      stop - the stop value to set.
      Returns:
      the CompletionsOptions object itself.
    • getPresencePenalty

      public Double getPresencePenalty()
      Get the presencePenalty property: A value that influences the probability of generated tokens appearing based on their existing presence in generated text. Positive values will make tokens less likely to appear when they already exist and increase the model's likelihood to output new topics.
      Returns:
      the presencePenalty value.
    • setPresencePenalty

      public CompletionsOptions setPresencePenalty(Double presencePenalty)
      Set the presencePenalty property: A value that influences the probability of generated tokens appearing based on their existing presence in generated text. Positive values will make tokens less likely to appear when they already exist and increase the model's likelihood to output new topics.
      Parameters:
      presencePenalty - the presencePenalty value to set.
      Returns:
      the CompletionsOptions object itself.
    • getFrequencyPenalty

      public Double getFrequencyPenalty()
      Get the frequencyPenalty property: A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text. Positive values will make tokens less likely to appear as their frequency increases and decrease the likelihood of the model repeating the same statements verbatim.
      Returns:
      the frequencyPenalty value.
    • setFrequencyPenalty

      public CompletionsOptions setFrequencyPenalty(Double frequencyPenalty)
      Set the frequencyPenalty property: A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text. Positive values will make tokens less likely to appear as their frequency increases and decrease the likelihood of the model repeating the same statements verbatim.
      Parameters:
      frequencyPenalty - the frequencyPenalty value to set.
      Returns:
      the CompletionsOptions object itself.
    • getBestOf

      public Integer getBestOf()
      Get the bestOf property: A value that controls how many completions will be internally generated prior to response formulation. When used together with n, best_of controls the number of candidate completions and must be greater than n. Because this setting can generate many completions, it may quickly consume your token quota. Use carefully and ensure reasonable settings for max_tokens and stop.
      Returns:
      the bestOf value.
    • setBestOf

      public CompletionsOptions setBestOf(Integer bestOf)
      Set the bestOf property: A value that controls how many completions will be internally generated prior to response formulation. When used together with n, best_of controls the number of candidate completions and must be greater than n. Because this setting can generate many completions, it may quickly consume your token quota. Use carefully and ensure reasonable settings for max_tokens and stop.
      Parameters:
      bestOf - the bestOf value to set.
      Returns:
      the CompletionsOptions object itself.
    • isStream

      public Boolean isStream()
      Get the stream property: A value indicating whether chat completions should be streamed for this request.
      Returns:
      the stream value.
    • getModel

      public String getModel()
      Get the model property: The model name to provide as part of this completions request. Not applicable to Azure OpenAI, where deployment information should be included in the Azure resource URI that's connected to.
      Returns:
      the model value.
    • setModel

      public CompletionsOptions setModel(String model)
      Set the model property: The model name to provide as part of this completions request. Not applicable to Azure OpenAI, where deployment information should be included in the Azure resource URI that's connected to.
      Parameters:
      model - the model value to set.
      Returns:
      the CompletionsOptions object itself.
    • getSuffix

      public String getSuffix()
      Get the suffix property: The suffix that comes after a completion of inserted text.
      Returns:
      the suffix value.
    • setSuffix

      public CompletionsOptions setSuffix(String suffix)
      Set the suffix property: The suffix that comes after a completion of inserted text.
      Parameters:
      suffix - the suffix value to set.
      Returns:
      the CompletionsOptions object itself.
    • toJson

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

      public static CompletionsOptions fromJson(com.azure.json.JsonReader jsonReader) throws IOException
      Reads an instance of CompletionsOptions from the JsonReader.
      Parameters:
      jsonReader - The JsonReader being read.
      Returns:
      An instance of CompletionsOptions 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 CompletionsOptions.
    • getSeed

      public Integer getSeed()
      Get the seed property: If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
      Returns:
      the seed value.
    • setSeed

      public CompletionsOptions setSeed(Integer seed)
      Set the seed property: If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
      Parameters:
      seed - the seed value to set.
      Returns:
      the CompletionsOptions object itself.
    • getStreamOptions

      public ChatCompletionStreamOptions getStreamOptions()
      Get the streamOptions property: Options for streaming response. Only set this when you set `stream: true`.
      Returns:
      the streamOptions value.