mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Move Poe nudges to Generate anchors appendage
This commit is contained in:
		| @@ -945,7 +945,7 @@ | ||||
|                                         Influences bot behavior in its responses. | ||||
|                                     </div> | ||||
|                                     <div class="wide100p"> | ||||
|                                         <textarea id="poe_nudge_text" class="text_pole textarea_compact" rows="6" maxlength="250"></textarea> | ||||
|                                         <textarea id="poe_nudge_text" class="text_pole textarea_compact" rows="6" maxlength="2500"></textarea> | ||||
|                                     </div> | ||||
|                                 </div> | ||||
|                                 <div class="range-block"> | ||||
| @@ -959,7 +959,7 @@ | ||||
|                                         Prompt that is used for Impersonation function | ||||
|                                     </div> | ||||
|                                     <div class="wide100p"> | ||||
|                                         <textarea id="poe_impersonation_prompt" class="text_pole textarea_compact" rows="6" maxlength="250"></textarea> | ||||
|                                         <textarea id="poe_impersonation_prompt" class="text_pole textarea_compact" rows="6" maxlength="2500"></textarea> | ||||
|                                     </div> | ||||
|                                 </div> | ||||
|                             </div> | ||||
|   | ||||
| @@ -105,6 +105,7 @@ import { | ||||
|     generatePoe, | ||||
|     is_get_status_poe, | ||||
|     setPoeOnlineStatus, | ||||
|     appendPoeAnchors, | ||||
| } from "./scripts/poe.js"; | ||||
|  | ||||
| import { | ||||
| @@ -1901,11 +1902,17 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, | ||||
|         } | ||||
|  | ||||
|         // Extension added strings | ||||
|         const allAnchors = getAllExtensionPrompts(); | ||||
|         let allAnchors = getAllExtensionPrompts(); | ||||
|         const afterScenarioAnchor = getExtensionPrompt(extension_prompt_types.AFTER_SCENARIO); | ||||
|         let zeroDepthAnchor = getExtensionPrompt(extension_prompt_types.IN_CHAT, 0, ' '); | ||||
|         let { worldInfoString, worldInfoBefore, worldInfoAfter } = getWorldInfoPrompt(chat2); | ||||
|  | ||||
|         // Moved here to not overflow the Poe context with added prompt bits | ||||
|         if (main_api == 'poe') { | ||||
|             allAnchors = appendPoeAnchors(type, allAnchors); | ||||
|             zeroDepthAnchor = appendPoeAnchors(type, zeroDepthAnchor); | ||||
|         } | ||||
|  | ||||
|         // hack for regeneration of the first message | ||||
|         if (chat2.length == 0) { | ||||
|             chat2.push(''); | ||||
|   | ||||
| @@ -86,6 +86,23 @@ function onBotChange() { | ||||
|     saveSettingsDebounced(); | ||||
| } | ||||
|  | ||||
| export function appendPoeAnchors(type, prompt) { | ||||
|     const isImpersonate = type === 'impersonate'; | ||||
|     const isQuiet = type === 'quiet'; | ||||
|  | ||||
|     if (poe_settings.character_nudge && !isQuiet && !isImpersonate) { | ||||
|         let characterNudge = '\n' + substituteParams(poe_settings.character_nudge_message); | ||||
|         prompt += characterNudge; | ||||
|     } | ||||
|  | ||||
|     if (poe_settings.impersonation_prompt && isImpersonate) { | ||||
|         let impersonationNudge = '\n' + substituteParams(poe_settings.impersonation_prompt); | ||||
|         prompt += impersonationNudge; | ||||
|     } | ||||
|  | ||||
|     return prompt; | ||||
| } | ||||
|  | ||||
| async function generatePoe(type, finalPrompt, signal) { | ||||
|     if (poe_settings.auto_purge) { | ||||
|         let count_to_delete = -1; | ||||
| @@ -115,28 +132,7 @@ async function generatePoe(type, finalPrompt, signal) { | ||||
|         console.log('Could not jailbreak the bot'); | ||||
|     } | ||||
|  | ||||
|     const isImpersonate = type === 'impersonate'; | ||||
|     const isQuiet = type === 'quiet'; | ||||
|  | ||||
|     if (poe_settings.character_nudge && !isQuiet && !isImpersonate) { | ||||
|         let characterNudge = '\n' + substituteParams(poe_settings.character_nudge_message); | ||||
|         finalPrompt += characterNudge; | ||||
|     } | ||||
|  | ||||
|     if (poe_settings.impersonation_prompt && isImpersonate) { | ||||
|         let impersonationNudge = '\n' + substituteParams(poe_settings.impersonation_prompt); | ||||
|         finalPrompt += impersonationNudge; | ||||
|     } | ||||
|  | ||||
|     // If prompt overflows the max context, reduce it (or the generation would fail) | ||||
|     // Split by sentence boundary and remove sentence-by-sentence from the beginning | ||||
|     while (getTokenCount(finalPrompt) > max_context) { | ||||
|         const sentences = finalPrompt.split(/([.?!])\s+/); | ||||
|         const removed = sentences.shift(); | ||||
|         console.log(`Reducing Poe context due to overflow. Sentence dropped from prompt: "${removed}"`); | ||||
|         finalPrompt = sentences.join(''); | ||||
|     } | ||||
|  | ||||
|     const reply = await sendMessage(finalPrompt, !isQuiet, signal); | ||||
|     got_reply = true; | ||||
|     return reply; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user