How to impose token count limits on ChatHistory #12450
Unanswered
yuichiromukaiyama
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Looks like you are using Python based on your comment in the other post. Here is a sample on using the truncation history reducer with the You can set the reducer to auto reduce:
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was previously looking into the following issue. I don’t think the discussion has progressed much, but in Semantic Kernel, when the token count of ChatHistory increases, is there a best practice for trimming the conversation history—either by removing only the minimum necessary parts of the history or by cutting off the last user prompt—once it exceeds a certain token threshold?
#6155
I understand that there is a feature for summarizing ChatHistory. However, my understanding is that this function has to be called explicitly. For example, in an AI agent implementation where inference is run multiple times, you have to remember to call it every time. Rather than summarizing, I feel I would rather just delete excess tokens by trimming the conversation history or the last message content directly.
Currently, this is what I’m doing:
• I call the inference function wrapped in another function. Before inference, I manually count the tokens using tiktoken, and delete parts manually.
Beta Was this translation helpful? Give feedback.
All reactions