com.amazonaws.services.bedrockagent.model.PromptModelInferenceConfiguration Maven / Gradle / Ivy
/*
* Copyright 2019-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.bedrockagent.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
*
* Contains inference configurations related to model inference for a prompt. For more information, see Inference parameters.
*
*
* @see AWS API Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class PromptModelInferenceConfiguration implements Serializable, Cloneable, StructuredPojo {
/**
*
* The maximum number of tokens to return in the response.
*
*/
private Integer maxTokens;
/**
*
* A list of strings that define sequences after which the model will stop generating.
*
*/
private java.util.List stopSequences;
/**
*
* Controls the randomness of the response. Choose a lower value for more predictable outputs and a higher value for
* more surprising outputs.
*
*/
private Float temperature;
/**
*
* The number of most-likely candidates that the model considers for the next token during generation.
*
*/
private Integer topK;
/**
*
* The percentage of most-likely candidates that the model considers for the next token.
*
*/
private Float topP;
/**
*
* The maximum number of tokens to return in the response.
*
*
* @param maxTokens
* The maximum number of tokens to return in the response.
*/
public void setMaxTokens(Integer maxTokens) {
this.maxTokens = maxTokens;
}
/**
*
* The maximum number of tokens to return in the response.
*
*
* @return The maximum number of tokens to return in the response.
*/
public Integer getMaxTokens() {
return this.maxTokens;
}
/**
*
* The maximum number of tokens to return in the response.
*
*
* @param maxTokens
* The maximum number of tokens to return in the response.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public PromptModelInferenceConfiguration withMaxTokens(Integer maxTokens) {
setMaxTokens(maxTokens);
return this;
}
/**
*
* A list of strings that define sequences after which the model will stop generating.
*
*
* @return A list of strings that define sequences after which the model will stop generating.
*/
public java.util.List getStopSequences() {
return stopSequences;
}
/**
*
* A list of strings that define sequences after which the model will stop generating.
*
*
* @param stopSequences
* A list of strings that define sequences after which the model will stop generating.
*/
public void setStopSequences(java.util.Collection stopSequences) {
if (stopSequences == null) {
this.stopSequences = null;
return;
}
this.stopSequences = new java.util.ArrayList(stopSequences);
}
/**
*
* A list of strings that define sequences after which the model will stop generating.
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setStopSequences(java.util.Collection)} or {@link #withStopSequences(java.util.Collection)} if you want
* to override the existing values.
*
*
* @param stopSequences
* A list of strings that define sequences after which the model will stop generating.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public PromptModelInferenceConfiguration withStopSequences(String... stopSequences) {
if (this.stopSequences == null) {
setStopSequences(new java.util.ArrayList(stopSequences.length));
}
for (String ele : stopSequences) {
this.stopSequences.add(ele);
}
return this;
}
/**
*
* A list of strings that define sequences after which the model will stop generating.
*
*
* @param stopSequences
* A list of strings that define sequences after which the model will stop generating.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public PromptModelInferenceConfiguration withStopSequences(java.util.Collection stopSequences) {
setStopSequences(stopSequences);
return this;
}
/**
*
* Controls the randomness of the response. Choose a lower value for more predictable outputs and a higher value for
* more surprising outputs.
*
*
* @param temperature
* Controls the randomness of the response. Choose a lower value for more predictable outputs and a higher
* value for more surprising outputs.
*/
public void setTemperature(Float temperature) {
this.temperature = temperature;
}
/**
*
* Controls the randomness of the response. Choose a lower value for more predictable outputs and a higher value for
* more surprising outputs.
*
*
* @return Controls the randomness of the response. Choose a lower value for more predictable outputs and a higher
* value for more surprising outputs.
*/
public Float getTemperature() {
return this.temperature;
}
/**
*
* Controls the randomness of the response. Choose a lower value for more predictable outputs and a higher value for
* more surprising outputs.
*
*
* @param temperature
* Controls the randomness of the response. Choose a lower value for more predictable outputs and a higher
* value for more surprising outputs.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public PromptModelInferenceConfiguration withTemperature(Float temperature) {
setTemperature(temperature);
return this;
}
/**
*
* The number of most-likely candidates that the model considers for the next token during generation.
*
*
* @param topK
* The number of most-likely candidates that the model considers for the next token during generation.
*/
public void setTopK(Integer topK) {
this.topK = topK;
}
/**
*
* The number of most-likely candidates that the model considers for the next token during generation.
*
*
* @return The number of most-likely candidates that the model considers for the next token during generation.
*/
public Integer getTopK() {
return this.topK;
}
/**
*
* The number of most-likely candidates that the model considers for the next token during generation.
*
*
* @param topK
* The number of most-likely candidates that the model considers for the next token during generation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public PromptModelInferenceConfiguration withTopK(Integer topK) {
setTopK(topK);
return this;
}
/**
*
* The percentage of most-likely candidates that the model considers for the next token.
*
*
* @param topP
* The percentage of most-likely candidates that the model considers for the next token.
*/
public void setTopP(Float topP) {
this.topP = topP;
}
/**
*
* The percentage of most-likely candidates that the model considers for the next token.
*
*
* @return The percentage of most-likely candidates that the model considers for the next token.
*/
public Float getTopP() {
return this.topP;
}
/**
*
* The percentage of most-likely candidates that the model considers for the next token.
*
*
* @param topP
* The percentage of most-likely candidates that the model considers for the next token.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public PromptModelInferenceConfiguration withTopP(Float topP) {
setTopP(topP);
return this;
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getMaxTokens() != null)
sb.append("MaxTokens: ").append(getMaxTokens()).append(",");
if (getStopSequences() != null)
sb.append("StopSequences: ").append(getStopSequences()).append(",");
if (getTemperature() != null)
sb.append("Temperature: ").append(getTemperature()).append(",");
if (getTopK() != null)
sb.append("TopK: ").append(getTopK()).append(",");
if (getTopP() != null)
sb.append("TopP: ").append(getTopP());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof PromptModelInferenceConfiguration == false)
return false;
PromptModelInferenceConfiguration other = (PromptModelInferenceConfiguration) obj;
if (other.getMaxTokens() == null ^ this.getMaxTokens() == null)
return false;
if (other.getMaxTokens() != null && other.getMaxTokens().equals(this.getMaxTokens()) == false)
return false;
if (other.getStopSequences() == null ^ this.getStopSequences() == null)
return false;
if (other.getStopSequences() != null && other.getStopSequences().equals(this.getStopSequences()) == false)
return false;
if (other.getTemperature() == null ^ this.getTemperature() == null)
return false;
if (other.getTemperature() != null && other.getTemperature().equals(this.getTemperature()) == false)
return false;
if (other.getTopK() == null ^ this.getTopK() == null)
return false;
if (other.getTopK() != null && other.getTopK().equals(this.getTopK()) == false)
return false;
if (other.getTopP() == null ^ this.getTopP() == null)
return false;
if (other.getTopP() != null && other.getTopP().equals(this.getTopP()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getMaxTokens() == null) ? 0 : getMaxTokens().hashCode());
hashCode = prime * hashCode + ((getStopSequences() == null) ? 0 : getStopSequences().hashCode());
hashCode = prime * hashCode + ((getTemperature() == null) ? 0 : getTemperature().hashCode());
hashCode = prime * hashCode + ((getTopK() == null) ? 0 : getTopK().hashCode());
hashCode = prime * hashCode + ((getTopP() == null) ? 0 : getTopP().hashCode());
return hashCode;
}
@Override
public PromptModelInferenceConfiguration clone() {
try {
return (PromptModelInferenceConfiguration) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.bedrockagent.model.transform.PromptModelInferenceConfigurationMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}