From d114ebf6faa7056ff78f2189bf55a34ce17d699f Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:20:33 +0200 Subject: [PATCH] Add default role for Message class if not set. --- public/scripts/openai.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 77bd36d97..70c3fe304 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -1758,6 +1758,11 @@ class Message { this.role = role; this.content = content; + if (!this.role) { + console.log(`Message role not set, defaulting to 'system' for identifier '${this.identifier}'`); + this.role = 'system'; + } + if (typeof this.content === 'string' && this.content.length > 0) { this.tokens = tokenHandler.count({ role: this.role, content: this.content }); } else {