Class LastMaxTokenSizeContentPurger
java.lang.Object
org.springframework.ai.chat.client.advisor.LastMaxTokenSizeContentPurger
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final org.springframework.ai.tokenizer.TokenCountEstimator -
Constructor Summary
ConstructorsConstructorDescriptionLastMaxTokenSizeContentPurger(org.springframework.ai.tokenizer.TokenCountEstimator tokenCountEstimator, int maxTokenSize) -
Method Summary
Modifier and TypeMethodDescriptionprotected intdoEstimateTokenCount(List<org.springframework.ai.content.MediaContent> datum) protected intdoEstimateTokenCount(org.springframework.ai.content.MediaContent datum) List<org.springframework.ai.content.Content>purgeExcess(List<org.springframework.ai.content.MediaContent> datum, int totalSize)
-
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
-
doEstimateTokenCount
protected int doEstimateTokenCount(org.springframework.ai.content.MediaContent datum) -
doEstimateTokenCount
-