Class TokenUsage
java.lang.Object
com.sap.ai.sdk.orchestration.model.TokenUsage
Usage of tokens in the response
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBuilder helper class.static interfaceBuilder helper class.static interfaceBuilder helper class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompletionTokens(Integer completionTokens) Set the completionTokens of thisTokenUsageinstance and return the same instance.completionTokensDetails(TokenUsageCompletionTokensDetails completionTokensDetails) Set the completionTokensDetails of thisTokenUsageinstance and return the same instance.static TokenUsage.Buildercreate()Create a type-safe, fluent-api builder object to construct a newTokenUsageinstance with all required arguments.booleanNumber of tokens in the generated completion.Get completionTokensDetailsgetCustomField(String name) Deprecated.Get the names of the unrecognizable properties of theTokenUsage.Number of tokens in the prompt.Get promptTokensDetailsTotal number of tokens used in the request (prompt + completion).inthashCode()promptTokens(Integer promptTokens) Set the promptTokens of thisTokenUsageinstance and return the same instance.promptTokensDetails(TokenUsagePromptTokensDetails promptTokensDetails) Set the promptTokensDetails of thisTokenUsageinstance and return the same instance.voidsetCompletionTokens(Integer completionTokens) Set the completionTokens of thisTokenUsageinstance.voidsetCompletionTokensDetails(TokenUsageCompletionTokensDetails completionTokensDetails) Set the completionTokensDetails of thisTokenUsageinstance.voidsetCustomField(String customFieldName, Object customFieldValue) Set an unrecognizable property of thisTokenUsageinstance.voidsetPromptTokens(Integer promptTokens) Set the promptTokens of thisTokenUsageinstance.voidsetPromptTokensDetails(TokenUsagePromptTokensDetails promptTokensDetails) Set the promptTokensDetails of thisTokenUsageinstance.voidsetTotalTokens(Integer totalTokens) Set the totalTokens of thisTokenUsageinstance.toMap()Get the value of all properties of thisTokenUsageinstance including unrecognized properties.toString()totalTokens(Integer totalTokens) Set the totalTokens of thisTokenUsageinstance and return the same instance.
-
Constructor Details
-
TokenUsage
protected TokenUsage()Default constructor for TokenUsage.
-
-
Method Details
-
completionTokens
Set the completionTokens of thisTokenUsageinstance and return the same instance.- Parameters:
completionTokens- Number of tokens in the generated completion.- Returns:
- The same instance of this
TokenUsageclass
-
getCompletionTokens
Number of tokens in the generated completion.- Returns:
- completionTokens The completionTokens of this
TokenUsageinstance.
-
setCompletionTokens
Set the completionTokens of thisTokenUsageinstance.- Parameters:
completionTokens- Number of tokens in the generated completion.
-
promptTokens
Set the promptTokens of thisTokenUsageinstance and return the same instance.- Parameters:
promptTokens- Number of tokens in the prompt.- Returns:
- The same instance of this
TokenUsageclass
-
getPromptTokens
Number of tokens in the prompt.- Returns:
- promptTokens The promptTokens of this
TokenUsageinstance.
-
setPromptTokens
Set the promptTokens of thisTokenUsageinstance.- Parameters:
promptTokens- Number of tokens in the prompt.
-
totalTokens
Set the totalTokens of thisTokenUsageinstance and return the same instance.- Parameters:
totalTokens- Total number of tokens used in the request (prompt + completion).- Returns:
- The same instance of this
TokenUsageclass
-
getTotalTokens
Total number of tokens used in the request (prompt + completion).- Returns:
- totalTokens The totalTokens of this
TokenUsageinstance.
-
setTotalTokens
Set the totalTokens of thisTokenUsageinstance.- Parameters:
totalTokens- Total number of tokens used in the request (prompt + completion).
-
promptTokensDetails
@Nonnull public TokenUsage promptTokensDetails(@Nullable TokenUsagePromptTokensDetails promptTokensDetails) Set the promptTokensDetails of thisTokenUsageinstance and return the same instance.- Parameters:
promptTokensDetails- The promptTokensDetails of thisTokenUsage- Returns:
- The same instance of this
TokenUsageclass
-
getPromptTokensDetails
Get promptTokensDetails- Returns:
- promptTokensDetails The promptTokensDetails of this
TokenUsageinstance.
-
setPromptTokensDetails
Set the promptTokensDetails of thisTokenUsageinstance.- Parameters:
promptTokensDetails- The promptTokensDetails of thisTokenUsage
-
completionTokensDetails
@Nonnull public TokenUsage completionTokensDetails(@Nullable TokenUsageCompletionTokensDetails completionTokensDetails) Set the completionTokensDetails of thisTokenUsageinstance and return the same instance.- Parameters:
completionTokensDetails- The completionTokensDetails of thisTokenUsage- Returns:
- The same instance of this
TokenUsageclass
-
getCompletionTokensDetails
Get completionTokensDetails- Returns:
- completionTokensDetails The completionTokensDetails of this
TokenUsageinstance.
-
setCompletionTokensDetails
public void setCompletionTokensDetails(@Nullable TokenUsageCompletionTokensDetails completionTokensDetails) Set the completionTokensDetails of thisTokenUsageinstance.- Parameters:
completionTokensDetails- The completionTokensDetails of thisTokenUsage
-
getCustomFieldNames
Get the names of the unrecognizable properties of theTokenUsage.- Returns:
- The set of properties names
-
getCustomField
@Nullable @Deprecated public Object getCustomField(@Nonnull String name) throws NoSuchElementException Deprecated.UsetoMap()instead.Get the value of an unrecognizable property of thisTokenUsageinstance.- Parameters:
name- The name of the property- Returns:
- The value of the property
- Throws:
NoSuchElementException- If no property with the given name could be found.
-
toMap
Get the value of all properties of thisTokenUsageinstance including unrecognized properties.- Returns:
- The map of all properties
-
setCustomField
Set an unrecognizable property of thisTokenUsageinstance. If the map previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
customFieldName- The name of the propertycustomFieldValue- The value of the property
-
equals
-
hashCode
public int hashCode() -
toString
-
create
Create a type-safe, fluent-api builder object to construct a newTokenUsageinstance with all required arguments.
-
toMap()instead.