Merge pull request #1397 from aisu-wata0/claude_system_order_fix
This commit is contained in:
commit
2c822f79f7
|
@ -18,14 +18,20 @@ function convertClaudePrompt(messages, addHumanPrefix, addAssistantPostfix, with
|
||||||
|
|
||||||
let systemPrompt = '';
|
let systemPrompt = '';
|
||||||
if (withSystemPrompt) {
|
if (withSystemPrompt) {
|
||||||
for (const message of messages) {
|
let lastSystemIdx = -1;
|
||||||
|
|
||||||
|
for (let i = 0; i < messages.length - 1; i++) {
|
||||||
|
const message = messages[i];
|
||||||
if (message.role === "system" && !message.name) {
|
if (message.role === "system" && !message.name) {
|
||||||
systemPrompt += message.content + '\n\n';
|
systemPrompt += message.content + '\n\n';
|
||||||
messages.splice(messages.indexOf(message), 1);
|
|
||||||
} else {
|
} else {
|
||||||
|
lastSystemIdx = i - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (lastSystemIdx >= 0) {
|
||||||
|
messages.splice(0, lastSystemIdx + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let requestPrompt = messages.map((v) => {
|
let requestPrompt = messages.map((v) => {
|
||||||
|
|
Loading…
Reference in New Issue