Package com.azure.ai.openai.models
Class ChatCompletionsOptions
java.lang.Object
com.azure.ai.openai.models.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 Summary
ConstructorsConstructorDescriptionChatCompletionsOptions(List<ChatMessage> messages) Creates an instance of ChatCompletionsOptions class. -
Method Summary
Modifier and TypeMethodDescriptionGet the frequencyPenalty property: A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text.Get the functionCall property: Controls how the model responds to function calls.Get the functions property: A list of functions the model may generate JSON inputs for.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 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: The model name to provide as part of this completions request.getN()Get the n property: The number of chat completions choices that should be generated for a chat completions response.Get the presencePenalty property: A value that influences the probability of generated tokens appearing based on their existing presence in generated text.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.getTopP()Get the topP property: An alternative to sampling with temperature called nucleus sampling.getUser()Get the user property: An identifier for the caller or end user of the operation.isStream()Get the stream property: A value indicating whether chat completions should be streamed for this request.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.setFunctionCall(FunctionCallConfig functionCallConfig) Set the functionCall property: Controls how the model responds to function calls.setFunctions(List<FunctionDefinition> functions) Set the functions property: A list of functions the model may generate JSON inputs for.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.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 chat completions choices that should be generated for a chat 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 stop property: A collection of textual sequences that will end completions generation.Set the stream property: A value indicating whether chat completions should be streamed for this request.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.
-
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.
-
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.
-
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
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
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
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
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
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
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
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
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
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.
-
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
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
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
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
Get the stream property: A value indicating whether chat completions should be streamed for this request.- Returns:
- the stream value.
-
setStream
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
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
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
Get the functions property: A list of functions the model may generate JSON inputs for.- Returns:
- the functions value.
-
setFunctions
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
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
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.
-