Fix double append of example dialogue names in group chats for Claude

This commit is contained in:
Cohee 2024-03-27 23:37:28 +02:00
parent 2468c1bc88
commit 06510f25bf

View File

@ -89,11 +89,16 @@ function convertClaudeMessages(messages, prefillString, useSysPrompt, humanMsgFi
if (messages[i].role !== 'system') {
break;
}
// Append example names if not already done by the frontend (e.g. for group chats).
if (userName && messages[i].name === 'example_user') {
messages[i].content = `${userName}: ${messages[i].content}`;
if (!messages[i].content.startsWith(`${userName}: `)) {
messages[i].content = `${userName}: ${messages[i].content}`;
}
}
if (charName && messages[i].name === 'example_assistant') {
messages[i].content = `${charName}: ${messages[i].content}`;
if (!messages[i].content.startsWith(`${charName}: `)) {
messages[i].content = `${charName}: ${messages[i].content}`;
}
}
systemPrompt += `${messages[i].content}\n\n`;
}