Files
ST-Amily2-Chat-Optimisation/core/table-system/secondary-filler.js
2025-08-24 11:51:17 +08:00

2 lines
8.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(_0x2b964f,_0x1d91e0){const _0x294bac=_0x2ed5,_0x2ddd5e=_0x2b964f();while(!![]){try{const _0x347dca=parseInt(_0x294bac(0x1cb))/0x1*(parseInt(_0x294bac(0x1ee))/0x2)+-parseInt(_0x294bac(0x1de))/0x3+parseInt(_0x294bac(0x1f3))/0x4*(-parseInt(_0x294bac(0x1cc))/0x5)+-parseInt(_0x294bac(0x1f7))/0x6+-parseInt(_0x294bac(0x1e4))/0x7*(parseInt(_0x294bac(0x1fa))/0x8)+-parseInt(_0x294bac(0x1f9))/0x9*(-parseInt(_0x294bac(0x1f4))/0xa)+-parseInt(_0x294bac(0x1cf))/0xb*(-parseInt(_0x294bac(0x1e2))/0xc);if(_0x347dca===_0x1d91e0)break;else _0x2ddd5e['push'](_0x2ddd5e['shift']());}catch(_0xff610c){_0x2ddd5e['push'](_0x2ddd5e['shift']());}}}(_0x34f9,0x8b7db));import{getContext,extension_settings}from'/scripts/extensions.js';import{saveChat}from'/script.js';import{renderTables}from'../../ui/table-bindings.js';import{extensionName}from'../../utils/settings.js';import{updateTableFromText,getBatchFillerRuleTemplate,getBatchFillerFlowTemplate,convertTablesToCsvString,saveStateToMessage,getMemoryState}from'./manager.js';function _0x2ed5(_0x2242bc,_0x78da6b){const _0x34f9b3=_0x34f9();return _0x2ed5=function(_0x2ed5f2,_0x2707a1){_0x2ed5f2=_0x2ed5f2-0x1cb;let _0x1500a1=_0x34f9b3[_0x2ed5f2];return _0x1500a1;},_0x2ed5(_0x2242bc,_0x78da6b);}function _0x34f9(){const _0x5e765e=['flowTemplate','secondaryApiUrlWarned','350064XkhmOD','filling_mode','name1','[Amily2-副API]\x20发生严重错误:','12541416csVczS','\x0a</最新消息>','393309HOlUox','[副API填表]\x20加载混合顺序失败:','Amily2-分步填表','严重错误','mes','groupEnd','secondary-api','message','is_user','coreContent','2eoNwhD','replace','index','push','groupCollapsed','152QMTcsj','147890dMtvmd','user','conditional','1456866mTeNSn','[Amily2-副API]\x20未能获取AI响应内容。','333kxThGH','88GhzPYA','请严格根据以下\x22最新消息\x22中的内容进行填写表格并按照指定的格式输出不要添加任何额外信息。\x0a\x0a<最新消息>\x0a','error','37958cBmMTF','10705ZPlqjS','main-api','name2','11gjIYFU','secondary_filler','AMILY2_SYSTEM_PARALYZED','(用户)最新消息:','parse','[Amily2号-副API-原始回复]:','[Amily2\x20分步填表]\x20即将发送至\x20API\x20的内容','length','getItem','system','副API填表失败:\x20','chat','trim'];_0x34f9=function(){return _0x5e765e;};return _0x34f9();}import{getPresetPrompts,getMixedOrder}from'../../PresetSettings/index.js';import{callAI,generateRandomSeed}from'../api.js';export async function fillWithSecondaryApi(_0x234010){const _0x2522bf=_0x2ed5,_0x5ea6e2=extension_settings[extensionName],_0x10261d=_0x5ea6e2[_0x2522bf(0x1df)]||_0x2522bf(0x1cd);if(_0x10261d!==_0x2522bf(0x1ea))return;if(window[_0x2522bf(0x1d1)]===!![]){console[_0x2522bf(0x1fc)]('[Amily2-制裁]\x20系统完整性已受损所有外交活动被无限期中止。');return;}const {apiUrl:_0x58d429,apiKey:_0x2673a6,model:_0x4d4bc4,temperature:_0x1146ea,maxTokens:_0x15c18d,forceProxyForCustomApi:_0x5a8eaf}=_0x5ea6e2;if(!_0x58d429||!_0x4d4bc4){!window[_0x2522bf(0x1dd)]&&(toastr[_0x2522bf(0x1fc)]('主API的URL或模型未配置分步填表功能无法启动。',_0x2522bf(0x1e6)),window[_0x2522bf(0x1dd)]=!![]);return;}try{const _0x4fd3de=_0x234010[_0x2522bf(0x1e8)];if(!_0x4fd3de||!_0x4fd3de[_0x2522bf(0x1db)]()){console['log']('[Amily2-副API]\x20消息内容为空跳过填表任务。'),console['timeEnd']('副API填表任务总耗时'),console[_0x2522bf(0x1e9)]();return;}const _0x368062=getContext(),_0x202f18=_0x368062[_0x2522bf(0x1e0)]||'用户',_0x3e4a44=_0x368062[_0x2522bf(0x1ce)]||'角色',_0x1a8871=_0x368062[_0x2522bf(0x1da)],_0x2a1418=_0x1a8871[_0x2522bf(0x1d6)]>0x1&&_0x1a8871[_0x1a8871[_0x2522bf(0x1d6)]-0x2][_0x2522bf(0x1ec)]?_0x1a8871[_0x1a8871[_0x2522bf(0x1d6)]-0x2]:null,_0x1b0fa6=_0x2a1418?_0x202f18+_0x2522bf(0x1d2)+_0x2a1418[_0x2522bf(0x1e8)]+'\x0a'+_0x3e4a44+'AI最新消息[核心处理内容]'+_0x4fd3de:_0x3e4a44+'AI最新消息[核心处理内容]'+_0x4fd3de;let _0xb0b718;try{const _0x450664=localStorage[_0x2522bf(0x1d7)]('amily2_prompt_presets_v2_mixed_order');_0x450664&&(_0xb0b718=JSON[_0x2522bf(0x1d3)](_0x450664));}catch(_0x37b4e1){console[_0x2522bf(0x1fc)](_0x2522bf(0x1e5),_0x37b4e1);}const _0xc302f3=getMixedOrder(_0x2522bf(0x1d0))||[],_0xf08169=getPresetPrompts(_0x2522bf(0x1d0)),_0x2e309e=[{'role':'system','content':generateRandomSeed()}],_0x41a66c=getBatchFillerRuleTemplate(),_0x5ced0e=getBatchFillerFlowTemplate(),_0x125783=convertTablesToCsvString(),_0xe55abd=_0x5ced0e[_0x2522bf(0x1ef)]('{{{Amily2TableData}}}',_0x125783);for(const _0x20f61b of _0xc302f3){if(_0x20f61b['type']==='prompt')_0xf08169&&_0xf08169[_0x20f61b[_0x2522bf(0x1f0)]]&&_0x2e309e[_0x2522bf(0x1f1)](_0xf08169[_0x20f61b[_0x2522bf(0x1f0)]]);else{if(_0x20f61b['type']===_0x2522bf(0x1f6))switch(_0x20f61b['id']){case'ruleTemplate':_0x2e309e['push']({'role':_0x2522bf(0x1d8),'content':_0x41a66c});break;case _0x2522bf(0x1dc):_0x2e309e[_0x2522bf(0x1f1)]({'role':'system','content':_0xe55abd});break;case _0x2522bf(0x1ed):_0x2e309e[_0x2522bf(0x1f1)]({'role':_0x2522bf(0x1f5),'content':_0x2522bf(0x1fb)+_0x1b0fa6+_0x2522bf(0x1e3)});break;case'thinkingFramework':_0x2e309e['push']({'role':'system','content':'#\x20通用表格转换思考框架\x0a##\x20核心原则\x0a1.\x20将叙事内容转化为结构化数据\x0a2.\x20聚焦关键元素变更\x0a3.\x20保证数据真实性与一致性\x0a##\x20思考流程\x20(<thinking></thinking>)\x0a请严格按此框架思考并在<thinking>标签内输出:\x0a<thinking>\x0a1.\x20【时间地点分析】\x0a\x20\x20\x20-\x20当前时态现在是什么年份/季节/日期?具体几点几分?\x0a\x20\x20\x20-\x20空间定位故事发生在什么场景(建筑/自然等)?具体位置?\x0a\x20\x20\x20-\x20变更检测相比之前时间地点是否有显著变化\x0a2.\x20【角色动态分析】\x0a\x20\x20\x20-\x20在场角色当前场景有哪些角色存在\x0a\x20\x20\x20-\x20新增角色是否有首次出现的角色\x0a\x20\x20\x20-\x20角色变化\x0a\x20\x20\x20\x20\x20-\x20外貌特征体型/发型/穿戴着装\x0a\x20\x20\x20\x20\x20-\x20状态变化受伤/情绪/随身物品\x0a\x20\x20\x20\x20\x20-\x20关系变动新建立/改变的关系\x0a\x20\x20\x20-\x20角色语录有否揭示角色背景的关键对话\x0a3.\x20【任务进展追踪】\x0a\x20\x20\x20-\x20活跃任务正在进行哪些重要事项\x0a\x20\x20\x20-\x20新任务是否产生新的承诺/任务?\x0a\x20\x20\x20-\x20状态更新任何任务进度变化\x0a\x20\x20\x20-\x20任务闭环有无完成或失败的任务\x0a4.\x20【关键物品识别】\x0a\x20\x20\x20-\x20特殊物品有无意义重大的物品出现\x0a\x20\x20\x20-\x20物品变动\x0a\x20\x20\x20\x20\x20-\x20获取/丢失物品\x0a\x20\x20\x20\x20\x20-\x20使用/损耗情况\x0a\x20\x20\x20\x20\x20-\x20所有权变更\x0a5.\x20【系统指令响应】\x20(仅处理明确指令)\x0a\x20\x20\x20-\x20识别是否有来自叙事者的指令(括号标注)\x0a\x20\x20\x20-\x20响应完全执行/拒绝无效指令\x0a6.\x20【逻辑校验】\x0a\x20\x20\x20-\x20矛盾解决处理相互冲突的信息\x0a\x20\x20\x20-\x20数据溯源标注信息提取位置(例第3段)\x0a\x20\x20\x20-\x20过滤机制忽略临时/不重要的描写\x0a\x20\x20\x20-\x20必须填表无论表格是否为新都需要结合正文与现有表格内容进行更新。\x0a\x20\x20\x20-\x20必须填充当内容为\x22未知\x22或者\x22无\x22的表格必须结合现知内容补全。\x0a##\x20通用输出规范\x0a-\x20时间格式YYYY-MM-DD\x20HH:MM\x0a-\x20地点格式[建筑]>[具体位置]\x20(例:城堡>东侧塔楼)\x0a-\x20角色引用统一使用全名首次出现\x0a-\x20状态标记使用标准状态词(进行中/已完成/已取消)\x0a</thinking>\x0a<Amily2Edit>\x0a<!--\x0a(这里是你的填表内容)\x0a-->\x0a</Amily2Edit>\x0a<finsh>The\x20form\x20filling\x20work\x20has\x20been\x20completed.</finsh>'});break;}}}const _0x245b42=_0x5ea6e2[_0x2522bf(0x1df)]||'main-api';_0x245b42===_0x2522bf(0x1ea)&&(console[_0x2522bf(0x1f2)](_0x2522bf(0x1d5)),console['dir'](_0x2e309e),console[_0x2522bf(0x1e9)]());const _0x426095=await callAI(_0x2e309e);if(!_0x426095){console[_0x2522bf(0x1fc)](_0x2522bf(0x1f8));return;}console['log'](_0x2522bf(0x1d4),_0x426095),updateTableFromText(_0x426095);const _0xe5a09c=getContext();if(_0xe5a09c['chat']&&_0xe5a09c[_0x2522bf(0x1da)][_0x2522bf(0x1d6)]>0x0){const _0xffee49=_0xe5a09c['chat'][_0xe5a09c[_0x2522bf(0x1da)][_0x2522bf(0x1d6)]-0x1];if(saveStateToMessage(getMemoryState(),_0xffee49)){saveChat(),renderTables();return;}}saveChatDebounced();}catch(_0x20b37e){console[_0x2522bf(0x1fc)](_0x2522bf(0x1e1),_0x20b37e),toastr[_0x2522bf(0x1fc)](_0x2522bf(0x1d9)+_0x20b37e[_0x2522bf(0x1eb)],_0x2522bf(0x1e7));}}