接口 TokenCountEstimator


public interface TokenCountEstimator
Represents an interface for estimating the count of tokens in various texts, text segments, etc. This can be useful when it's necessary to know in advance the cost of processing a specified text by the LLM.
  • 方法详细资料

    • estimateTokenCount

      int estimateTokenCount(String text)
      Estimates the count of tokens in the given text.
      参数:
      text - the text.
      返回:
      the estimated count of tokens.
    • estimateTokenCount

      default int estimateTokenCount(TextSegment textSegment)
      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.
    • estimateTokenCount

      default int estimateTokenCount(List<TextSegment> textSegments)
      Estimates the count of tokens in the given text segments.

      The metadata will not be included in the estimate.

      参数:
      textSegments - the text segments.
      返回:
      the estimated count of tokens.