fix for openai token limit error (#350)

This commit is contained in:
Abror Aliboyev 2023-04-02 09:46:32 +05:00 committed by GitHub
parent 8f3a3ae3e7
commit 462ca9bb04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -35,7 +35,7 @@ const handler = async (req: Request): Promise<Response> => {
const message = messages[i]; const message = messages[i];
const tokens = encoding.encode(message.content); const tokens = encoding.encode(message.content);
if (tokenCount + tokens.length > model.tokenLimit) { if (tokenCount + tokens.length + 1000 > model.tokenLimit) {
break; break;
} }
tokenCount += tokens.length; tokenCount += tokens.length;