From c014adde737733fedea4c757b144e18e29760914 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sat, 12 Jul 2025 13:27:08 -0400 Subject: [PATCH] fix intro generation getting cut off by being more generous with output tokens - reduce aggressive buffering that was leaving too little room for intro output - reserve up to 1000 tokens or 30% of model capacity for intro generation - increase minimum output tokens from 100 to 200 - should fix truncated intros especially on Groq models with 8K completion limits --- src/ui.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ui.js b/src/ui.js index 61eeabb..d73d22a 100644 --- a/src/ui.js +++ b/src/ui.js @@ -144,8 +144,11 @@ async function* sendMessageWithCustomHistory(messageHistory) { // Estimate input tokens for intro generation const inputText = messageHistory.map(msg => msg.content).join(''); const inputTokens = Math.ceil(inputText.length / 4); - const buffer = Math.max(2048, Math.floor(inputTokens * 1.5)); // Use 1.5x input tokens as buffer, minimum 2048 - const calculatedAvailable = Math.max(100, modelMaxTokens - inputTokens - buffer); + + // For intro generation, be more generous - we want complete intros + // Reserve a reasonable amount for output instead of aggressive buffering + const outputReserve = Math.min(1000, Math.floor(modelMaxTokens * 0.3)); // Reserve up to 1000 tokens or 30% for output + const calculatedAvailable = Math.max(200, modelMaxTokens - inputTokens - outputReserve); // Cap to model's max completion tokens limit const maxCompletionTokens = getSelectedModelMaxCompletionTokens();