Skip to content

Commit db522ee

Browse files
committed
fix(grzesiu): make it cheaper
1 parent e1652f7 commit db522ee

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/commands/grzesiu.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const openai = new OpenAIApi(configuration);
1111

1212
const MAX_TOKENS = 2049;
1313
const RESPONSE_TOKENS = 64;
14+
const MAX_GENERATED_CONTENT_LEN = Math.floor((MAX_TOKENS - RESPONSE_TOKENS) / 2); // make it cheaper
1415
const BANNED_PATTERNS = /[`\[\]{}\(\)]|http/g;
1516
const COOLDOWN = 20;
1617
const GRZESIU_DELAY = 1500;
@@ -87,7 +88,7 @@ const generateGrzesiuPrompt = async (username: string, question: string) => {
8788
const txt = uniqueLines.reduce((txt, line) => {
8889
const newTxt = txt + `${GRZESIU_NAME}: ` + line + '\n';
8990
const fullConvo = getFullConvo(newTxt, username, question);
90-
return fullConvo.length <= MAX_TOKENS - RESPONSE_TOKENS ? newTxt : txt;
91+
return fullConvo.length <= MAX_GENERATED_CONTENT_LEN ? newTxt : txt;
9192
}, '');
9293
return getFullConvo(txt, username, question);
9394
};

0 commit comments

Comments
 (0)