mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Export Chat Comps examples parser
This commit is contained in:
		| @@ -523,7 +523,7 @@ function setOpenAIMessageExamples(mesExamplesArray) { | ||||
|     for (let item of mesExamplesArray) { | ||||
|         // remove <START> {Example Dialogue:} and replace \r\n with just \n | ||||
|         let replaced = item.replace(/<START>/i, '{Example Dialogue:}').replace(/\r/gm, ''); | ||||
|         let parsed = parseExampleIntoIndividual(replaced); | ||||
|         let parsed = parseExampleIntoIndividual(replaced, true); | ||||
|         // add to the example message blocks array | ||||
|         examples.push(parsed); | ||||
|     } | ||||
| @@ -584,7 +584,13 @@ function setupChatCompletionPromptManager(openAiSettings) { | ||||
|     return promptManager; | ||||
| } | ||||
|  | ||||
| function parseExampleIntoIndividual(messageExampleString) { | ||||
| /** | ||||
|  * Parses the example messages into individual messages. | ||||
|  * @param {string} messageExampleString - The string containing the example messages | ||||
|  * @param {boolean} appendNamesForGroup - Whether to append the character name for group chats | ||||
|  * @returns {object[]} Array of message objects | ||||
|  */ | ||||
| export function parseExampleIntoIndividual(messageExampleString, appendNamesForGroup = true) { | ||||
|     let result = []; // array of msgs | ||||
|     let tmp = messageExampleString.split('\n'); | ||||
|     let cur_msg_lines = []; | ||||
| @@ -597,7 +603,7 @@ function parseExampleIntoIndividual(messageExampleString) { | ||||
|         // strip to remove extra spaces | ||||
|         let parsed_msg = cur_msg_lines.join('\n').replace(name + ':', '').trim(); | ||||
|  | ||||
|         if (selected_group && ['example_user', 'example_assistant'].includes(system_name)) { | ||||
|         if (appendNamesForGroup && selected_group && ['example_user', 'example_assistant'].includes(system_name)) { | ||||
|             parsed_msg = `${name}: ${parsed_msg}`; | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user