Add default role for Message class if not set.

This commit is contained in:
Cohee 2023-11-16 16:20:33 +02:00
parent e753246373
commit d114ebf6fa
1 changed files with 5 additions and 0 deletions

View File

@ -1758,6 +1758,11 @@ class Message {
this.role = role; this.role = role;
this.content = content; 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) { if (typeof this.content === 'string' && this.content.length > 0) {
this.tokens = tokenHandler.count({ role: this.role, content: this.content }); this.tokens = tokenHandler.count({ role: this.role, content: this.content });
} else { } else {