Ambiente de programação com IA
Divisão de mensagens de bot
Divida o texto do bot no limite configurado de UTF-16 sem separar pares substitutos.
● ● ●BotEnvelope●
Fluxos de trabalho · Divisão de mensagens de bot ×
if (!Number.isInteger(start) || start < 0 || start > text.length) {
throw new Error("start.invalid");
}
if (!Number.isInteger(limit) || limit < 1) throw new Error("limit.invalid");
if (start === text.length) return "";
let end = Math.min(start + limit, text.length);
const last = text.charCodeAt(end - 1);
if (end < text.length && last >= 0xD800 && last <= 0xDBFF) end--;
if (end === start) throw new Error("limit.too_small");
return text.slice(start, end);✳Divida o texto do bot no limite configurado de UTF-16 sem separar pares substitutos.
✓ AlteraçõesRevise antes de aplicar ↗
Ilustração do ambiente
Projeto
Confira um emoji na borda, uma mensagem vazia e blocos de código, preservando o texto ao juntar os trechos.
Revise antes de aplicar
Compare o comportamento real com o resultado esperado. Se uma verificação falhar, investigue a causa antes de fazer outras alterações.
Modelos
Configure um endpoint compatível com OpenAI ou Anthropic com a URL base e uma chave API, quando necessária. Teste a conexão. O servidor local precisa estar em execução; ferramentas remotas podem transmitir dados separadamente.
Fluxos de trabalho
if (!Number.isInteger(start) || start < 0 || start > text.length) {
throw new Error("start.invalid");
}
if (!Number.isInteger(limit) || limit < 1) throw new Error("limit.invalid");
if (start === text.length) return "";
let end = Math.min(start + limit, text.length);
const last = text.charCodeAt(end - 1);
if (end < text.length && last >= 0xD800 && last <= 0xDBFF) end--;
if (end === start) throw new Error("limit.too_small");
return text.slice(start, end);