com.github.tjake.jlama.net.openai.model.CreateCompletionRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jlama-net Show documentation
Show all versions of jlama-net Show documentation
Jlama: A modern LLM inference engine for Java
The newest version!
/*
* OpenAI API
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.github.tjake.jlama.net.openai.model;
import java.util.Objects;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.github.tjake.jlama.net.openai.model.ChatCompletionStreamOptions;
import com.github.tjake.jlama.net.openai.model.CreateCompletionRequestModel;
import com.github.tjake.jlama.net.openai.model.CreateCompletionRequestPrompt;
import com.github.tjake.jlama.net.openai.model.CreateCompletionRequestStop;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import jakarta.validation.constraints.*;
import jakarta.validation.Valid;
import org.hibernate.validator.constraints.*;
import com.github.tjake.jlama.net.openai.JSON;
/**
* CreateCompletionRequest
*/
@JsonPropertyOrder({
CreateCompletionRequest.JSON_PROPERTY_MODEL,
CreateCompletionRequest.JSON_PROPERTY_PROMPT,
CreateCompletionRequest.JSON_PROPERTY_BEST_OF,
CreateCompletionRequest.JSON_PROPERTY_ECHO,
CreateCompletionRequest.JSON_PROPERTY_FREQUENCY_PENALTY,
CreateCompletionRequest.JSON_PROPERTY_LOGIT_BIAS,
CreateCompletionRequest.JSON_PROPERTY_LOGPROBS,
CreateCompletionRequest.JSON_PROPERTY_MAX_TOKENS,
CreateCompletionRequest.JSON_PROPERTY_N,
CreateCompletionRequest.JSON_PROPERTY_PRESENCE_PENALTY,
CreateCompletionRequest.JSON_PROPERTY_SEED,
CreateCompletionRequest.JSON_PROPERTY_STOP,
CreateCompletionRequest.JSON_PROPERTY_STREAM,
CreateCompletionRequest.JSON_PROPERTY_STREAM_OPTIONS,
CreateCompletionRequest.JSON_PROPERTY_SUFFIX,
CreateCompletionRequest.JSON_PROPERTY_TEMPERATURE,
CreateCompletionRequest.JSON_PROPERTY_TOP_P,
CreateCompletionRequest.JSON_PROPERTY_USER
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.7.0")
public class CreateCompletionRequest {
public static final String JSON_PROPERTY_MODEL = "model";
private CreateCompletionRequestModel model;
public static final String JSON_PROPERTY_PROMPT = "prompt";
private CreateCompletionRequestPrompt prompt;
public static final String JSON_PROPERTY_BEST_OF = "best_of";
private Integer bestOf = 1;
public static final String JSON_PROPERTY_ECHO = "echo";
private Boolean echo = false;
public static final String JSON_PROPERTY_FREQUENCY_PENALTY = "frequency_penalty";
private BigDecimal frequencyPenalty = new BigDecimal("0");
public static final String JSON_PROPERTY_LOGIT_BIAS = "logit_bias";
private Map logitBias;
public static final String JSON_PROPERTY_LOGPROBS = "logprobs";
private Integer logprobs;
public static final String JSON_PROPERTY_MAX_TOKENS = "max_tokens";
private Integer maxTokens = 16;
public static final String JSON_PROPERTY_N = "n";
private Integer n = 1;
public static final String JSON_PROPERTY_PRESENCE_PENALTY = "presence_penalty";
private BigDecimal presencePenalty = new BigDecimal("0");
public static final String JSON_PROPERTY_SEED = "seed";
private Integer seed;
public static final String JSON_PROPERTY_STOP = "stop";
private CreateCompletionRequestStop stop = null;
public static final String JSON_PROPERTY_STREAM = "stream";
private Boolean stream = false;
public static final String JSON_PROPERTY_STREAM_OPTIONS = "stream_options";
private ChatCompletionStreamOptions streamOptions;
public static final String JSON_PROPERTY_SUFFIX = "suffix";
private String suffix;
public static final String JSON_PROPERTY_TEMPERATURE = "temperature";
private BigDecimal temperature = new BigDecimal("1");
public static final String JSON_PROPERTY_TOP_P = "top_p";
private BigDecimal topP = new BigDecimal("1");
public static final String JSON_PROPERTY_USER = "user";
private String user;
public CreateCompletionRequest() {
}
public CreateCompletionRequest model(CreateCompletionRequestModel model) {
this.model = model;
return this;
}
/**
* Get model
* @return model
*/
@jakarta.annotation.Nonnull
@NotNull
@Valid
@JsonProperty(JSON_PROPERTY_MODEL)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public CreateCompletionRequestModel getModel() {
return model;
}
@JsonProperty(JSON_PROPERTY_MODEL)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setModel(CreateCompletionRequestModel model) {
this.model = model;
}
public CreateCompletionRequest prompt(CreateCompletionRequestPrompt prompt) {
this.prompt = prompt;
return this;
}
/**
* Get prompt
* @return prompt
*/
@jakarta.annotation.Nullable
@NotNull
@Valid
@JsonProperty(JSON_PROPERTY_PROMPT)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public CreateCompletionRequestPrompt getPrompt() {
return prompt;
}
@JsonProperty(JSON_PROPERTY_PROMPT)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setPrompt(CreateCompletionRequestPrompt prompt) {
this.prompt = prompt;
}
public CreateCompletionRequest bestOf(Integer bestOf) {
this.bestOf = bestOf;
return this;
}
/**
* Generates `best_of` completions server-side and returns the \"best\" (the one with the highest log probability per token). Results cannot be streamed. When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`. **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.
* minimum: 0
* maximum: 20
* @return bestOf
*/
@jakarta.annotation.Nullable
@Min(0) @Max(20)
@JsonProperty(JSON_PROPERTY_BEST_OF)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Integer getBestOf() {
return bestOf;
}
@JsonProperty(JSON_PROPERTY_BEST_OF)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setBestOf(Integer bestOf) {
this.bestOf = bestOf;
}
public CreateCompletionRequest echo(Boolean echo) {
this.echo = echo;
return this;
}
/**
* Echo back the prompt in addition to the completion
* @return echo
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ECHO)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Boolean getEcho() {
return echo;
}
@JsonProperty(JSON_PROPERTY_ECHO)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setEcho(Boolean echo) {
this.echo = echo;
}
public CreateCompletionRequest frequencyPenalty(BigDecimal frequencyPenalty) {
this.frequencyPenalty = frequencyPenalty;
return this;
}
/**
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)
* minimum: -2
* maximum: 2
* @return frequencyPenalty
*/
@jakarta.annotation.Nullable
@Valid
@DecimalMin("-2") @DecimalMax("2")
@JsonProperty(JSON_PROPERTY_FREQUENCY_PENALTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getFrequencyPenalty() {
return frequencyPenalty;
}
@JsonProperty(JSON_PROPERTY_FREQUENCY_PENALTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setFrequencyPenalty(BigDecimal frequencyPenalty) {
this.frequencyPenalty = frequencyPenalty;
}
public CreateCompletionRequest logitBias(Map logitBias) {
this.logitBias = logitBias;
return this;
}
public CreateCompletionRequest putLogitBiasItem(String key, Integer logitBiasItem) {
if (this.logitBias == null) {
this.logitBias = new HashMap<>();
}
this.logitBias.put(key, logitBiasItem);
return this;
}
/**
* Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. As an example, you can pass `{\"50256\": -100}` to prevent the <|endoftext|> token from being generated.
* @return logitBias
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_LOGIT_BIAS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Map getLogitBias() {
return logitBias;
}
@JsonProperty(JSON_PROPERTY_LOGIT_BIAS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setLogitBias(Map logitBias) {
this.logitBias = logitBias;
}
public CreateCompletionRequest logprobs(Integer logprobs) {
this.logprobs = logprobs;
return this;
}
/**
* Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. The maximum value for `logprobs` is 5.
* minimum: 0
* maximum: 5
* @return logprobs
*/
@jakarta.annotation.Nullable
@Min(0) @Max(5)
@JsonProperty(JSON_PROPERTY_LOGPROBS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Integer getLogprobs() {
return logprobs;
}
@JsonProperty(JSON_PROPERTY_LOGPROBS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setLogprobs(Integer logprobs) {
this.logprobs = logprobs;
}
public CreateCompletionRequest maxTokens(Integer maxTokens) {
this.maxTokens = maxTokens;
return this;
}
/**
* The maximum number of [tokens](/tokenizer) that can be generated in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.
* minimum: 0
* @return maxTokens
*/
@jakarta.annotation.Nullable
@Min(0)
@JsonProperty(JSON_PROPERTY_MAX_TOKENS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Integer getMaxTokens() {
return maxTokens;
}
@JsonProperty(JSON_PROPERTY_MAX_TOKENS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMaxTokens(Integer maxTokens) {
this.maxTokens = maxTokens;
}
public CreateCompletionRequest n(Integer n) {
this.n = n;
return this;
}
/**
* How many completions to generate for each prompt. **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.
* minimum: 1
* maximum: 128
* @return n
*/
@jakarta.annotation.Nullable
@Min(1) @Max(128)
@JsonProperty(JSON_PROPERTY_N)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Integer getN() {
return n;
}
@JsonProperty(JSON_PROPERTY_N)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setN(Integer n) {
this.n = n;
}
public CreateCompletionRequest presencePenalty(BigDecimal presencePenalty) {
this.presencePenalty = presencePenalty;
return this;
}
/**
* Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)
* minimum: -2
* maximum: 2
* @return presencePenalty
*/
@jakarta.annotation.Nullable
@Valid
@DecimalMin("-2") @DecimalMax("2")
@JsonProperty(JSON_PROPERTY_PRESENCE_PENALTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getPresencePenalty() {
return presencePenalty;
}
@JsonProperty(JSON_PROPERTY_PRESENCE_PENALTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setPresencePenalty(BigDecimal presencePenalty) {
this.presencePenalty = presencePenalty;
}
public CreateCompletionRequest seed(Integer seed) {
this.seed = seed;
return this;
}
/**
* If specified, our 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.
* @return seed
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SEED)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Integer getSeed() {
return seed;
}
@JsonProperty(JSON_PROPERTY_SEED)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSeed(Integer seed) {
this.seed = seed;
}
public CreateCompletionRequest stop(CreateCompletionRequestStop stop) {
this.stop = stop;
return this;
}
/**
* Get stop
* @return stop
*/
@jakarta.annotation.Nullable
@Valid
@JsonProperty(JSON_PROPERTY_STOP)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public CreateCompletionRequestStop getStop() {
return stop;
}
@JsonProperty(JSON_PROPERTY_STOP)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setStop(CreateCompletionRequestStop stop) {
this.stop = stop;
}
public CreateCompletionRequest stream(Boolean stream) {
this.stream = stream;
return this;
}
/**
* Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).
* @return stream
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_STREAM)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Boolean getStream() {
return stream;
}
@JsonProperty(JSON_PROPERTY_STREAM)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setStream(Boolean stream) {
this.stream = stream;
}
public CreateCompletionRequest streamOptions(ChatCompletionStreamOptions streamOptions) {
this.streamOptions = streamOptions;
return this;
}
/**
* Get streamOptions
* @return streamOptions
*/
@jakarta.annotation.Nullable
@Valid
@JsonProperty(JSON_PROPERTY_STREAM_OPTIONS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public ChatCompletionStreamOptions getStreamOptions() {
return streamOptions;
}
@JsonProperty(JSON_PROPERTY_STREAM_OPTIONS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setStreamOptions(ChatCompletionStreamOptions streamOptions) {
this.streamOptions = streamOptions;
}
public CreateCompletionRequest suffix(String suffix) {
this.suffix = suffix;
return this;
}
/**
* The suffix that comes after a completion of inserted text. This parameter is only supported for `gpt-3.5-turbo-instruct`.
* @return suffix
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SUFFIX)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getSuffix() {
return suffix;
}
@JsonProperty(JSON_PROPERTY_SUFFIX)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSuffix(String suffix) {
this.suffix = suffix;
}
public CreateCompletionRequest temperature(BigDecimal temperature) {
this.temperature = temperature;
return this;
}
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
* minimum: 0
* maximum: 2
* @return temperature
*/
@jakarta.annotation.Nullable
@Valid
@DecimalMin("0") @DecimalMax("2")
@JsonProperty(JSON_PROPERTY_TEMPERATURE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getTemperature() {
return temperature;
}
@JsonProperty(JSON_PROPERTY_TEMPERATURE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setTemperature(BigDecimal temperature) {
this.temperature = temperature;
}
public CreateCompletionRequest topP(BigDecimal topP) {
this.topP = topP;
return this;
}
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
* minimum: 0
* maximum: 1
* @return topP
*/
@jakarta.annotation.Nullable
@Valid
@DecimalMin("0") @DecimalMax("1")
@JsonProperty(JSON_PROPERTY_TOP_P)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getTopP() {
return topP;
}
@JsonProperty(JSON_PROPERTY_TOP_P)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setTopP(BigDecimal topP) {
this.topP = topP;
}
public CreateCompletionRequest user(String user) {
this.user = user;
return this;
}
/**
* A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
* @return user
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_USER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getUser() {
return user;
}
@JsonProperty(JSON_PROPERTY_USER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setUser(String user) {
this.user = user;
}
/**
* Return true if this CreateCompletionRequest object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CreateCompletionRequest createCompletionRequest = (CreateCompletionRequest) o;
return Objects.equals(this.model, createCompletionRequest.model) &&
Objects.equals(this.prompt, createCompletionRequest.prompt) &&
Objects.equals(this.bestOf, createCompletionRequest.bestOf) &&
Objects.equals(this.echo, createCompletionRequest.echo) &&
Objects.equals(this.frequencyPenalty, createCompletionRequest.frequencyPenalty) &&
Objects.equals(this.logitBias, createCompletionRequest.logitBias) &&
Objects.equals(this.logprobs, createCompletionRequest.logprobs) &&
Objects.equals(this.maxTokens, createCompletionRequest.maxTokens) &&
Objects.equals(this.n, createCompletionRequest.n) &&
Objects.equals(this.presencePenalty, createCompletionRequest.presencePenalty) &&
Objects.equals(this.seed, createCompletionRequest.seed) &&
Objects.equals(this.stop, createCompletionRequest.stop) &&
Objects.equals(this.stream, createCompletionRequest.stream) &&
Objects.equals(this.streamOptions, createCompletionRequest.streamOptions) &&
Objects.equals(this.suffix, createCompletionRequest.suffix) &&
Objects.equals(this.temperature, createCompletionRequest.temperature) &&
Objects.equals(this.topP, createCompletionRequest.topP) &&
Objects.equals(this.user, createCompletionRequest.user);
}
@Override
public int hashCode() {
return Objects.hash(model, prompt, bestOf, echo, frequencyPenalty, logitBias, logprobs, maxTokens, n, presencePenalty, seed, stop, stream, streamOptions, suffix, temperature, topP, user);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateCompletionRequest {\n");
sb.append(" model: ").append(toIndentedString(model)).append("\n");
sb.append(" prompt: ").append(toIndentedString(prompt)).append("\n");
sb.append(" bestOf: ").append(toIndentedString(bestOf)).append("\n");
sb.append(" echo: ").append(toIndentedString(echo)).append("\n");
sb.append(" frequencyPenalty: ").append(toIndentedString(frequencyPenalty)).append("\n");
sb.append(" logitBias: ").append(toIndentedString(logitBias)).append("\n");
sb.append(" logprobs: ").append(toIndentedString(logprobs)).append("\n");
sb.append(" maxTokens: ").append(toIndentedString(maxTokens)).append("\n");
sb.append(" n: ").append(toIndentedString(n)).append("\n");
sb.append(" presencePenalty: ").append(toIndentedString(presencePenalty)).append("\n");
sb.append(" seed: ").append(toIndentedString(seed)).append("\n");
sb.append(" stop: ").append(toIndentedString(stop)).append("\n");
sb.append(" stream: ").append(toIndentedString(stream)).append("\n");
sb.append(" streamOptions: ").append(toIndentedString(streamOptions)).append("\n");
sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n");
sb.append(" temperature: ").append(toIndentedString(temperature)).append("\n");
sb.append(" topP: ").append(toIndentedString(topP)).append("\n");
sb.append(" user: ").append(toIndentedString(user)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}