warn users when maxTokens too close to contextLength

This commit is contained in:
Nate 2024-11-14 11:44:41 -08:00
parent f534820b66
commit b614c43f8d

View file

@ -34,6 +34,18 @@ export function validateConfig(config: SerializedContinueConfig) {
message: `Model at index ${index} has an invalid 'provider'.`,
});
}
if (model.contextLength && model.completionOptions?.maxTokens) {
const difference =
model.contextLength - model.completionOptions.maxTokens;
if (difference < 1000) {
errors.push({
fatal: false,
message: `Model "${model.title}" has a contextLength of ${model.contextLength} and a maxTokens of ${model.completionOptions.maxTokens}. This leaves only ${difference} tokens for input context and will likely result in your inputs being truncated.`,
});
}
}
});
}