remove artificial response caps - let models use their full completion token limits

This commit is contained in:
Russell Ballestrini 2025-07-12 13:32:56 -04:00
parent 471d61176d
commit 04fa0fb05f

View file

@ -110,15 +110,10 @@ export async function* sendMessage(message) {
// Cap to model's max completion tokens limit
const maxCompletionTokens = getSelectedModelMaxCompletionTokens();
// For chat, prefer using the full calculated available space for coherent responses
// Only cap if we're exceeding the model's hard limit
// Use the full calculated available space or the model's limit, whichever is smaller
const finalAvailable = Math.min(calculatedAvailable, maxCompletionTokens);
// However, for very large available token counts, cap at a reasonable max to prevent rambling
const reasonableMax = 4096; // Enough for very thorough responses without being excessive
const actualFinal = Math.min(finalAvailable, reasonableMax);
console.log("Chat using tokens:", actualFinal, "calculated:", calculatedAvailable, "max completion:", maxCompletionTokens);
console.log("Chat using tokens:", finalAvailable, "calculated:", calculatedAvailable, "max completion:", maxCompletionTokens);
const response = await fetch(apiUrl, {
method: "POST",
@ -127,7 +122,7 @@ export async function* sendMessage(message) {
model: model,
messages: chatHistory,
temperature: 0.5,
max_tokens: actualFinal,
max_tokens: finalAvailable,
stream: true,
}),
});