Class LastMaxTokenSizeContentPurger

java.lang.Object
org.springframework.ai.chat.client.advisor.LastMaxTokenSizeContentPurger

public class LastMaxTokenSizeContentPurger extends Object
Returns a new list of content (e.g list of messages of list of documents) that is a subset of the input list of contents and complies with the max token size constraint. The token estimator is used to estimate the token count of the datum.
Since:
1.0.0 M1
Author:
Christian Tzolov
  • Field Details

    • tokenCountEstimator

      protected final org.springframework.ai.tokenizer.TokenCountEstimator tokenCountEstimator
    • maxTokenSize

      protected final int maxTokenSize
  • Constructor Details

    • LastMaxTokenSizeContentPurger

      public LastMaxTokenSizeContentPurger(org.springframework.ai.tokenizer.TokenCountEstimator tokenCountEstimator, int maxTokenSize)
  • Method Details

    • purgeExcess

      public List<org.springframework.ai.content.Content> purgeExcess(List<org.springframework.ai.content.MediaContent> datum, int totalSize)
    • doEstimateTokenCount

      protected int doEstimateTokenCount(org.springframework.ai.content.MediaContent datum)
    • doEstimateTokenCount

      protected int doEstimateTokenCount(List<org.springframework.ai.content.MediaContent> datum)