Update max allowed size

This commit is contained in:
Saoud Rizwan
2024-08-30 23:57:05 -04:00
parent 88e4217878
commit 172aaa524b

View File

@@ -1318,7 +1318,7 @@ ${this.customInstructions.trim()}
)
const totalTokens = (tokensIn || 0) + (tokensOut || 0) + (cacheWrites || 0) + (cacheReads || 0)
const contextWindow = this.api.getModel().info.contextWindow
const maxAllowedSize = Math.max(contextWindow - 20_000, contextWindow * 0.8)
const maxAllowedSize = Math.max(contextWindow - 40_000, contextWindow * 0.8)
if (totalTokens >= maxAllowedSize) {
const truncatedMessages = truncateHalfConversation(this.apiConversationHistory)
await this.overwriteApiConversationHistory(truncatedMessages)