add limits related to current messages to config

This commit is contained in:
Wroclaw 2023-03-24 16:47:26 +01:00
parent 4f4b708ba5
commit 02730ff488
3 changed files with 13 additions and 3 deletions

View file

@ -89,7 +89,7 @@ export default function toOpenAIMessages(messages: Collection<string, DiscordMes
const content = formatMessage(message);
// FIXME: tokens are not being counted properly (it's lower than it is) but it's enough for me for now.
tokenCount += countTokens(content);
if (tokenCount > 2048) break;
if (tokenCount > config.limits.tokens) break;
rvalue.push({
role: message.author.id == message.client.user.id ? "assistant" : "user",
content: content,