feat(demo): cap chat input at 8000 chars (~2000 tokens)
This commit is contained in:
@@ -236,6 +236,14 @@ fn main() -> Void {
|
||||
if (!input || btn.disabled) return;
|
||||
var msg = input.value.trim();
|
||||
if (!msg) return;
|
||||
var MAX_CHARS = 8000;
|
||||
if (msg.length > MAX_CHARS) {
|
||||
if (input) {
|
||||
input.style.outline = '2px solid #e53e3e';
|
||||
setTimeout(function() { input.style.outline = ''; }, 2000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
input.value = '';
|
||||
btn.disabled = true;
|
||||
addMsg('user', msg);
|
||||
|
||||
Reference in New Issue
Block a user