com.amazonaws.services.bedrockruntime.model.ConverseResult Maven / Gradle / Ivy
Show all versions of aws-java-sdk-bedrockruntime Show documentation
/*
* 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.bedrockruntime.model;
import java.io.Serializable;
import javax.annotation.Generated;
/**
*
* @see AWS API
* Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class ConverseResult extends com.amazonaws.AmazonWebServiceResult implements Serializable, Cloneable {
/**
*
* The result from the call to Converse
.
*
*/
private ConverseOutput output;
/**
*
* The reason why the model stopped generating output.
*
*/
private String stopReason;
/**
*
* The total number of tokens used in the call to Converse
. The total includes the tokens input to the
* model and the tokens generated by the model.
*
*/
private TokenUsage usage;
/**
*
* Metrics for the call to Converse
.
*
*/
private ConverseMetrics metrics;
/**
*
* A trace object that contains information about the Guardrail behavior.
*
*/
private ConverseTrace trace;
/**
*
* The result from the call to Converse
.
*
*
* @param output
* The result from the call to Converse
.
*/
public void setOutput(ConverseOutput output) {
this.output = output;
}
/**
*
* The result from the call to Converse
.
*
*
* @return The result from the call to Converse
.
*/
public ConverseOutput getOutput() {
return this.output;
}
/**
*
* The result from the call to Converse
.
*
*
* @param output
* The result from the call to Converse
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public ConverseResult withOutput(ConverseOutput output) {
setOutput(output);
return this;
}
/**
*
* The reason why the model stopped generating output.
*
*
* @param stopReason
* The reason why the model stopped generating output.
* @see StopReason
*/
public void setStopReason(String stopReason) {
this.stopReason = stopReason;
}
/**
*
* The reason why the model stopped generating output.
*
*
* @return The reason why the model stopped generating output.
* @see StopReason
*/
public String getStopReason() {
return this.stopReason;
}
/**
*
* The reason why the model stopped generating output.
*
*
* @param stopReason
* The reason why the model stopped generating output.
* @return Returns a reference to this object so that method calls can be chained together.
* @see StopReason
*/
public ConverseResult withStopReason(String stopReason) {
setStopReason(stopReason);
return this;
}
/**
*
* The reason why the model stopped generating output.
*
*
* @param stopReason
* The reason why the model stopped generating output.
* @return Returns a reference to this object so that method calls can be chained together.
* @see StopReason
*/
public ConverseResult withStopReason(StopReason stopReason) {
this.stopReason = stopReason.toString();
return this;
}
/**
*
* The total number of tokens used in the call to Converse
. The total includes the tokens input to the
* model and the tokens generated by the model.
*
*
* @param usage
* The total number of tokens used in the call to Converse
. The total includes the tokens input
* to the model and the tokens generated by the model.
*/
public void setUsage(TokenUsage usage) {
this.usage = usage;
}
/**
*
* The total number of tokens used in the call to Converse
. The total includes the tokens input to the
* model and the tokens generated by the model.
*
*
* @return The total number of tokens used in the call to Converse
. The total includes the tokens input
* to the model and the tokens generated by the model.
*/
public TokenUsage getUsage() {
return this.usage;
}
/**
*
* The total number of tokens used in the call to Converse
. The total includes the tokens input to the
* model and the tokens generated by the model.
*
*
* @param usage
* The total number of tokens used in the call to Converse
. The total includes the tokens input
* to the model and the tokens generated by the model.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public ConverseResult withUsage(TokenUsage usage) {
setUsage(usage);
return this;
}
/**
*
* Metrics for the call to Converse
.
*
*
* @param metrics
* Metrics for the call to Converse
.
*/
public void setMetrics(ConverseMetrics metrics) {
this.metrics = metrics;
}
/**
*
* Metrics for the call to Converse
.
*
*
* @return Metrics for the call to Converse
.
*/
public ConverseMetrics getMetrics() {
return this.metrics;
}
/**
*
* Metrics for the call to Converse
.
*
*
* @param metrics
* Metrics for the call to Converse
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public ConverseResult withMetrics(ConverseMetrics metrics) {
setMetrics(metrics);
return this;
}
/**
*
* A trace object that contains information about the Guardrail behavior.
*
*
* @param trace
* A trace object that contains information about the Guardrail behavior.
*/
public void setTrace(ConverseTrace trace) {
this.trace = trace;
}
/**
*
* A trace object that contains information about the Guardrail behavior.
*
*
* @return A trace object that contains information about the Guardrail behavior.
*/
public ConverseTrace getTrace() {
return this.trace;
}
/**
*
* A trace object that contains information about the Guardrail behavior.
*
*
* @param trace
* A trace object that contains information about the Guardrail behavior.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public ConverseResult withTrace(ConverseTrace trace) {
setTrace(trace);
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 (getOutput() != null)
sb.append("Output: ").append(getOutput()).append(",");
if (getStopReason() != null)
sb.append("StopReason: ").append(getStopReason()).append(",");
if (getUsage() != null)
sb.append("Usage: ").append(getUsage()).append(",");
if (getMetrics() != null)
sb.append("Metrics: ").append(getMetrics()).append(",");
if (getTrace() != null)
sb.append("Trace: ").append(getTrace());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof ConverseResult == false)
return false;
ConverseResult other = (ConverseResult) obj;
if (other.getOutput() == null ^ this.getOutput() == null)
return false;
if (other.getOutput() != null && other.getOutput().equals(this.getOutput()) == false)
return false;
if (other.getStopReason() == null ^ this.getStopReason() == null)
return false;
if (other.getStopReason() != null && other.getStopReason().equals(this.getStopReason()) == false)
return false;
if (other.getUsage() == null ^ this.getUsage() == null)
return false;
if (other.getUsage() != null && other.getUsage().equals(this.getUsage()) == false)
return false;
if (other.getMetrics() == null ^ this.getMetrics() == null)
return false;
if (other.getMetrics() != null && other.getMetrics().equals(this.getMetrics()) == false)
return false;
if (other.getTrace() == null ^ this.getTrace() == null)
return false;
if (other.getTrace() != null && other.getTrace().equals(this.getTrace()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getOutput() == null) ? 0 : getOutput().hashCode());
hashCode = prime * hashCode + ((getStopReason() == null) ? 0 : getStopReason().hashCode());
hashCode = prime * hashCode + ((getUsage() == null) ? 0 : getUsage().hashCode());
hashCode = prime * hashCode + ((getMetrics() == null) ? 0 : getMetrics().hashCode());
hashCode = prime * hashCode + ((getTrace() == null) ? 0 : getTrace().hashCode());
return hashCode;
}
@Override
public ConverseResult clone() {
try {
return (ConverseResult) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
}