Set prefill before squashing messages
This commit is contained in:
parent
6ac8ef1b48
commit
94230c0891
|
@ -122,6 +122,14 @@ 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) {
|
||||
messages.push({
|
||||
role: 'assistant',
|
||||
content: prefillString.trimEnd(),
|
||||
});
|
||||
}
|
||||
|
||||
// Since the messaging endpoint only supports user assistant roles in turns, we have to merge messages with the same role if they follow eachother
|
||||
// Also handle multi-modality, holy slop.
|
||||
let mergedMessages = [];
|
||||
|
@ -172,14 +180,6 @@ 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) {
|
||||
mergedMessages.push({
|
||||
role: 'assistant',
|
||||
content: prefillString.trimEnd(),
|
||||
});
|
||||
}
|
||||
|
||||
return { messages: mergedMessages, systemPrompt: systemPrompt.trim() };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue