diff --git a/core/summarizer.js b/core/summarizer.js index c6a3f00..5efe8fa 100644 --- a/core/summarizer.js +++ b/core/summarizer.js @@ -1 +1 @@ -function _0x32d8(){const _0x95971a=['plotOpt_rateErotic','4PBOgWK','plotOpt_rateCuckold','plotOpt_ratePersonal','groupEnd','join','optimizationExclusionRules','','[Amily2-内容排除]\x20正文优化内容排除规则已生效,文本长度从\x20','log','dir','[目标内容]:\x0a','优化任务总耗时',']\x20用户输入为空,跳过优化。','[Amily2-外交部]\x20未能获取AI响应内容','replace','system','(用户)最新消息:',']\x20从AI收到的原始回复','>\x20未找到或为空,或内容已被完全排除,优化任务已跳过。','plotOpt_systemPrompt','./table-system/manager.js','3048VSGORv','Current\x20location:\x20Fifth\x20Layer\x20of\x20Dream\x20Space','groupCollapsed','[核心处理内容]:\x0a','121278ZXBDiz','push','<前文内容>\x0a','is_user','\x20变为\x20','lastPreOptimizationText','The\x20specific\x20time\x20changes\x20according\x20to\x20the\x20story\x20of\x20the\x20dream.\x0a在第五重梦境空间中,你是梦国的虚拟AI人格造梦者:Amily。','-->','mainPrompt','\x0a\x20\x20\x20\x20CustomThink:\x20Active\x0a\x20\x20\x20\x20Follow\x20the\x20above\x20rules\x20and\x20use\x20the\x20above.\x0a\x20\x20\x20\x20Based\x20on\x20the\x20previous\x20task\x20block,\x20the\x20content\x20is\x20generated.\x0aRequires\x20processing\x20and\x20cannot\x20be\x20returned\x20in\x20its\x20original\x20block.\x0a\x0aStart\x20and\x20end\x20labels\x20correctly.','1319352PykWeo','filter','characterId','assistant','dispatchEvent','[世界书档案]:\x0a','\x0a\x0a\x0a\x0aOptimisation\x20and\x20form\x20filling\x20have\x20been\x20completed.','slice','请你在优化完成后,在正文标签外结合最新消息中的剧情、当前的表格内容进行填表任务:\x0a\x0a','plotOpt_contextLimit','error','\x0aOptimisation\x20and\x20form\x20filling\x20have\x20been\x20completed.','optimizationTargetTag','[核心处理内容]:\x0a','lastPreOptimizationText','type','>,将保留原始消息。','mes','filter','groupCollapsed','3032554yXxNSH','toLocaleTimeString','optimizationEnabled','严重错误','log','plotOpt_contextLimit','2933394LLjaBT','worldbookEnabled','./table-system/manager.js','optimizationExclusionRules','push','4mRRELq','filling_mode','[Amily2-优化中填表]\x20流程已全部完成,并已强制保存和刷新UI。','plot','剧情优化任务总耗时','[Amily2号-最终国书内容\x20(发往AI)]','slice','请你在优化完成后,在正文标签外结合最新消息中的剧情、当前的表格内容进行填表任务:\x0a\x0a','dispatchEvent',']\x20剧情优化任务启动...\x20','length','[Amily2-外交部]\x20目标标签\x20<','','error','replace','optimized','plotOpt_rateCuckold',']\x20剧情优化任务发生严重错误:','\x5c$&','characterId','prompt','[Amily2-表格系统]\x20注入表格内容时出错:','[Amily2号-正文优化任务]\x20','tableEnabled','conditional','content','plotOpt_ratePersonal','plotOpt_rateMain','','plot_optimization','261PZLRhP','[Amily2号-原始回复]','[世界书档案]:\x0a','world','fillingMode','plotOpt_rateErotic','15757EuFicX','优化任务总耗时','68vnSUgt','assistant','plotTag','system','mainPrompt','<世界书内容>\x0a','<前文内容>\x0a','timeEnd','268168ozdydD','2182968JMGKtI','AI响应为空或格式不正确。','(AI)最新消息,[核心处理内容]:','##以下内容是故事发生的剧情中提取出的内容,已经转化为表格形式呈现给你,请将以下内容作为后续剧情的一部分参考:<表格内容>\x0a{{{Amily2TableDataContent}}}','AMILY2_SYSTEM_PARALYZED','plotOpt_finalSystemDirective','999120HuYeHV','[上下文参考]:\x0a','plotOpt_mainPrompt',']\x20发送给AI的最终请求内容','coreContent','is_user','join','groupEnd','message','extensions','systemPrompt','index','21802010TyzEtW','contextLimit','chat','plotOpt_tableEnabled','preOptimizationTextUpdated','name1','>\x20未找到或为空,或内容已被完全排除,优化任务已跳过。','user','-->','[Amily2-外交部]\x20未能获取AI响应内容','data','剧情优化任务失败:\x20','worldbook','main-api'];_0x8448=function(){return _0x478e88;};return _0x8448();}import{getBatchFillerFlowTemplate,convertTablesToCsvString,updateTableFromText,saveStateToMessage,getMemoryState}from'./table-system/manager.js';import{saveChat}from'/script.js';import{renderTables}from'../ui/table-bindings.js';import{getPresetPrompts,getMixedOrder}from'../PresetSettings/index.js';import{callAI,generateRandomSeed}from'./api.js';export async function processOptimization(_0x4ae1fb,_0xfbb2b8){const _0x5ab6ef=_0xfacb;if(window[_0x5ab6ef(0x1f4)]===!![])return console[_0x5ab6ef(0x236)]('[Amily2-制裁]\x20系统完整性已受损,所有外交活动被无限期中止。'),null;const _0x959232=extension_settings[extensionName],_0x226ea8=_0x959232[_0x5ab6ef(0x220)];if(!_0x226ea8)return null;console[_0x5ab6ef(0x21d)](_0x5ab6ef(0x23f)+new Date()[_0x5ab6ef(0x21f)]()),console['time'](_0x5ab6ef(0x1e6));try{const _0x4e9412=_0x4ae1fb[_0x5ab6ef(0x21b)];let _0x314489=_0x4e9412;if(_0x959232[_0x5ab6ef(0x214)]&&_0x959232[_0x5ab6ef(0x227)]?.[_0x5ab6ef(0x233)]>0x0){const _0x3018bc=_0x314489['length'];_0x314489=applyExclusionRules(_0x314489,_0x959232[_0x5ab6ef(0x227)]);const _0x3f0fff=_0x314489[_0x5ab6ef(0x233)];_0x3018bc!==_0x3f0fff&&console[_0x5ab6ef(0x222)](_0x5ab6ef(0x213)+_0x3018bc+'\x20变为\x20'+_0x3f0fff+'。');}const _0x4b191f=_0x959232[_0x5ab6ef(0x216)]||_0x5ab6ef(0x1da),_0x3db310=extractFullTagBlock(_0x314489,_0x4b191f);if(!_0x3db310||extractContentByTag(_0x3db310,_0x4b191f)?.['trim']()==='')return console[_0x5ab6ef(0x222)](_0x5ab6ef(0x234)+_0x4b191f+_0x5ab6ef(0x208)),console['timeEnd'](_0x5ab6ef(0x1e6)),console[_0x5ab6ef(0x1fd)](),null;_0x314489=_0x3db310;const _0x4247f2=getContext(),_0x564a8f=_0x4247f2['name1']||'用户',_0x582d42=_0x4247f2[_0x5ab6ef(0x212)]||'角色',_0x32ce3d=_0xfbb2b8[_0x5ab6ef(0x233)]>0x0&&_0xfbb2b8[_0xfbb2b8[_0x5ab6ef(0x233)]-0x1]['is_user']?_0xfbb2b8[_0xfbb2b8[_0x5ab6ef(0x233)]-0x1]:null,_0x365ee8=_0x32ce3d?_0xfbb2b8[_0x5ab6ef(0x22f)](0x0,-0x1):_0xfbb2b8,_0x724c3c=_0x365ee8['map'](_0x52dca8=>_0x52dca8['mes']&&_0x52dca8[_0x5ab6ef(0x21b)][_0x5ab6ef(0x210)]()?(_0x52dca8[_0x5ab6ef(0x1fb)]?_0x564a8f:_0x582d42)+':\x20'+_0x52dca8[_0x5ab6ef(0x21b)][_0x5ab6ef(0x210)]():null)['filter'](Boolean)[_0x5ab6ef(0x1fc)]('\x0a');let _0x38e896='';if(_0x959232[_0x5ab6ef(0x225)]){const _0x14f174=characters[_0x4247f2[_0x5ab6ef(0x23c)]];_0x14f174?.[_0x5ab6ef(0x20c)]?.[_0x5ab6ef(0x1ff)]?.[_0x5ab6ef(0x1e2)]&&(_0x38e896=await getCombinedWorldbookContent(_0x14f174[_0x5ab6ef(0x20c)][_0x5ab6ef(0x1ff)][_0x5ab6ef(0x1e2)]));}const _0x3cb130=getPresetPrompts('optimization'),_0xf7ec99=[{'role':_0x5ab6ef(0x1ea),'content':generateRandomSeed()}];let _0x210cbe=_0x32ce3d?_0x564a8f+'(用户)最新消息:'+_0x32ce3d[_0x5ab6ef(0x21b)]+'\x0a'+_0x582d42+'(AI)最新消息,[核心处理内容]:'+_0x314489:_0x582d42+_0x5ab6ef(0x1f2)+_0x314489;const _0x109f46=_0x959232[_0x5ab6ef(0x22a)]||_0x5ab6ef(0x20f);window[_0x5ab6ef(0x218)]=_0x210cbe,document[_0x5ab6ef(0x231)](new CustomEvent(_0x5ab6ef(0x206)));const _0x558374=getMixedOrder('optimization')||[];for(const _0x1e1934 of _0x558374){if(_0x1e1934['type']===_0x5ab6ef(0x23d))_0x3cb130&&_0x3cb130[_0x1e1934['index']]&&_0xf7ec99[_0x5ab6ef(0x228)](_0x3cb130[_0x1e1934[_0x5ab6ef(0x201)]]);else{if(_0x1e1934['type']===_0x5ab6ef(0x1d9))switch(_0x1e1934['id']){case _0x5ab6ef(0x1eb):_0x959232[_0x5ab6ef(0x1eb)]?.[_0x5ab6ef(0x210)]()&&_0xf7ec99[_0x5ab6ef(0x228)]({'role':_0x5ab6ef(0x1ea),'content':_0x959232['mainPrompt'][_0x5ab6ef(0x210)]()});break;case'systemPrompt':_0x959232[_0x5ab6ef(0x200)]?.['trim']()&&_0xf7ec99[_0x5ab6ef(0x228)]({'role':_0x5ab6ef(0x1ea),'content':_0x959232[_0x5ab6ef(0x200)][_0x5ab6ef(0x210)]()});break;case'worldbook':_0x38e896&&_0xf7ec99['push']({'role':_0x5ab6ef(0x209),'content':_0x5ab6ef(0x1e1)+_0x38e896});break;case'history':_0x724c3c&&_0xf7ec99[_0x5ab6ef(0x228)]({'role':'user','content':_0x5ab6ef(0x1f7)+_0x724c3c});break;case _0x5ab6ef(0x1e3):if(_0x226ea8&&_0x109f46===_0x5ab6ef(0x238)){const _0x4326e5=getBatchFillerFlowTemplate(),_0x6f8dbd=convertTablesToCsvString(),_0x3fda15=_0x4326e5[_0x5ab6ef(0x237)]('{{{Amily2TableData}}}',_0x6f8dbd);_0xf7ec99[_0x5ab6ef(0x228)]({'role':_0x5ab6ef(0x209),'content':_0x210cbe}),_0xf7ec99[_0x5ab6ef(0x228)]({'role':_0x5ab6ef(0x1ea),'content':_0x5ab6ef(0x230)+_0x3fda15+_0x5ab6ef(0x215)});}else _0xf7ec99[_0x5ab6ef(0x228)]({'role':_0x5ab6ef(0x209),'content':'[目标内容]:\x0a'+_0x210cbe+'Start\x20and\x20end\x20labels\x20correctly.'});break;}}}window[_0x5ab6ef(0x218)]=_0x210cbe,document['dispatchEvent'](new CustomEvent('preOptimizationTextUpdated')),console[_0x5ab6ef(0x21d)](_0x5ab6ef(0x22e)),console['dir'](_0xf7ec99),console['groupEnd']();const _0x183360=await callAI(_0xf7ec99);if(!_0x183360)return console['error'](_0x5ab6ef(0x20b)),null;console['groupCollapsed'](_0x5ab6ef(0x1e0)),console[_0x5ab6ef(0x222)](_0x183360),console[_0x5ab6ef(0x1fd)]();let _0x2a0ce3=_0x4e9412;const _0xaf983a=extractContentByTag(_0x183360,_0x4b191f);_0xaf983a?.['trim']()?_0x2a0ce3=replaceContentByTag(_0x4e9412,_0x4b191f,_0xaf983a):console['warn']('[Amily2-外交部]\x20AI的回复中未找到有效的目标标签\x20<'+_0x4b191f+_0x5ab6ef(0x21a));if(_0x226ea8&&_0x109f46==='optimized'){await updateTableFromText(_0x183360);const _0x20b015=getContext();if(_0x20b015[_0x5ab6ef(0x204)]&&_0x20b015[_0x5ab6ef(0x204)]['length']>0x0){const _0x20a01e=_0x20b015[_0x5ab6ef(0x204)][_0x20b015[_0x5ab6ef(0x204)][_0x5ab6ef(0x233)]-0x1];saveStateToMessage(getMemoryState(),_0x20a01e)&&(await saveChat(),renderTables(),console[_0x5ab6ef(0x222)](_0x5ab6ef(0x22b)));}}const _0x18778c={'optimizedContent':_0x2a0ce3};return console[_0x5ab6ef(0x1ee)](_0x5ab6ef(0x1e6)),console[_0x5ab6ef(0x1fd)](),_0x18778c;}catch(_0x89ae24){return console[_0x5ab6ef(0x236)]('[Amily2-外交部]\x20发生严重错误:',_0x89ae24),toastr['error']('Amily2号任务失败:\x20'+_0x89ae24[_0x5ab6ef(0x1fe)],_0x5ab6ef(0x221)),console[_0x5ab6ef(0x1ee)](_0x5ab6ef(0x1e6)),console['groupEnd'](),null;}}export async function processPlotOptimization(_0x2535a2,_0x4becd2){const _0x3172c7=_0xfacb,_0x380a5a=extension_settings[extensionName];if(_0x380a5a['plotOpt_enabled']===![])return null;console[_0x3172c7(0x21d)]('['+extensionName+_0x3172c7(0x232)+new Date()['toLocaleTimeString']()),console['time'](_0x3172c7(0x22d));try{const _0x2c5ab9=_0x2535a2[_0x3172c7(0x21b)];if(!_0x2c5ab9||_0x2c5ab9['trim']()==='')return console[_0x3172c7(0x222)]('['+extensionName+']\x20用户输入为空,跳过优化。'),null;const _0x499a5f=getContext(),_0x3b60e=_0x499a5f[_0x3172c7(0x207)]||'用户',_0xdb2726=_0x499a5f[_0x3172c7(0x212)]||'角色',_0x12cf11=getPresetPrompts(_0x3172c7(0x1de)),_0x4a065e=[{'role':'system','content':generateRandomSeed()}],_0x4b3b0f={'sulv1':_0x380a5a[_0x3172c7(0x1dc)]??0x1,'sulv2':_0x380a5a[_0x3172c7(0x1db)]??0x1,'sulv3':_0x380a5a[_0x3172c7(0x1e4)]??0x1,'sulv4':_0x380a5a[_0x3172c7(0x239)]??0x1};let _0xde1076=_0x380a5a[_0x3172c7(0x1f8)]||'',_0x66f750=_0x380a5a['plotOpt_systemPrompt']||'';for(const _0x5a7548 in _0x4b3b0f){const _0x5acdc2=_0x4b3b0f[_0x5a7548],_0x558253=new RegExp(_0x5a7548[_0x3172c7(0x237)](/[-\/\\^$*+?.()|[\]{}]/g,_0x3172c7(0x23b)),'g');_0xde1076=_0xde1076[_0x3172c7(0x237)](_0x558253,_0x5acdc2),_0x66f750=_0x66f750[_0x3172c7(0x237)](_0x558253,_0x5acdc2);}const _0x3d09de=await getPlotOptimizedWorldbookContent(_0x499a5f,_0x380a5a);let _0x4a1e71='';if(_0x380a5a[_0x3172c7(0x205)])try{const {convertTablesToCsvStringForContentOnly:_0x330b00}=await import(_0x3172c7(0x226)),_0x27433e=_0x3172c7(0x1f3),_0x3e27dd=_0x330b00();_0x3e27dd['trim']()&&(_0x4a1e71=_0x27433e[_0x3172c7(0x237)]('{{{Amily2TableDataContent}}}',_0x3e27dd));}catch(_0x53b71c){console[_0x3172c7(0x236)](_0x3172c7(0x23e),_0x53b71c);}let _0x7124f6='';const _0x9d3823=_0x380a5a[_0x3172c7(0x223)]||0x0;if(_0x9d3823>0x0&&_0x4becd2[_0x3172c7(0x233)]>0x0){const _0x2cfeb4=_0x4becd2['slice'](-_0x9d3823);_0x7124f6=_0x2cfeb4['map'](_0x403516=>{const _0x4cffc8=_0x3172c7;if(_0x403516['mes']&&_0x403516[_0x4cffc8(0x21b)][_0x4cffc8(0x210)]()){const _0x112f67=[{'start':'