Class DefaultUsage
java.lang.Object
org.springframework.ai.chat.metadata.DefaultUsage
- All Implemented Interfaces:
Usage
Default implementation of the
Usage
interface.- Since:
- 1.0.0
- Author:
- Mark Pollack
-
Constructor Summary
ConstructorDescriptionDefaultUsage
(Long promptTokens, Long generationTokens) Create a new DefaultUsage with promptTokens and generationTokens.DefaultUsage
(Long promptTokens, Long generationTokens, Long totalTokens) Create a new DefaultUsage with promptTokens, generationTokens, and totalTokens. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the number of tokens returned in the generation (aka completion) of the AI's response.Returns the number of tokens used in the prompt of the AI request.Return the total number of tokens from both the prompt of an AI request and generation of the AI's response.int
hashCode()
toString()
-
Constructor Details
-
DefaultUsage
Create a new DefaultUsage with promptTokens and generationTokens.- Parameters:
promptTokens
- the number of tokens in the prompt, ornull
if not availablegenerationTokens
- the number of tokens in the generation, ornull
if not available
-
DefaultUsage
Create a new DefaultUsage with promptTokens, generationTokens, and totalTokens.- Parameters:
promptTokens
- the number of tokens in the prompt, ornull
if not availablegenerationTokens
- the number of tokens in the generation, ornull
if not availabletotalTokens
- the total number of tokens, ornull
to calculate from promptTokens and generationTokens
-
-
Method Details
-
getPromptTokens
Description copied from interface:Usage
Returns the number of tokens used in the prompt of the AI request.- Specified by:
getPromptTokens
in interfaceUsage
- Returns:
- an
Long
with the number of tokens used in the prompt of the AI request. - See Also:
-
getGenerationTokens
Description copied from interface:Usage
Returns the number of tokens returned in the generation (aka completion) of the AI's response.- Specified by:
getGenerationTokens
in interfaceUsage
- Returns:
- an
Long
with the number of tokens returned in the generation (aka completion) of the AI's response. - See Also:
-
getTotalTokens
Description copied from interface:Usage
Return the total number of tokens from both the prompt of an AI request and generation of the AI's response.- Specified by:
getTotalTokens
in interfaceUsage
- Returns:
- the total number of tokens from both the prompt of an AI request and generation of the AI's response.
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-