Package com.azure.ai.openai.models
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
ConstructorsConstructorDescriptionCompletionsOptions(List<String> prompt) Creates an instance of CompletionsOptions class. -
Method Summary
Modifier and TypeMethodDescriptionstatic CompletionsOptionsfromJson(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.getModel()Get the model property: The model name to provide as part of this completions request.getN()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.getStop()Get the stop property: A collection of textual sequences that will end completions generation.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.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.isEcho()Get the echo property: A value specifying whether completions responses should include input prompts as prefixes to their generated output.isStream()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.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.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 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.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.JsonWritertoJson(com.azure.json.JsonWriter jsonWriter)
-
Constructor Details
-
CompletionsOptions
Creates an instance of CompletionsOptions class.- Parameters:
prompt- the prompt value to set.
-
-
Method Details
-
getPrompt
Get the prompt property: The prompts to generate completions from.- Returns:
- the prompt 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 CompletionsOptions 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 CompletionsOptions 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 CompletionsOptions 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 CompletionsOptions 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 CompletionsOptions object itself.
-
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
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
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
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
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
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
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 CompletionsOptions 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 CompletionsOptions 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 CompletionsOptions object itself.
-
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
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
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 CompletionsOptions 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 CompletionsOptions object itself.
-
getSuffix
Get the suffix property: The suffix that comes after a completion of inserted text.- Returns:
- the suffix value.
-
setSuffix
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
- Specified by:
toJsonin interfacecom.azure.json.JsonSerializable<CompletionsOptions>- Throws:
IOException
-
fromJson
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.
-