Class ChatCompletionsOptions

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

public final class ChatCompletionsOptions extends Object implements com.azure.json.JsonSerializable<ChatCompletionsOptions>
The ChatCompletionsOptions model.
  • 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.
    • 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. Supported range is [-2, 2].
      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. Supported range is [-2, 2].
      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.
    • 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. Supported range is [-2, 2].
      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. Supported range is [-2, 2].
      Parameters:
      presencePenalty - the presencePenalty 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. Supported range is [0, 1].
      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. Supported range is [0, 1].
      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. Supported range is [0, 1].
      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. Supported range is [0, 1].
      Parameters:
      topP - the topP value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • 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.
    • getResponseFormat

      public ChatCompletionsResponseFormat getResponseFormat()
      Get the responseFormat property: An object specifying the format that the model must output. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
      Returns:
      the responseFormat value.
    • setResponseFormat

      public ChatCompletionsOptions setResponseFormat(ChatCompletionsResponseFormat responseFormat)
      Set the responseFormat property: An object specifying the format that the model must output. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
      Parameters:
      responseFormat - the responseFormat value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • setJsonFormat

      public ChatCompletionsOptions setJsonFormat(String name, Map<String,com.azure.core.util.BinaryData> jsonSchema)
      Set the responseFormat to a given JSON schema: The format that the model must output. Use this to enable JSON mode instead of
      Parameters:
      name - the name of the schema.
      jsonSchema - the JSON schema 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.
    • getTools

      public List<ChatCompletionsToolDefinition> getTools()
      Get the tools property: A list of tools the model may request to call. Currently, only functions are supported as a tool. The model may response with a function call request and provide the input arguments in JSON format for that function.
      Returns:
      the tools value.
    • setTools

      Set the tools property: A list of tools the model may request to call. Currently, only functions are supported as a tool. The model may response with a function call request and provide the input arguments in JSON format for that function.
      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.
    • 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.
      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.
      Parameters:
      seed - the seed value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getModel

      public String getModel()
      Get the model property: ID of the specific AI model to use, if more than one model is available on the endpoint.
      Returns:
      the model value.
    • setModel

      public ChatCompletionsOptions setModel(String model)
      Set the model property: ID of the specific AI model to use, if more than one model is available on the endpoint.
      Parameters:
      model - the model value to set.
      Returns:
      the ChatCompletionsOptions object itself.
    • getExtraParams

      public ExtraParameters getExtraParams()
      Get the extraParams property: Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload. This sets the HTTP request header `extra-parameters`.
      Returns:
      the extraParams value.
    • setExtraParams

      public ChatCompletionsOptions setExtraParams(ExtraParameters extraParams)
      Set the extraParams property: Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload. This sets the HTTP request header `extra-parameters`.
      Parameters:
      extraParams - the extraParams 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 - If an error occurs while writing fields to the ChatCompletionsOptions instance.
    • 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.
    • getAdditionalProperties

      public Map<String,com.azure.core.util.BinaryData> getAdditionalProperties()
      Get the additionalProperties property: The ChatCompletionsOptions model.
      Returns:
      the additionalProperties value.
    • setAdditionalProperties

      public ChatCompletionsOptions setAdditionalProperties(Map<String,com.azure.core.util.BinaryData> additionalProperties)
      Set the additionalProperties property: The ChatCompletionsOptions model.
      Parameters:
      additionalProperties - the additionalProperties value to set.
      Returns:
      the ChatCompletionsOptions object itself.