From 41e053c40d7be94969de8190934919a39008bd76 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 6 Mar 2024 21:40:51 +0200 Subject: [PATCH] Fix case if message content is a string --- src/endpoints/prompt-converters.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/endpoints/prompt-converters.js b/src/endpoints/prompt-converters.js index 2b22a3e0a..433d2127e 100644 --- a/src/endpoints/prompt-converters.js +++ b/src/endpoints/prompt-converters.js @@ -151,13 +151,10 @@ function convertClaudeMessages(messages, prefillString, useSysPrompt, humanMsgFi // Take care of name properties since claude messages don't support them mergedMessages.forEach((message) => { if (message.name) { - const content = Array.isArray(message.content) ? message.content : [message.content]; - for (let i = 0; i < content.length; i++) { - if (typeof content[i] === 'string') { - content[i] = `${message.name}: ${content[i]}`; - } else if (typeof content[i].text === 'string') { - content[i].text = `${message.name}: ${content[i].text}`; - } + if (Array.isArray(message.content)) { + message.content[0].text = `${message.name}: ${message.content[0].text}`; + } else { + message.content = `${message.name}: ${message.content}`; } delete message.name; }