Update prompt-converters.js
This commit is contained in:
parent
1df9e628bd
commit
58227b82fc
|
@ -11,7 +11,6 @@
|
||||||
*/
|
*/
|
||||||
function convertClaudePrompt(messages, addAssistantPostfix, addAssistantPrefill, withSyspromptSupport, useSystemPrompt, addSysHumanMsg) {
|
function convertClaudePrompt(messages, addAssistantPostfix, addAssistantPrefill, withSyspromptSupport, useSystemPrompt, addSysHumanMsg) {
|
||||||
|
|
||||||
console.log(JSON.stringify(messages, null, 2));
|
|
||||||
//Prepare messages for claude.
|
//Prepare messages for claude.
|
||||||
if (messages.length > 0) {
|
if (messages.length > 0) {
|
||||||
messages[0].role = 'system';
|
messages[0].role = 'system';
|
||||||
|
@ -30,7 +29,7 @@ function convertClaudePrompt(messages, addAssistantPostfix, addAssistantPrefill,
|
||||||
}
|
}
|
||||||
return message.role === 'assistant' && i > 0;
|
return message.role === 'assistant' && i > 0;
|
||||||
});
|
});
|
||||||
// When 2.1 and 'Use system prompt" checked, switches to the system prompt format by setting the first message's role to the 'system'.
|
// When 2.1+ and 'Use system prompt" checked, switches to the system prompt format by setting the first message's role to the 'system'.
|
||||||
// Inserts the human's message before the first the assistant one, if there are no such message or prefix found.
|
// Inserts the human's message before the first the assistant one, if there are no such message or prefix found.
|
||||||
if (withSyspromptSupport && useSystemPrompt) {
|
if (withSyspromptSupport && useSystemPrompt) {
|
||||||
messages[0].role = 'system';
|
messages[0].role = 'system';
|
||||||
|
@ -50,9 +49,7 @@ function convertClaudePrompt(messages, addAssistantPostfix, addAssistantPrefill,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(JSON.stringify(messages, null, 2));
|
// Convert messages to the prompt.
|
||||||
|
|
||||||
// Convert messages to requestPrompt.
|
|
||||||
let requestPrompt = messages.map((v, i) => {
|
let requestPrompt = messages.map((v, i) => {
|
||||||
// Set prefix according to the role.
|
// Set prefix according to the role.
|
||||||
let prefix = {
|
let prefix = {
|
||||||
|
|
Loading…
Reference in New Issue