From 67c8476cdf436618b844b2a09afe4a04b8577478 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:40:16 +0300 Subject: [PATCH] Set 0 tokens for prompts with no content --- public/scripts/openai.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index c02fb62b5..4a16b5458 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -1417,7 +1417,7 @@ class Message { this.role = role; this.content = content; - if (typeof this.content === 'string') { + if (typeof this.content === 'string' && this.content.length > 0) { this.tokens = tokenHandler.count({ role: this.role, content: this.content }); } else { this.tokens = 0;