Fix macro not being subbed in example separators for instruct

This commit is contained in:
Cohee 2024-04-09 11:24:16 +03:00
parent a10cff376b
commit 6d65d47f00
2 changed files with 5 additions and 5 deletions

View File

@ -372,7 +372,7 @@ export function formatInstructModeSystemPrompt(systemPrompt) {
* @returns {string[]} Formatted example messages string. * @returns {string[]} Formatted example messages string.
*/ */
export function formatInstructModeExamples(mesExamplesArray, name1, name2) { export function formatInstructModeExamples(mesExamplesArray, name1, name2) {
const blockHeading = power_user.context.example_separator ? power_user.context.example_separator + '\n' : ''; const blockHeading = power_user.context.example_separator ? `${substituteParams(power_user.context.example_separator)}\n` : '';
if (power_user.instruct.skip_examples) { if (power_user.instruct.skip_examples) {
return mesExamplesArray.map(x => x.replace(/<START>\n/i, blockHeading)); return mesExamplesArray.map(x => x.replace(/<START>\n/i, blockHeading));

View File

@ -431,15 +431,15 @@ function convertChatCompletionToInstruct(messages, type) {
const exampleMessages = messages.filter(x => x.role === 'system' && (x.name === 'example_user' || x.name === 'example_assistant')); const exampleMessages = messages.filter(x => x.role === 'system' && (x.name === 'example_user' || x.name === 'example_assistant'));
if (exampleMessages.length) { if (exampleMessages.length) {
examplesText = power_user.context.example_separator + '\n'; const blockHeading = power_user.context.example_separator ? (substituteParams(power_user.context.example_separator) + '\n') : '';
examplesText += exampleMessages.map(toString).join('\n'); const examplesArray = exampleMessages.map(m => '<START>\n' + toString(m));
examplesText = formatInstructModeExamples(examplesText, name1, name2); examplesText = blockHeading + formatInstructModeExamples(examplesArray, name1, name2).join('');
} }
const chatMessages = messages.slice(firstChatMessage); const chatMessages = messages.slice(firstChatMessage);
if (chatMessages.length) { if (chatMessages.length) {
chatMessagesText = power_user.context.chat_start + '\n'; chatMessagesText = substituteParams(power_user.context.chat_start) + '\n';
for (const message of chatMessages) { for (const message of chatMessages) {
const name = getPrefix(message); const name = getPrefix(message);