Fix case if message content is a string
This commit is contained in:
parent
0ba6a562cb
commit
41e053c40d
|
@ -151,13 +151,10 @@ function convertClaudeMessages(messages, prefillString, useSysPrompt, humanMsgFi
|
||||||
// Take care of name properties since claude messages don't support them
|
// Take care of name properties since claude messages don't support them
|
||||||
mergedMessages.forEach((message) => {
|
mergedMessages.forEach((message) => {
|
||||||
if (message.name) {
|
if (message.name) {
|
||||||
const content = Array.isArray(message.content) ? message.content : [message.content];
|
if (Array.isArray(message.content)) {
|
||||||
for (let i = 0; i < content.length; i++) {
|
message.content[0].text = `${message.name}: ${message.content[0].text}`;
|
||||||
if (typeof content[i] === 'string') {
|
} else {
|
||||||
content[i] = `${message.name}: ${content[i]}`;
|
message.content = `${message.name}: ${message.content}`;
|
||||||
} else if (typeof content[i].text === 'string') {
|
|
||||||
content[i].text = `${message.name}: ${content[i].text}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
delete message.name;
|
delete message.name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue