mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Remove redundant checks for personality insertion and fix a stray space in OpenAI prompt
This commit is contained in:
		| @@ -1731,7 +1731,6 @@ async function Generate(type, automatic_trigger, force_name2) { | |||||||
|                 console.log('generating prompt'); |                 console.log('generating prompt'); | ||||||
|                 chatString = ""; |                 chatString = ""; | ||||||
|                 arrMes = arrMes.reverse(); |                 arrMes = arrMes.reverse(); | ||||||
|                 let is_add_personality = false; |  | ||||||
|                 arrMes.forEach(function (item, i, arr) {//For added anchors and others |                 arrMes.forEach(function (item, i, arr) {//For added anchors and others | ||||||
|  |  | ||||||
|                     if (i >= arrMes.length - 1 && $.trim(item).substr(0, (name1 + ":").length) != name1 + ":") { |                     if (i >= arrMes.length - 1 && $.trim(item).substr(0, (name1 + ":").length) != name1 + ":") { | ||||||
| @@ -1739,12 +1738,11 @@ async function Generate(type, automatic_trigger, force_name2) { | |||||||
|                             item = item.substr(0, item.length - 1); |                             item = item.substr(0, item.length - 1); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     if (i === arrMes.length - topAnchorDepth && count_view_mes >= topAnchorDepth && !is_add_personality) { |                     if (i === arrMes.length - topAnchorDepth && count_view_mes >= topAnchorDepth && !is_pygmalion) { | ||||||
|                         is_add_personality = true; |  | ||||||
|                         //chatString = chatString.substr(0,chatString.length-1); |                         //chatString = chatString.substr(0,chatString.length-1); | ||||||
|                         //anchorAndPersonality = "[Genre: roleplay chat][Tone: very long messages with descriptions]"; |                         //anchorAndPersonality = "[Genre: roleplay chat][Tone: very long messages with descriptions]"; | ||||||
|                         let personalityAndAnchor = [charPersonality, anchorTop].filter(x => x).join(' '); |                         let personalityAndAnchor = [charPersonality, anchorTop].filter(x => x).join(' '); | ||||||
|                         if (personalityAndAnchor && !is_pygmalion) { |                         if (personalityAndAnchor) { | ||||||
|                             item += "[" + personalityAndAnchor + ']\n'; |                             item += "[" + personalityAndAnchor + ']\n'; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|   | |||||||
| @@ -201,14 +201,12 @@ function setOpenAIMessageExamples(mesExamplesArray) { | |||||||
|  |  | ||||||
| function generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, anchorBottom) { | function generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, anchorBottom) { | ||||||
|     openai_msgs = openai_msgs.reverse(); |     openai_msgs = openai_msgs.reverse(); | ||||||
|     let is_add_personality = false; |  | ||||||
|     openai_msgs.forEach(function (msg, i, arr) {//For added anchors and others |     openai_msgs.forEach(function (msg, i, arr) {//For added anchors and others | ||||||
|         let item = msg["content"]; |         let item = msg["content"]; | ||||||
|         if (i === openai_msgs.length - topAnchorDepth && count_view_mes >= topAnchorDepth && !is_add_personality) { |         if (i === openai_msgs.length - topAnchorDepth && count_view_mes >= topAnchorDepth) { | ||||||
|             is_add_personality = true; |             let personalityAndAnchor = [charPersonality, anchorTop].filter(x => x).join(' '); | ||||||
|             if ((anchorTop != "" || charPersonality != "")) { |             if (personalityAndAnchor) { | ||||||
|                 if (anchorTop != "") charPersonality += ' '; |                 item = `[${name2} is ${personalityAndAnchor}]\n${item}`; | ||||||
|                 item = `[${name2} is ${charPersonality}${anchorTop}]\n${item}`; |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (i >= openai_msgs.length - 1 && count_view_mes > 8 && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":") {//For add anchor in end |         if (i >= openai_msgs.length - 1 && count_view_mes > 8 && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":") {//For add anchor in end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user