Record Class OpenAiApi.Usage
java.lang.Object
java.lang.Record
org.springframework.ai.openai.api.OpenAiApi.Usage
- Record Components:
completionTokens- Number of tokens in the generated completion. Only applicable for completion requests.promptTokens- Number of tokens in the prompt.totalTokens- Total number of tokens used in the request (prompt + completion).promptTokensDetails- Breakdown of tokens used in the prompt.completionTokenDetails- Breakdown of tokens used in a completion.
- Enclosing class:
- OpenAiApi
public static record OpenAiApi.Usage(Integer completionTokens, Integer promptTokens, Integer totalTokens, OpenAiApi.Usage.PromptTokensDetails promptTokensDetails, OpenAiApi.Usage.CompletionTokenDetails completionTokenDetails)
extends Record
Usage statistics for the completion request.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordBreakdown of tokens used in a completion.static final recordBreakdown of tokens used in the prompt -
Constructor Summary
ConstructorsConstructorDescriptionUsage(Integer completionTokens, Integer promptTokens, Integer totalTokens, OpenAiApi.Usage.PromptTokensDetails promptTokensDetails, OpenAiApi.Usage.CompletionTokenDetails completionTokenDetails) Creates an instance of aUsagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecompletionTokenDetailsrecord component.Returns the value of thecompletionTokensrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thepromptTokensrecord component.Returns the value of thepromptTokensDetailsrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thetotalTokensrecord component.
-
Constructor Details
-
Usage
-
Usage
public Usage(Integer completionTokens, Integer promptTokens, Integer totalTokens, OpenAiApi.Usage.PromptTokensDetails promptTokensDetails, OpenAiApi.Usage.CompletionTokenDetails completionTokenDetails) Creates an instance of aUsagerecord class.- Parameters:
completionTokens- the value for thecompletionTokensrecord componentpromptTokens- the value for thepromptTokensrecord componenttotalTokens- the value for thetotalTokensrecord componentpromptTokensDetails- the value for thepromptTokensDetailsrecord componentcompletionTokenDetails- the value for thecompletionTokenDetailsrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
completionTokens
Returns the value of thecompletionTokensrecord component.- Returns:
- the value of the
completionTokensrecord component
-
promptTokens
Returns the value of thepromptTokensrecord component.- Returns:
- the value of the
promptTokensrecord component
-
totalTokens
Returns the value of thetotalTokensrecord component.- Returns:
- the value of the
totalTokensrecord component
-
promptTokensDetails
Returns the value of thepromptTokensDetailsrecord component.- Returns:
- the value of the
promptTokensDetailsrecord component
-
completionTokenDetails
Returns the value of thecompletionTokenDetailsrecord component.- Returns:
- the value of the
completionTokenDetailsrecord component
-