Fix Claude error in empty chats with no history
This commit is contained in:
parent
5d561b64e2
commit
c9c6d798d9
|
@ -101,7 +101,8 @@ function convertClaudeMessages(messages, prefillString, useSysPrompt, humanMsgFi
|
||||||
messages.splice(0, i);
|
messages.splice(0, i);
|
||||||
|
|
||||||
// Check if the first message in the array is of type user, if not, interject with humanMsgFix or a blank message.
|
// Check if the first message in the array is of type user, if not, interject with humanMsgFix or a blank message.
|
||||||
if (messages.length > 0 && messages[0].role !== 'user') {
|
// Also prevents erroring out if the messages array is empty.
|
||||||
|
if (messages.length === 0 || (messages.length > 0 && messages[0].role !== 'user')) {
|
||||||
messages.unshift({
|
messages.unshift({
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: humanMsgFix || '[Start a new chat]',
|
content: humanMsgFix || '[Start a new chat]',
|
||||||
|
|
Loading…
Reference in New Issue