接口 TokenCountEstimator
public interface TokenCountEstimator
Represents an interface for estimating the count of tokens in various text types such as a text, prompt, text segment, etc.
This can be useful when it's necessary to know in advance the cost of processing a specified text by the LLM.
-
方法概要
修饰符和类型方法说明default intestimateTokenCount(TextSegment textSegment) Estimates the count of tokens in the given text segment.default intestimateTokenCount(Prompt prompt) Estimates the count of tokens in the given prompt.intestimateTokenCount(String text) Estimates the count of tokens in the given text.
-
方法详细资料
-
estimateTokenCount
Estimates the count of tokens in the given text.- 参数:
text- the text.- 返回:
- the estimated count of tokens.
-
estimateTokenCount
Estimates the count of tokens in the given prompt.- 参数:
prompt- the prompt.- 返回:
- the estimated count of tokens.
-
estimateTokenCount
Estimates the count of tokens in the given text segment.The metadata will not be included in the estimate.
- 参数:
textSegment- the text segment.- 返回:
- the estimated count of tokens.
-