Is there a way to implement context window compacting/compressing? #8192
-
|
I am trying to find a way so that when the context window limit is about to be reached I would call an llm and the llm would create a compacted summary of the conversation and insert this to the system message, while truncating messages to the latest message. I am just confused as to where to insert this operation. are there any best practices for this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
If you use |
Beta Was this translation helpful? Give feedback.
-
|
This discussion was automatically locked because it has not been updated in over 30 days. If you still have questions about this topic, please ask us at community.vercel.com/ai-sdk |
Beta Was this translation helpful? Give feedback.
If you use
streamTextorgenerateText, then theprepareStepcallback might be the best place: https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text#prepare-step