Class ChatCompletionsOptions

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

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

    • ChatCompletionsOptions

      public ChatCompletionsOptions(List<ChatRequestMessage> messages)
      Creates an instance of ChatCompletionsOptions class.
      Parameters:
      messages - the messages value to set.
  • Method Details

    • getMessages

      public List<ChatRequestMessage> getMessages()
      Get the messages property: The collection of context messages associated with this chat completions request. Typical usage begins with a chat message for the System role that provides instructions for the behavior of the assistant, followed by alternating messages between the User and Assistant roles.
      Returns:
      the messages value.
    • getMaxTokens

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

      public ChatCompletionsOptions setMaxTokens(Integer maxTokens)
      Set the maxTokens property: The maximum number of tokens to generate.
      Parameters:
      maxTokens - the maxTokens value to set.
      Returns:
      the ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions object itself.
    • getN

      public Integer getN()
      Get the n property: The number of chat completions choices that should be generated for a chat 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

      Set the n property: The number of chat completions choices that should be generated for a chat 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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 ChatCompletionsOptions 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.
    • setStream

      public ChatCompletionsOptions setStream(Boolean stream)
      Set the stream property: A value indicating whether chat completions should be streamed for this request.
      Parameters:
      stream - the stream value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • 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 ChatCompletionsOptions 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 ChatCompletionsOptions object itself.
    • getFunctions

      public List<FunctionDefinition> getFunctions()
      Get the functions property: A list of functions the model may generate JSON inputs for.
      Returns:
      the functions value.
    • setFunctions

      public ChatCompletionsOptions setFunctions(List<FunctionDefinition> functions)
      Set the functions property: A list of functions the model may generate JSON inputs for.
      Parameters:
      functions - the functions value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getFunctionCall

      public FunctionCallConfig getFunctionCall()
      Get the functionCall property: Controls how the model responds to function calls. "none" means the model does not call a function, and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. "none" is the default when no functions are present. "auto" is the default if functions are present.
      Returns:
      the functionCall value.
    • setFunctionCall

      public ChatCompletionsOptions setFunctionCall(FunctionCallConfig functionCallConfig)
      Set the functionCall property: Controls how the model responds to function calls. "none" means the model does not call a function, and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. "none" is the default when no functions are present. "auto" is the default if functions are present.
      Parameters:
      functionCallConfig - the functionCall value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getDataSources

      public List<AzureChatExtensionConfiguration> getDataSources()
      Get the dataSources property: The configuration entries for Azure OpenAI chat extensions that use them. This additional specification is only compatible with Azure OpenAI.
      Returns:
      the dataSources value.
    • setDataSources

      public ChatCompletionsOptions setDataSources(List<AzureChatExtensionConfiguration> dataSources)
      Set the dataSources property: The configuration entries for Azure OpenAI chat extensions that use them. This additional specification is only compatible with Azure OpenAI.
      Parameters:
      dataSources - the dataSources value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getEnhancements

      public AzureChatEnhancementConfiguration getEnhancements()
      Get the enhancements property: If provided, the configuration options for available Azure OpenAI chat enhancements.
      Returns:
      the enhancements value.
    • setEnhancements

      public ChatCompletionsOptions setEnhancements(AzureChatEnhancementConfiguration enhancements)
      Set the enhancements property: If provided, the configuration options for available Azure OpenAI chat enhancements.
      Parameters:
      enhancements - the enhancements value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getSeed

      public Long getSeed()
      Get the seed property: If specified, the 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 ChatCompletionsOptions setSeed(Long seed)
      Set the seed property: If specified, the 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 ChatCompletionsOptions object itself.
    • getResponseFormat

      public ChatCompletionsResponseFormat getResponseFormat()
      Get the responseFormat property: An object specifying the format that the model must output. Used to enable JSON mode.
      Returns:
      the responseFormat value.
    • setResponseFormat

      public ChatCompletionsOptions setResponseFormat(ChatCompletionsResponseFormat responseFormat)
      Set the responseFormat property: An object specifying the format that the model must output. Used to enable JSON mode.
      Parameters:
      responseFormat - the responseFormat value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getTools

      public List<ChatCompletionsToolDefinition> getTools()
      Get the tools property: The available tool definitions that the chat completions request can use, including caller-defined functions.
      Returns:
      the tools value.
    • setTools

      Set the tools property: The available tool definitions that the chat completions request can use, including caller-defined functions.
      Parameters:
      tools - the tools value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getToolChoice

      public com.azure.core.util.BinaryData getToolChoice()
      Get the toolChoice property: If specified, the model will configure which of the provided tools it can use for the chat completions response.
      Returns:
      the toolChoice value.
    • setToolChoice

      public ChatCompletionsOptions setToolChoice(com.azure.core.util.BinaryData toolChoice)
      Set the toolChoice property: If specified, the model will configure which of the provided tools it can use for the chat completions response.
      Parameters:
      toolChoice - the toolChoice value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • isLogprobs

      public Boolean isLogprobs()
      Get the logprobs property: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. This option is currently not available on the `gpt-4-vision-preview` model.
      Returns:
      the logprobs value.
    • setLogprobs

      public ChatCompletionsOptions setLogprobs(Boolean logprobs)
      Set the logprobs property: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. This option is currently not available on the `gpt-4-vision-preview` model.
      Parameters:
      logprobs - the logprobs value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getTopLogprobs

      public Integer getTopLogprobs()
      Get the topLogprobs property: An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.
      Returns:
      the topLogprobs value.
    • setTopLogprobs

      public ChatCompletionsOptions setTopLogprobs(Integer topLogprobs)
      Set the topLogprobs property: An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.
      Parameters:
      topLogprobs - the topLogprobs value to set.
      Returns:
      the ChatCompletionsOptions 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<ChatCompletionsOptions>
      Throws:
      IOException
    • fromJson

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