Package com.azure.ai.inference.models
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 Summary
ConstructorsConstructorDescriptionChatCompletionsOptions
(List<ChatRequestMessage> messages) Creates an instance of ChatCompletionsOptions class. -
Method Summary
Modifier and TypeMethodDescriptionstatic ChatCompletionsOptions
fromJson
(com.azure.json.JsonReader jsonReader) Reads an instance of ChatCompletionsOptions from the JsonReader.Get the additionalProperties property: The ChatCompletionsOptions model.Get the extraParams property: Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload.Get the frequencyPenalty property: A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text.Get the maxTokens property: The maximum number of tokens to generate.Get the messages property: The collection of context messages associated with this chat completions request.getModel()
Get the model property: ID of the specific AI model to use, if more than one model is available on the endpoint.Get the presencePenalty property: A value that influences the probability of generated tokens appearing based on their existing presence in generated text.Get the responseFormat property: An object specifying the format that the model must output.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.getStop()
Get the stop property: A collection of textual sequences that will end completions generation.Get the temperature property: The sampling temperature to use that controls the apparent creativity of generated completions.com.azure.core.util.BinaryData
Get the toolChoice property: If specified, the model will configure which of the provided tools it can use for the chat completions response.getTools()
Get the tools property: A list of tools the model may request to call.getTopP()
Get the topP property: An alternative to sampling with temperature called nucleus sampling.isStream()
Get the stream property: A value indicating whether chat completions should be streamed for this request.setAdditionalProperties
(Map<String, com.azure.core.util.BinaryData> additionalProperties) Set the additionalProperties property: The ChatCompletionsOptions model.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.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.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.setMaxTokens
(Integer maxTokens) Set the maxTokens property: The maximum number of tokens to generate.Set the model property: ID of the specific AI model to use, if more than one model is available on the endpoint.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.setResponseFormat
(ChatCompletionsResponseFormat responseFormat) Set the responseFormat property: An object specifying the format that the model must output.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.Set the stop property: A collection of textual sequences that will end completions generation.setTemperature
(Double temperature) Set the temperature property: The sampling temperature to use that controls the apparent creativity of generated completions.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.Set the tools property: A list of tools the model may request to call.Set the topP property: An alternative to sampling with temperature called nucleus sampling.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
-
ChatCompletionsOptions
Creates an instance of ChatCompletionsOptions class.- Parameters:
messages
- the messages value to set.
-
-
Method Details
-
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
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
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
Get the stream property: A value indicating whether chat completions should be streamed for this request.- Returns:
- the stream value.
-
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
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
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
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
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
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
Get the maxTokens property: The maximum number of tokens to generate.- Returns:
- the maxTokens value.
-
setMaxTokens
Set the maxTokens property: The maximum number of tokens to generate.- Parameters:
maxTokens
- the maxTokens value to set.- Returns:
- the ChatCompletionsOptions object itself.
-
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
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
Get the stop property: A collection of textual sequences that will end completions generation.- Returns:
- the stop value.
-
setStop
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
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
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
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
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
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
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
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
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
- Specified by:
toJson
in interfacecom.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
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.
-