fix(puterai): adapt message role for claude

This commit is contained in:
KernelDeimos 2024-08-21 23:50:09 -04:00
parent 3bface8c66
commit c08b897d4a

View File

@ -41,6 +41,7 @@ class ClaudeService extends BaseService {
if ( whatis(message.content) !== 'array' ) { if ( whatis(message.content) !== 'array' ) {
message.content = [message.content]; message.content = [message.content];
} }
if ( ! message.role ) message.role = 'user';
if ( message.role === 'user' && previous_was_user ) { if ( message.role === 'user' && previous_was_user ) {
const last_msg = adapted_messages[adapted_messages.length-1]; const last_msg = adapted_messages[adapted_messages.length-1];
last_msg.content.push( last_msg.content.push(