fix: append continuation message after prefill

This commit is contained in:
Carsten Kragelund Jørgensen 2024-09-12 01:58:58 +02:00 committed by Carsten Kragelund
parent 14b48c5b34
commit 8401cc6032
1 changed files with 3 additions and 1 deletions

View File

@ -132,7 +132,9 @@ function convertClaudeMessages(messages, prefillString, useSysPrompt, humanMsgFi
});
// Shouldn't be conditional anymore, messages api expects the last role to be user unless we're explicitly prefilling
if (prefillString) {
if (messages[messages.length - 1].role == 'assistant' && prefillString) {
messages[messages.length - 1].content = prefillString.trimEnd() + messages[messages.length - 1].content;
} else if (prefillString) {
messages.push({
role: 'assistant',
content: prefillString.trimEnd(),