Package org.springframework.ai.tokenizer
Class JTokkitTokenCountEstimator
java.lang.Object
org.springframework.ai.tokenizer.JTokkitTokenCountEstimator
- All Implemented Interfaces:
TokenCountEstimator
Estimates the number of tokens in a given text or message using the JTokkit encoding
library.
- Since:
- 1.0.0
- Author:
- Christian Tzolov, Soby Chacko
-
Constructor Summary
ConstructorDescriptionJTokkitTokenCountEstimator
(com.knuddels.jtokkit.api.EncodingType tokenEncodingType) -
Method Summary
Modifier and TypeMethodDescriptionint
estimate
(Iterable<MediaContent> contents) Estimates the number of tokens in the given messages.int
Estimates the number of tokens in the given text.int
estimate
(MediaContent content) Estimates the number of tokens in the given message.
-
Constructor Details
-
JTokkitTokenCountEstimator
public JTokkitTokenCountEstimator() -
JTokkitTokenCountEstimator
public JTokkitTokenCountEstimator(com.knuddels.jtokkit.api.EncodingType tokenEncodingType)
-
-
Method Details
-
estimate
Description copied from interface:TokenCountEstimator
Estimates the number of tokens in the given text.- Specified by:
estimate
in interfaceTokenCountEstimator
- Parameters:
text
- the text to estimate the number of tokens for.- Returns:
- the estimated number of tokens.
-
estimate
Description copied from interface:TokenCountEstimator
Estimates the number of tokens in the given message.- Specified by:
estimate
in interfaceTokenCountEstimator
- Parameters:
content
- the content (Message or Document) to estimate the number of tokens for.- Returns:
- the estimated number of tokens.
-
estimate
Description copied from interface:TokenCountEstimator
Estimates the number of tokens in the given messages.- Specified by:
estimate
in interfaceTokenCountEstimator
- Parameters:
contents
- the messages to estimate the number of tokens for.- Returns:
- the estimated number of tokens.
-