Files
ST-Amily2-Chat-Optimisation/core/rag-processor.js
2025-09-28 23:46:54 +08:00

2 lines
48 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.
'use strict';const _0x5d3107=_0x25d4;function _0x25d4(_0x910e97,_0x399df3){const _0x21b01c=_0x21b0();return _0x25d4=function(_0x25d4c9,_0x1ed7cd){_0x25d4c9=_0x25d4c9-0x140;let _0x21c417=_0x21b01c[_0x25d4c9];return _0x21c417;},_0x25d4(_0x910e97,_0x399df3);}(function(_0x14987d,_0x2d6dbd){const _0x1fc0c8=_0x25d4,_0x559f80=_0x14987d();while(!![]){try{const _0x162154=-parseInt(_0x1fc0c8(0x235))/0x1+-parseInt(_0x1fc0c8(0x1ca))/0x2+parseInt(_0x1fc0c8(0x1c2))/0x3*(-parseInt(_0x1fc0c8(0x194))/0x4)+-parseInt(_0x1fc0c8(0x176))/0x5+-parseInt(_0x1fc0c8(0x19b))/0x6*(parseInt(_0x1fc0c8(0x19e))/0x7)+parseInt(_0x1fc0c8(0x208))/0x8+-parseInt(_0x1fc0c8(0x221))/0x9*(-parseInt(_0x1fc0c8(0x212))/0xa);if(_0x162154===_0x2d6dbd)break;else _0x559f80['push'](_0x559f80['shift']());}catch(_0x1710e2){_0x559f80['push'](_0x559f80['shift']());}}}(_0x21b0,0xa1980));import{extension_prompt_roles,setExtensionPrompt}from'/script.js';import*as _0x92844d from'./utils/context-utils.js';import{getCollectionIdInfo,getCharacterId,getCharacterStableId}from'./utils/context-utils.js';import{defaultSettings as _0xa36a4a}from'./rag-settings.js';import*as _0x100a2d from'./ingestion-manager.js';import{getEmbeddings,fetchEmbeddingModels as _0x51d523,fetchRerankModels as _0xcf46af,executeRerank,testApiConnection as _0x535c48}from'./rag-api.js';const MODULE_NAME=_0x5d3107(0x1d1),OFFICIAL_REARRANGE_CHAT_FUNCTION_NAME=_0x5d3107(0x1bd),GLOBAL_SCOPE_ID=_0x5d3107(0x173);let context=null,settings=null,lockedCollectionId=null;function filterWorldbooks(_0x44bbee,_0x37dc97){const _0x1b07b1=_0x5d3107;if(!_0x44bbee||!_0x44bbee[_0x1b07b1(0x171)]())return _0x37dc97;const _0x5c845e=_0x44bbee[_0x1b07b1(0x1c7)]()[_0x1b07b1(0x171)]();return _0x37dc97[_0x1b07b1(0x1bc)](_0x528a7b=>{const _0x5242a5=_0x1b07b1;return _0x528a7b[_0x5242a5(0x1c7)]()['includes'](_0x5c845e)||containsPinyinMatch(_0x528a7b,_0x5c845e);});}function filterWorldbookEntries(_0x3ce68c,_0x3667de){const _0x58eda6=_0x5d3107;if(!_0x3ce68c||!_0x3ce68c[_0x58eda6(0x171)]())return _0x3667de;const _0xe2603c=_0x3ce68c[_0x58eda6(0x1c7)]()['trim']();return _0x3667de[_0x58eda6(0x1bc)](_0x4b8c07=>{const _0x2e9eb1=_0x58eda6,_0x27b2aa=[_0x4b8c07[_0x2e9eb1(0x230)]||'',_0x4b8c07['key']||'',_0x4b8c07[_0x2e9eb1(0x158)]||''][_0x2e9eb1(0x1df)]('\x20')[_0x2e9eb1(0x1c7)]();return _0x27b2aa[_0x2e9eb1(0x154)](_0xe2603c)||containsPinyinMatch(_0x4b8c07['comment']||'',_0xe2603c);});}function containsPinyinMatch(_0x5a339f,_0x143fba){const _0x3f5bf0=_0x5d3107,_0x2ef757={'世界书':'sjshu','条目':_0x3f5bf0(0x1f7),'编纂':'bianzhuan','搜索':_0x3f5bf0(0x23f)},_0x4d3fce=_0x2ef757[_0x5a339f];return _0x4d3fce&&_0x4d3fce[_0x3f5bf0(0x154)](_0x143fba);}function highlightSearchMatch(_0x493f52,_0x1172e7){const _0x302c68=_0x5d3107;if(!_0x1172e7||!_0x1172e7[_0x302c68(0x171)]())return _0x493f52;const _0x23aadd=new RegExp('('+_0x1172e7['replace'](/[.*+?^${}()|[\]\\]/g,_0x302c68(0x21e))+')','gi');return _0x493f52[_0x302c68(0x1fa)](_0x23aadd,_0x302c68(0x1d9));}function debounce(_0x4f32a0,_0x1ae045){let _0x1a7300;return function _0xeec3c4(..._0x52961a){const _0x2a523e=()=>{clearTimeout(_0x1a7300),_0x4f32a0(..._0x52961a);};clearTimeout(_0x1a7300),_0x1a7300=setTimeout(_0x2a523e,_0x1ae045);};}export{initialize,getSettings,saveSettings,resetSettings,_0x535c48 as testApiConnection,_0x51d523 as fetchEmbeddingModels,_0xcf46af as fetchRerankModels,getVectorCount,purgeStorage,getMessagesForCondensation,processCondensation,ingestTextToHanlinyuan,getCollectionId,toggleSessionLock,isSessionLocked,getLockedSessionInfo,addKnowledgeBase,removeKnowledgeBase,getLocalKnowledgeBases,getGlobalKnowledgeBases,toggleKnowledgeBase,moveKnowledgeBase,filterWorldbooks,filterWorldbookEntries,highlightSearchMatch,debounce};function initialize(){const _0x3eee36=_0x5d3107;context=SillyTavern[_0x3eee36(0x1c1)]();if(!context){console['error'](_0x3eee36(0x1be));return;}settings=getSettings(),!window['hanlinyuanRagProcessor']&&(window['hanlinyuanRagProcessor']={}),window['hanlinyuanRagProcessor']['rearrangeChat']=rearrangeChat,window[_0x3eee36(0x1b9)][_0x3eee36(0x14f)]=!![],console[_0x3eee36(0x1f2)](_0x3eee36(0x243));}async function ingestTextToHanlinyuan(_0x3dda79,_0x24eb3d=_0x5d3107(0x161),_0x21b6c4={},_0x2912da=()=>{},_0x39e68f=null,_0xa92799=()=>{},_0x552c78=()=>{},_0x4eac81=null,_0x1cf252=0x0){const _0xcbfd84=_0x5d3107;if(!_0x3dda79||!_0x3dda79[_0xcbfd84(0x171)]())return{'success':![],'error':_0xcbfd84(0x217)};if(!settings)return{'success':![],'error':_0xcbfd84(0x241)};try{const _0x20ab45=getCollectionIdInfo(),_0xedee1d=await _0x5bd7f2();if(_0x20ab45['oldId']&&_0x20ab45[_0xcbfd84(0x248)]===_0xedee1d&&_0x20ab45['oldId']!==_0x20ab45['newId']){const _0x2e0615=confirm(_0xcbfd84(0x22e));if(_0x2e0615)_0xa92799(_0xcbfd84(0x167)+_0x20ab45[_0xcbfd84(0x248)],_0xcbfd84(0x16a)),await purgeStorage(_0x20ab45[_0xcbfd84(0x248)]),_0xa92799('[翰林院-迁移]\x20旧宝库已清空。',_0xcbfd84(0x1f1));else return _0xa92799('[翰林院-迁移]\x20用户取消了迁移操作。',_0xcbfd84(0x149)),toastr[_0xcbfd84(0x149)](_0xcbfd84(0x14a)),{'success':![],'error':_0xcbfd84(0x1d6)};}let _0x378469,_0x4c81ee;const _0x1c58bb=new Date()[_0xcbfd84(0x1a0)](_0xcbfd84(0x15f),{'hour12':![]}),_0x1bc1ee=getCharacterName()||'未知角色';switch(_0x24eb3d){case _0xcbfd84(0x1e0):const _0x13dee9=_0x21b6c4[_0xcbfd84(0x229)]||{},_0xb659a6=_0x13dee9[_0xcbfd84(0x1a6)]??'?',_0xe24cb9=_0x13dee9[_0xcbfd84(0x1ce)]===0x0?'末':_0x13dee9[_0xcbfd84(0x1ce)]??'?';_0x378469=_0x1bc1ee+':\x20'+_0xb659a6+'楼-'+_0xe24cb9+'楼';break;case _0xcbfd84(0x191):const _0x933b84=_0x21b6c4[_0xcbfd84(0x21c)]||_0xcbfd84(0x245),_0x336d97=_0x21b6c4[_0xcbfd84(0x179)]||_0xcbfd84(0x19f);_0x378469=_0x933b84+':\x20'+_0x336d97;break;case _0xcbfd84(0x18a):_0x378469='小说:\x20'+(_0x21b6c4['sourceName']||'未知小说');break;case _0xcbfd84(0x161):default:_0x378469='手动录入:\x20'+_0x1c58bb;break;}const _0x480fec=Object[_0xcbfd84(0x15b)](getKnowledgeBases()),_0x322f3c=_0x480fec[_0xcbfd84(0x197)](_0x388ab9=>_0x388ab9['name']===_0x378469);if(_0x322f3c)_0x4c81ee=_0x322f3c['id'],_0xa92799(_0xcbfd84(0x21f)+_0x378469+_0xcbfd84(0x18d),'info');else{_0xa92799(_0xcbfd84(0x1b6)+_0x378469+_0xcbfd84(0x1a3),_0xcbfd84(0x149));const _0x37393a=addKnowledgeBase(_0x378469);_0x4c81ee=_0x37393a['id'];}const _0x316562=getCharacterStableId(),_0x3b8275=_0x316562+'_'+_0x4c81ee;_0xa92799('[翰林院-核心]\x20已创建并锁定知识库:\x20'+_0x378469+'\x20(集合ID:\x20'+_0x3b8275+')',_0xcbfd84(0x1f1)),_0xa92799(_0xcbfd84(0x159)+_0x3b8275,'info'),_0x2912da({'message':_0xcbfd84(0x20f),'processed':0x0,'total':0x1});const _0x4e985f=splitIntoChunks(_0x3dda79,_0x24eb3d,_0x21b6c4),_0x3e527a=_0x4e985f[_0xcbfd84(0x168)];if(_0x39e68f?.['aborted'])throw new Error(_0xcbfd84(0x246));_0xa92799('[翰林院-核心]\x20将来源\x27'+_0x378469+_0xcbfd84(0x1d2)+_0x3e527a+'\x20个块。',_0xcbfd84(0x149));if(_0x3e527a===0x0)return{'success':!![],'count':0x0};const _0x31210e=settings['retrieval'][_0xcbfd84(0x1ab)]||0x5;let _0xd3c8fb=_0x1cf252;for(let _0x2d5112=_0x1cf252;_0x2d5112<_0x3e527a;_0x2d5112+=_0x31210e){if(_0x39e68f?.['aborted'])throw new Error('AbortError');const _0x5b21ec=_0x4e985f[_0xcbfd84(0x228)](_0x2d5112,_0x2d5112+_0x31210e);_0x2912da({'message':'正在处理\x20'+(_0x2d5112+0x1)+'-'+(_0x2d5112+_0x5b21ec['length'])+'\x20块','processed':_0x2d5112,'total':_0x3e527a});const _0x3380fa=_0x5b21ec[_0xcbfd84(0x153)](_0x4e50f6=>_0x4e50f6[_0xcbfd84(0x15d)]),_0x379a07=await getEmbeddings(_0x3380fa,_0x39e68f);if(_0x39e68f?.[_0xcbfd84(0x15c)])throw new Error(_0xcbfd84(0x246));if(_0x5b21ec[_0xcbfd84(0x168)]!==_0x379a07[_0xcbfd84(0x168)])throw new Error(_0xcbfd84(0x178));const _0x29b2e8=_0x5b21ec['map']((_0xae29cf,_0x5a97d5)=>({..._0xae29cf,'vector':_0x379a07[_0x5a97d5]}));await insertVectors(_0x29b2e8,_0x39e68f,_0x3b8275),_0xd3c8fb+=_0x5b21ec[_0xcbfd84(0x168)],_0x4eac81&&_0x100a2d[_0xcbfd84(0x23b)](_0x4eac81,_0xd3c8fb,_0x3e527a),await _0x552c78();}return _0x4eac81&&_0x100a2d[_0xcbfd84(0x146)](_0x4eac81),_0xa92799(_0xcbfd84(0x1ed)+_0xd3c8fb+'\x20个向量条目。',_0xcbfd84(0x1f1)),{'success':!![],'count':_0xd3c8fb};}catch(_0x397772){if(_0x397772[_0xcbfd84(0x19d)]===_0xcbfd84(0x246)){_0xa92799(_0xcbfd84(0x1e4),_0xcbfd84(0x16a));throw _0x397772;}return console[_0xcbfd84(0x164)](_0xcbfd84(0x238),_0x397772),_0xa92799(_0xcbfd84(0x1fc)+_0x397772[_0xcbfd84(0x19a)],'error'),{'success':![],'error':_0x397772[_0xcbfd84(0x19a)]};}}function getSettings(){const _0xd21bc1=_0x5d3107;if(!context||!context[_0xd21bc1(0x142)])return structuredClone(_0xa36a4a);let _0x330956=context['extensionSettings'][MODULE_NAME];!_0x330956&&(_0x330956={},context['extensionSettings'][MODULE_NAME]=_0x330956);_0x330956['condensationHistory']===undefined&&(_0x330956[_0xd21bc1(0x1cc)]={});_0x330956[_0xd21bc1(0x1eb)]===undefined&&(_0x330956[_0xd21bc1(0x1eb)]={});for(const _0xa6cd1b in _0xa36a4a){if(_0x330956[_0xa6cd1b]===undefined)_0x330956[_0xa6cd1b]=structuredClone(_0xa36a4a[_0xa6cd1b]);else{if(typeof _0xa36a4a[_0xa6cd1b]===_0xd21bc1(0x1c9)&&!Array[_0xd21bc1(0x1b4)](_0xa36a4a[_0xa6cd1b])&&_0xa36a4a[_0xa6cd1b]!==null)for(const _0x4b50c7 in _0xa36a4a[_0xa6cd1b]){_0x330956[_0xa6cd1b][_0x4b50c7]===undefined&&(_0x330956[_0xa6cd1b][_0x4b50c7]=_0xa36a4a[_0xa6cd1b][_0x4b50c7]);}}}return _0x330956;}function saveSettings(){const _0x27f862=_0x5d3107;if(context)context[_0x27f862(0x20c)]();}function resetSettings(){const _0x30f435=_0x5d3107;context&&(context[_0x30f435(0x142)][MODULE_NAME]=structuredClone(_0xa36a4a),saveSettings());}function showNotification(_0x154bc0,_0x3e059f=_0x5d3107(0x149)){toastr[_0x3e059f](_0x154bc0);}function getTagForSource(_0x4a3555){const _0x2b5d2a=_0x5d3107;switch(_0x4a3555){case _0x2b5d2a(0x1e0):return _0x2b5d2a(0x1cd);case _0x2b5d2a(0x191):return _0x2b5d2a(0x224);case _0x2b5d2a(0x161):return _0x2b5d2a(0x1e9);case _0x2b5d2a(0x18a):return _0x2b5d2a(0x1e3);default:return'资料';}}function splitIntoChunks(_0x47370c,_0x4a687e,_0x202ea9={}){const _0x10d62b=_0x5d3107;switch(_0x4a687e){case _0x10d62b(0x18a):return _chunkForNovel(_0x47370c,_0x202ea9);case'chat_history':return _chunkForChatHistory(_0x47370c,_0x202ea9);case _0x10d62b(0x191):return _chunkForLorebook(_0x47370c,_0x202ea9);case _0x10d62b(0x161):return _chunkForManual(_0x47370c,_0x202ea9);default:console[_0x10d62b(0x16a)](_0x10d62b(0x170)+_0x4a687e+_0x10d62b(0x163));return _chunkForManual(_0x47370c,{..._0x202ea9,'sourceName':_0x202ea9[_0x10d62b(0x1e8)]||'未知来源'});}}function _chunkForNovel(_0x4215c7,_0x5b43a8){const _0x49a5a5=_0x5d3107,{chunkSize:_0x498712,overlap:_0x67dff0}=settings[_0x49a5a5(0x247)],{sourceName:sourceName='小说'}=_0x5b43a8,_0x2cdf45=[];if(!_0x4215c7||_0x498712<=0x0)return _0x2cdf45;const _0x477e08=/(第\s*[一二三四五六七八九十百千万零\d]+\s*卷)/gim,_0x20f370=/(第\s*[一二三四五六七八九十百千万零\d]+\s*[章回节部])|^(Chapter\s+\d+)/gim;let _0x18a0dc=0x0;const _0x50e6cc=_0x4215c7[_0x49a5a5(0x1c8)]('\x0a');let _0x4bcdd8='第1卷',_0x2135c8=_0x49a5a5(0x1fb),_0x36fba8=[];function _0x37c076(){const _0x1e6902=_0x49a5a5;if(_0x36fba8[_0x1e6902(0x168)]===0x0)return;const _0x103d39=_0x36fba8[_0x1e6902(0x1df)]('\x0a');let _0x5c6ea0=0x0,_0x52b063=0x1;while(_0x5c6ea0<_0x103d39['length']){const _0x492dc2=Math[_0x1e6902(0x1ba)](_0x5c6ea0+_0x498712,_0x103d39[_0x1e6902(0x168)]),_0x4bd798=_0x103d39[_0x1e6902(0x213)](_0x5c6ea0,_0x492dc2);if(_0x4bd798[_0x1e6902(0x171)]()[_0x1e6902(0x168)]>0x0){const _0xfbaddc={'source':'novel','sourceName':sourceName,'timestamp':new Date()['toISOString'](),'globalIndex':_0x18a0dc++,'volume':_0x4bcdd8,'chapter':_0x2135c8,'section':_0x52b063},_0x5e92c6=getTagForSource('novel'),_0x46920c=_0x1e6902(0x16f)+sourceName+',\x20'+_0x4bcdd8+',\x20'+_0x2135c8+_0x1e6902(0x225)+_0x52b063+'节]',_0x1ceee7='<'+_0x5e92c6+'>\x0a'+_0x46920c+'\x0a'+_0x4bd798+_0x1e6902(0x1de)+_0x5e92c6+'>';_0x2cdf45['push']({'text':_0x1ceee7,'metadata':_0xfbaddc}),_0x52b063++;}_0x5c6ea0+=_0x498712-_0x67dff0;if(_0x5c6ea0>=_0x103d39['length'])break;}_0x36fba8=[];}for(const _0x389462 of _0x50e6cc){const _0x33037e=_0x389462['trim']();if(_0x477e08['test'](_0x33037e))_0x37c076(),_0x4bcdd8=_0x33037e,_0x2135c8=_0x49a5a5(0x1fb);else _0x20f370[_0x49a5a5(0x232)](_0x33037e)?(_0x37c076(),_0x2135c8=_0x33037e):_0x36fba8[_0x49a5a5(0x1bb)](_0x389462);}_0x37c076();if(_0x2cdf45[_0x49a5a5(0x168)]===0x0&&_0x4215c7[_0x49a5a5(0x168)]>0x0){let _0x2d7a23=0x0,_0x4ff425=0x1;while(_0x2d7a23<_0x4215c7[_0x49a5a5(0x168)]){const _0x3e0c00=Math['min'](_0x2d7a23+_0x498712,_0x4215c7[_0x49a5a5(0x168)]),_0x341489=_0x4215c7['substring'](_0x2d7a23,_0x3e0c00),_0x35cf12={'source':_0x49a5a5(0x18a),'sourceName':sourceName,'timestamp':new Date()[_0x49a5a5(0x1ec)](),'globalIndex':_0x2cdf45[_0x49a5a5(0x168)],'volume':_0x49a5a5(0x1cb),'chapter':_0x49a5a5(0x1fb),'section':_0x4ff425},_0x2c1e70=getTagForSource('novel'),_0x342391=_0x49a5a5(0x16f)+sourceName+_0x49a5a5(0x218)+_0x4ff425+'节]',_0x270928='<'+_0x2c1e70+'>\x0a'+_0x342391+'\x0a'+_0x341489+_0x49a5a5(0x1de)+_0x2c1e70+'>';_0x2cdf45['push']({'text':_0x270928,'metadata':_0x35cf12}),_0x4ff425++,_0x2d7a23+=_0x498712-_0x67dff0;}}return _0x2cdf45;}function _chunkForChatHistory(_0x163217,_0x12f6a6){const _0x2e96e9=_0x5d3107,{chunkSize:_0x5725c9,overlap:_0x4f7de3}=settings[_0x2e96e9(0x247)],{floor:_0xca0b41,is_user:_0x3d8f21,timestamp:_0x5e76db}=_0x12f6a6,_0x209235=[];if(!_0x163217||_0x5725c9<=0x0)return _0x209235;let _0x4ddff8=0x1,_0x1a5ee2=0x0;while(_0x1a5ee2<_0x163217[_0x2e96e9(0x168)]){const _0x370930=Math[_0x2e96e9(0x1ba)](_0x1a5ee2+_0x5725c9,_0x163217[_0x2e96e9(0x168)]),_0xcebb88=_0x163217['substring'](_0x1a5ee2,_0x370930),_0x1fba2b=_0x2e96e9(0x1e6)+_0xca0b41+_0x2e96e9(0x225)+_0x4ddff8+_0x2e96e9(0x20a),_0x217e79=getTagForSource('chat_history'),_0x2ef4bb='<'+_0x217e79+'>\x0a'+_0x1fba2b+'\x0a'+_0xcebb88+_0x2e96e9(0x1de)+_0x217e79+'>';_0x209235[_0x2e96e9(0x1bb)]({'text':_0x2ef4bb,'metadata':{'source':_0x2e96e9(0x1e0),'sourceName':'聊天记录\x20#'+_0xca0b41,'floor':_0xca0b41,'part':_0x4ddff8,'is_user':_0x3d8f21,'timestamp':_0x5e76db}}),_0x4ddff8++,_0x1a5ee2+=_0x5725c9-_0x4f7de3;if(_0x1a5ee2>=_0x163217[_0x2e96e9(0x168)])break;}return _0x209235;}function _chunkForLorebook(_0x148306,_0x5832d3){const _0x3788b2=_0x5d3107,{chunkSize:_0x2ce878,overlap:_0x3862b3}=settings['advanced'],{sourceName:sourceName=_0x3788b2(0x22b)}=_0x5832d3,_0x30c1b3=[];if(!_0x148306||_0x2ce878<=0x0)return _0x30c1b3;let _0x586ebb=0x1,_0x27b8d2=0x0;while(_0x27b8d2<_0x148306[_0x3788b2(0x168)]){const _0xac92e2=Math[_0x3788b2(0x1ba)](_0x27b8d2+_0x2ce878,_0x148306['length']),_0x1ae172=_0x148306[_0x3788b2(0x213)](_0x27b8d2,_0xac92e2),_0x231b8c=_0x3788b2(0x180)+sourceName+_0x3788b2(0x225)+_0x586ebb+'部分]',_0x22882d=getTagForSource(_0x3788b2(0x191)),_0x45b5e2='<'+_0x22882d+'>\x0a'+_0x231b8c+'\x0a'+_0x1ae172+_0x3788b2(0x1de)+_0x22882d+'>';_0x30c1b3[_0x3788b2(0x1bb)]({'text':_0x45b5e2,'metadata':{'source':'lorebook','sourceName':sourceName,'part':_0x586ebb,'timestamp':new Date()[_0x3788b2(0x1ec)]()}}),_0x586ebb++,_0x27b8d2+=_0x2ce878-_0x3862b3;if(_0x27b8d2>=_0x148306['length'])break;}return _0x30c1b3;}function _0x21b0(){const _0x460701=['send_date','_global','...)','source','6597285vawQCE','[翰林院-日志]\x20统计集合\x20','文本块和向量数量不匹配','entryName','local','now','[翰林院-迁移]\x20集合\x20','floor','[翰林院-核心]\x20聊天记录凝识失败:\x20','[翰林院-计数]\x20在作用域\x20\x27','[来源:\x20世界书,\x20条目:\x20','\x20返回\x20','json','\x20条消息分解为\x20','webllm','HANLINYUAN_RAG_NOVEL','top_n','[翰林院-日志]\x20清空目标集合ID:\x20','[翰林院-日志]\x20无法确定要清空的目标集合ID。',')\x20的状态已切换为:\x20','novel','\x20条结果。','max','\x22将数据合并入库。','[翰林院-配置]\x20','[翰林院-调试]\x20步骤2\x20-\x20rerankResults返回的最终结果:','abs','lorebook','\x20失败:\x20','enabled','4wKKEQF','(已锁定:\x20','[翰林院-调试]\x20步骤1\x20-\x20queryVectors返回的原始结果:','find','[翰林院-修复]\x20最终返回数组样本:','凝识之权未开启','message','2178eTLfvH','add','name','20209IbymzP','未知条目','toLocaleString','embeddings','\x20(集合ID:\x20','\x22\x20创建专属知识库...','[翰林院-核心]\x20清空向量集合\x20','sort','start','删除知识库失败,未能清空后端数据。','charCodeAt','[翰林院-核心]\x20已为宝库\x20','results','batchSize','owner','[翰林院-核心]\x20知识库\x20','忆识存入API错误\x20','then','聊天记录:\x20','index','vector','[翰林院-日志]\x20所有知识库查询完毕共获得\x20','isArray','reduce','[翰林院-核心]\x20准备为任务\x20\x22','[翰林院-日志]\x20开始多知识库向量查询...','/api/vector/query','hanlinyuanRagProcessor','min','push','filter','vectors_rearrangeChat','[翰林院]\x20未能获取SillyTavern上下文初始化失败。','hasOwnProperty','\x20不存在计为\x200。','getContext','48486WXQkvT','hashes','\x20-\x20楼层\x20#','】已成功移动到','resolve','toLowerCase','split','object','1016752qZgdIS','第1卷','condensationHistory','聊天记录','end','\x27\x20的注入设置跳过处理。','[翰林院-Rerank]\x20开始元数据加权最终排序...','hanlinyuan-rag-core','\x27的文本分割成\x20','retrieval','section','[翰林院-日志]\x20统计目标集合ID:\x20','用户取消了迁移操作','relevance_score','[翰林院-日志]\x20/api/vector/purge\x20响应状态:\x20','<mark\x20class=\x22search-highlight\x22>$1</mark>','\x27\x20注入\x20',',\x20向量化录入时间:\x20','/api/vector/list','未知角色','\x0a</','join','chat_history','condensation','\x20失败:','小说录入','[翰林院-核心]\x20文本录入任务被用户中止。','[翰林院-Rerank]\x20外部Rerank失败将仅使用内部加权。','[来源:\x20聊天记录,\x20楼层:\x20#','forEach','sourceName','手动录入','/api/vector/insert','knowledgeBases','toISOString','[翰林院-核心]\x20成功插入\x20','final_score','flat','random','success','log',',将清空集合:\x20','match','status','template','tiaomu','[翰林院-日志]\x20没有启用的新知识库尝试查询旧版单体宝库...',']\x20的消息已成功凝识。','replace','第1章','[翰林院-核心]\x20文本录入失败:\x20','_history','\x27\x20中未找到ID为\x20','volume','rerank','\x20个条目。','global','[翰林院-核心]\x20凝识任务已锁定知识库:\x20','HANLINYUAN_RAG_LOREBOOK','depth','legacy','is_user','9739208wNNYxA','[翰林院-日志]\x20获取集合\x20','部分]','metadata','saveSettingsDebounced','\x20的知识库。','聊天记录\x20#','正在智能分块...','[翰林院-核心]\x20已将\x20','[翰林院-核心]\x20准备删除知识库\x20','683220fLVZVM','substring','忆识检索失败:\x20','No\x20messages\x20to\x20process.','在源作用域\x20\x27','输入文本为空',',\x20第1卷,\x20第1章,\x20第','\x20条初步结果。','旧版宝库\x20(Legacy)','string','bookName','[翰林院-日志]\x20去重后剩余\x20','\x5c$&','[翰林院-核心]\x20检测到同名知识库\x20\x22','[翰林院]\x20检索或注入时发生错误:','387VVngCh','[翰林院-配置]\x20为旧版知识库\x20','rerank_score','世界书',',\x20第','[翰林院-调试]\x20步骤3\x20-\x20按来源分组后的结果:','[翰林院-Rerank]\x20元数据加权排序完成。','slice','range','HANLINYUAN_RAG_CHAT','世界书条目','toString','\x20(范围:\x20','检测到旧版数据。此操作将把旧数据迁移到新格式,过程不可逆,是否继续?','知识库【','comment','\x20时发生网络错误:','test','\x20条内容。','\x20及其向量数据。','601383GsoELJ','scope','messageTypes','[翰林院-核心]\x20ingestTextToHanlinyuan\x20失败:','stringify','task_','saveProgress','[翰林院-日志]\x20查询知识库\x20','\x20补充所有者ID:\x20','mes','sousuo','[翰林院-修复]\x20最终返回数组长度:\x20','核心未初始化','[翰林院-核心]\x20已为角色\x20','翰林院忆识核心已启动\x20(V5.2-集成版),已注册到全局\x20hanlinyuanRagProcessor\x20对象。','quiet','未分类世界书','AbortError','advanced','oldId','chat','hybrid_alpha','queryMessageCount','移动失败:没有当前角色,无法移入局部知识库。','score','\x20(ID:\x20','extensionSettings','all','\x22\x20已删除。','maxResults','clearJob','has','[翰林院-日志]\x20所有知识库统计完成总向量数:\x20','info','操作已取消。','[翰林院-核心]\x20聊天记录凝识完成成功插入\x20','\x20添加新知识库:\x20','depth_role','[翰林院-日志]\x20忆识存入API错误:','initialized','matchThreshold','POST','移动失败:未找到源条目。','map','includes','getTime','\x20失败删除操作中止。','[翰林院-日志]\x20集合\x20','content','[翰林院-核心]\x20已锁定忆识宝库ID:\x20','getRequestHeaders','values','aborted','text','injection_','zh-CN','notify','manual','chapter','\x27使用通用分块逻辑。','error','user','HANLINYUAN_RAG_MANUAL','[翰林院-迁移]\x20用户确认迁移正在处理旧宝库:\x20','length','[翰林院-Rerank]\x20开始外部API重排序...','warn','知识库名称不能为空','data','findIndex','[翰林院-日志]\x20开始清空宝库...','[来源:\x20','[翰林院-分块]\x20未知的来源类型\x20\x27','trim'];_0x21b0=function(){return _0x460701;};return _0x21b0();}function _chunkForManual(_0x4007e7,_0x3b92f4){const _0x19d720=_0x5d3107,{chunkSize:_0x1c98ff,overlap:_0x27f9d6}=settings[_0x19d720(0x247)],{sourceName:sourceName=_0x19d720(0x1e9)}=_0x3b92f4,_0x3e10f5=[];if(!_0x4007e7||_0x1c98ff<=0x0)return _0x3e10f5;const _0x203860=new Date(),_0x26952d=_0x203860['toLocaleString'](_0x19d720(0x15f));let _0x337c58=0x1,_0x2f8484=0x0;while(_0x2f8484<_0x4007e7[_0x19d720(0x168)]){const _0x162bc6=Math['min'](_0x2f8484+_0x1c98ff,_0x4007e7['length']),_0x188497=_0x4007e7[_0x19d720(0x213)](_0x2f8484,_0x162bc6),_0x26bd26=_0x19d720(0x16f)+sourceName+_0x19d720(0x1db)+_0x26952d+',\x20第'+_0x337c58+_0x19d720(0x20a),_0x1690e5=getTagForSource(_0x19d720(0x161)),_0x173bb7='<'+_0x1690e5+'>\x0a'+_0x26bd26+'\x0a'+_0x188497+_0x19d720(0x1de)+_0x1690e5+'>';_0x3e10f5['push']({'text':_0x173bb7,'metadata':{'source':_0x19d720(0x161),'sourceName':sourceName,'part':_0x337c58,'timestamp':_0x203860['toISOString']()}}),_0x337c58++,_0x2f8484+=_0x1c98ff-_0x27f9d6;if(_0x2f8484>=_0x4007e7[_0x19d720(0x168)])break;}return _0x3e10f5;}import{getCollectionId as _0x5bd7f2,getCharacterName}from'./utils/context-utils.js';async function getCollectionId(){return lockedCollectionId||await _0x5bd7f2();}async function toggleSessionLock(){return lockedCollectionId?(lockedCollectionId=null,![]):(lockedCollectionId=await _0x5bd7f2(),!![]);}function isSessionLocked(){return lockedCollectionId!==null;}function getLockedSessionInfo(){const _0x8f4641=_0x5d3107;if(!lockedCollectionId)return null;return{'id':lockedCollectionId,'name':_0x8f4641(0x195)+lockedCollectionId[_0x8f4641(0x213)](0x0,0x8)+_0x8f4641(0x174)};}function getLocalKnowledgeBases(){const _0xf6b673=_0x5d3107,_0x2295f1=getCharacterStableId();return!settings[_0xf6b673(0x1eb)][_0x2295f1]&&(settings[_0xf6b673(0x1eb)][_0x2295f1]={}),settings[_0xf6b673(0x1eb)][_0x2295f1];}function getGlobalKnowledgeBases(){const _0x4d4b89=_0x5d3107;return!settings[_0x4d4b89(0x1eb)][GLOBAL_SCOPE_ID]&&(settings[_0x4d4b89(0x1eb)][GLOBAL_SCOPE_ID]={}),settings[_0x4d4b89(0x1eb)][GLOBAL_SCOPE_ID];}function getKnowledgeBases(){const _0x286dcd=getLocalKnowledgeBases(),_0xf0336b=getGlobalKnowledgeBases();return{..._0xf0336b,..._0x286dcd};}function addKnowledgeBase(_0x315c7b){const _0x5ca6cb=_0x5d3107;if(!_0x315c7b||!_0x315c7b['trim']())throw new Error(_0x5ca6cb(0x16b));const _0x155925=getCharacterStableId(),_0x13c5ee=getLocalKnowledgeBases(),_0x422e56=_0x5ca6cb(0x23a)+Date[_0x5ca6cb(0x17b)]()+'_'+Math[_0x5ca6cb(0x1f0)]()['toString'](0x24)[_0x5ca6cb(0x213)](0x2,0x9),_0xfbdc3e={'id':_0x422e56,'name':_0x315c7b[_0x5ca6cb(0x171)](),'enabled':!![],'createdAt':new Date()[_0x5ca6cb(0x1ec)](),'owner':_0x155925};return _0x13c5ee[_0x422e56]=_0xfbdc3e,saveSettings(),console['log'](_0x5ca6cb(0x242)+_0x155925+_0x5ca6cb(0x14c)+_0x315c7b+_0x5ca6cb(0x141)+_0x422e56+')'),_0xfbdc3e;}async function removeKnowledgeBase(_0x52e2fd,_0x3661fe){const _0x324e47=_0x5d3107,_0x3ed969=getCharacterStableId(),_0x245b89=_0x3661fe===_0x324e47(0x202)?getGlobalKnowledgeBases():getLocalKnowledgeBases(),_0x377f52=_0x245b89[_0x52e2fd],_0x4f5da1=_0x377f52?.[_0x324e47(0x19d)]||_0x52e2fd;if(!_0x377f52){console[_0x324e47(0x16a)]('[翰林院-核心]\x20尝试删除一个不存在的知识库:\x20'+_0x52e2fd+_0x324e47(0x22d)+_0x3661fe+')');return;}const _0x1f8760=_0x3661fe===_0x324e47(0x202)?_0x377f52[_0x324e47(0x1ac)]||GLOBAL_SCOPE_ID:_0x3ed969,_0x239431=_0x1f8760+'_'+_0x52e2fd;console['log'](_0x324e47(0x211)+_0x52e2fd+_0x324e47(0x1f3)+_0x239431);const _0x34a6bc=await purgeStorage(_0x239431);_0x34a6bc?(delete _0x245b89[_0x52e2fd],saveSettings(),console['log']('[翰林院-核心]\x20成功删除知识库\x20'+_0x52e2fd+_0x324e47(0x234)),toastr['success']('知识库\x20\x22'+_0x4f5da1+_0x324e47(0x144))):(console[_0x324e47(0x164)](_0x324e47(0x1a4)+_0x239431+_0x324e47(0x156)),toastr['error'](_0x324e47(0x1a7)));}function toggleKnowledgeBase(_0x323e64,_0x291d02){const _0x1736a1=_0x5d3107,_0x4475f9=_0x291d02===_0x1736a1(0x202)?getGlobalKnowledgeBases():getLocalKnowledgeBases();_0x4475f9[_0x323e64]&&(_0x4475f9[_0x323e64][_0x1736a1(0x193)]=!_0x4475f9[_0x323e64][_0x1736a1(0x193)],saveSettings(),console['log'](_0x1736a1(0x1ad)+_0x323e64+_0x1736a1(0x22d)+_0x291d02+_0x1736a1(0x189)+(_0x4475f9[_0x323e64][_0x1736a1(0x193)]?'启用':'禁用')));}function generateHash(_0x365832){const _0x5bdce1=_0x5d3107;let _0xee399c=0x0;for(let _0x283dfd=0x0;_0x283dfd<_0x365832['length'];_0x283dfd++){const _0x26fcfe=_0x365832[_0x5bdce1(0x1a8)](_0x283dfd);_0xee399c=(_0xee399c<<0x5)-_0xee399c+_0x26fcfe,_0xee399c=_0xee399c&_0xee399c;}return Math[_0x5bdce1(0x190)](_0xee399c)[_0x5bdce1(0x22c)](0x24);}async function queryVectors(_0x4c28ba){const _0x19aefc=_0x5d3107;console[_0x19aefc(0x1f2)](_0x19aefc(0x1b7));const _0x1716e2=getCharacterStableId(),_0x12b0d2=getLocalKnowledgeBases(),_0x2445a8=getGlobalKnowledgeBases(),_0x2915cb=Object['values'](_0x12b0d2)['filter'](_0x2b5d18=>_0x2b5d18[_0x19aefc(0x193)]),_0x604dc2=Object['values'](_0x2445a8)[_0x19aefc(0x1bc)](_0x3799bc=>_0x3799bc[_0x19aefc(0x193)]),_0x4efe39=[..._0x2915cb[_0x19aefc(0x153)](_0x3a0787=>({..._0x3a0787,'scope':_0x19aefc(0x17a)})),..._0x604dc2[_0x19aefc(0x153)](_0x2e7ea4=>({..._0x2e7ea4,'scope':_0x19aefc(0x202)}))];if(_0x4efe39[_0x19aefc(0x168)]===0x0){console[_0x19aefc(0x1f2)](_0x19aefc(0x1f8));const _0x110c39=await _0x5bd7f2();if(!_0x110c39)return[];_0x4efe39['push']({'id':null,'name':_0x19aefc(0x21a),'scope':'legacy'});}const _0x5d77aa=(await getEmbeddings([_0x4c28ba]))[0x0];let _0x42f87a=[];const _0x5662e2=_0x4efe39[_0x19aefc(0x153)](_0x295846=>{const _0x10ca51=_0x19aefc;let _0x53cf2f;if(_0x295846[_0x10ca51(0x236)]===_0x10ca51(0x206))_0x53cf2f=_0x5bd7f2();else{const _0x36cec8=_0x295846[_0x10ca51(0x236)]===_0x10ca51(0x202)?_0x295846[_0x10ca51(0x1ac)]||GLOBAL_SCOPE_ID:_0x1716e2;_0x53cf2f=Promise[_0x10ca51(0x1c6)](_0x36cec8+'_'+_0x295846['id']);}return _0x53cf2f[_0x10ca51(0x1af)](_0x528db6=>{const _0x4fc1bf=_0x10ca51;if(!_0x528db6)return[];console[_0x4fc1bf(0x1f2)]('[翰林院-日志]\x20正在查询知识库:\x20'+_0x295846[_0x4fc1bf(0x19d)]+'\x20(ID:\x20'+_0x528db6+')');const _0xd0e110={'collectionId':_0x528db6,'searchText':_0x4c28ba,'topK':settings[_0x4fc1bf(0x247)][_0x4fc1bf(0x145)],'threshold':settings[_0x4fc1bf(0x247)][_0x4fc1bf(0x150)],'source':_0x4fc1bf(0x184),'embeddings':{[_0x4c28ba]:_0x5d77aa}};return fetch(_0x4fc1bf(0x1b8),{'method':_0x4fc1bf(0x151),'headers':context[_0x4fc1bf(0x15a)](),'body':JSON[_0x4fc1bf(0x239)](_0xd0e110)})[_0x4fc1bf(0x1af)](async _0x532ec4=>{const _0x49c853=_0x4fc1bf;if(!_0x532ec4['ok']){const _0x26465f=await _0x532ec4[_0x49c853(0x15d)]();return console[_0x49c853(0x164)]('[翰林院-日志]\x20查询知识库\x20'+_0x528db6+_0x49c853(0x1e2),_0x26465f),[];}const _0x40217c=await _0x532ec4[_0x49c853(0x182)]();let _0x1ec3e0=[];if(Array[_0x49c853(0x1b4)](_0x40217c))_0x1ec3e0=_0x40217c;else{if(_0x40217c&&_0x40217c[_0x49c853(0x20b)]&&Array['isArray'](_0x40217c[_0x49c853(0x20b)]))_0x1ec3e0=_0x40217c[_0x49c853(0x20b)];else{if(_0x40217c&&_0x40217c[_0x49c853(0x1aa)]&&Array['isArray'](_0x40217c[_0x49c853(0x1aa)]))_0x1ec3e0=_0x40217c[_0x49c853(0x1aa)];else _0x40217c&&_0x40217c[_0x49c853(0x16c)]&&Array['isArray'](_0x40217c[_0x49c853(0x16c)])&&(_0x1ec3e0=_0x40217c[_0x49c853(0x16c)]);}}const _0x461fba=_0x1ec3e0[_0x49c853(0x153)](_0x18c928=>{const _0x18e7ee=_0x49c853;if(!_0x18c928||typeof _0x18c928[_0x18e7ee(0x15d)]!=='string')return null;const _0x1f79b1={'source':'unknown','sourceName':'未知'},_0x2a5849=_0x18c928[_0x18e7ee(0x15d)][_0x18e7ee(0x1f4)](/^<([^>]+)>/),_0x306743=_0x2a5849?_0x2a5849[0x1]:'';switch(_0x306743){case _0x18e7ee(0x1cd):_0x1f79b1['source']=_0x18e7ee(0x1e0);const _0x7d058a=_0x18c928[_0x18e7ee(0x15d)][_0x18e7ee(0x1f4)](/楼层:\s*#(\d+)/);_0x7d058a&&_0x7d058a[0x1]&&(_0x1f79b1[_0x18e7ee(0x17d)]=parseInt(_0x7d058a[0x1],0xa),_0x1f79b1[_0x18e7ee(0x1e8)]=_0x18e7ee(0x20e)+_0x1f79b1[_0x18e7ee(0x17d)]);break;case _0x18e7ee(0x224):_0x1f79b1[_0x18e7ee(0x175)]=_0x18e7ee(0x191);const _0x36fb12=_0x18c928[_0x18e7ee(0x15d)][_0x18e7ee(0x1f4)](/条目:\s*([^,\]]+)/);_0x36fb12&&_0x36fb12[0x1]&&(_0x1f79b1[_0x18e7ee(0x1e8)]=_0x36fb12[0x1][_0x18e7ee(0x171)]());break;case _0x18e7ee(0x1e9):_0x1f79b1[_0x18e7ee(0x175)]='manual';const _0xf9e040=_0x18c928['text']['match'](/\[来源:\s*([^,\]]+)/);_0xf9e040&&_0xf9e040[0x1]&&(_0x1f79b1[_0x18e7ee(0x1e8)]=_0xf9e040[0x1][_0x18e7ee(0x171)]());break;case'小说录入':_0x1f79b1[_0x18e7ee(0x175)]=_0x18e7ee(0x18a);const _0x40deb7=_0x18c928['text'][_0x18e7ee(0x1f4)](/\[来源:\s*([^,]+),\s*([^,]+),\s*([^,]+),\s*([^\]]+)\]/);_0x40deb7&&(_0x1f79b1['sourceName']=_0x40deb7[0x1][_0x18e7ee(0x171)](),_0x1f79b1[_0x18e7ee(0x1ff)]=_0x40deb7[0x2]['trim'](),_0x1f79b1[_0x18e7ee(0x162)]=_0x40deb7[0x3]['trim'](),_0x1f79b1[_0x18e7ee(0x1d4)]=_0x40deb7[0x4][_0x18e7ee(0x171)]());break;}return{..._0x18c928,'score':_0x18c928[_0x18e7ee(0x140)]||0x1,'metadata':_0x1f79b1};})['filter'](Boolean);return console[_0x49c853(0x1f2)]('[翰林院-V13\x20修复]\x20重建元数据后知识库\x20'+_0x295846['name']+_0x49c853(0x181)+_0x461fba[_0x49c853(0x168)]+_0x49c853(0x18b)),_0x461fba;})['catch'](_0x29e71d=>{const _0x5d8128=_0x4fc1bf;return console[_0x5d8128(0x164)](_0x5d8128(0x23c)+_0x528db6+_0x5d8128(0x231),_0x29e71d),[];});});}),_0x4b462c=await Promise['all'](_0x5662e2);_0x42f87a=_0x4b462c[_0x19aefc(0x1ef)](),console[_0x19aefc(0x1f2)](_0x19aefc(0x1b3)+_0x42f87a[_0x19aefc(0x168)]+_0x19aefc(0x219));const _0x29b81e=[],_0x3ba35b=new Set();for(const _0x2c4d79 of _0x42f87a){if(_0x2c4d79&&typeof _0x2c4d79===_0x19aefc(0x1c9)&&_0x2c4d79[_0x19aefc(0x15d)]&&typeof _0x2c4d79[_0x19aefc(0x15d)]===_0x19aefc(0x21b)){const _0x291b8=_0x2c4d79['text'][_0x19aefc(0x171)]();_0x291b8[_0x19aefc(0x168)]>0x0&&!_0x3ba35b[_0x19aefc(0x147)](_0x291b8)&&(_0x3ba35b[_0x19aefc(0x19c)](_0x291b8),_0x29b81e[_0x19aefc(0x1bb)](_0x2c4d79));}}console[_0x19aefc(0x1f2)](_0x19aefc(0x21d)+_0x29b81e[_0x19aefc(0x168)]+_0x19aefc(0x18b)),_0x29b81e[_0x19aefc(0x1a5)]((_0x1c79c2,_0x12f88d)=>(_0x12f88d[_0x19aefc(0x140)]||0x0)-(_0x1c79c2[_0x19aefc(0x140)]||0x0));const _0x1fddf6=[..._0x29b81e];return console[_0x19aefc(0x1f2)](_0x19aefc(0x240)+_0x1fddf6[_0x19aefc(0x168)]),console[_0x19aefc(0x1f2)](_0x19aefc(0x198),JSON['stringify'](_0x1fddf6[_0x19aefc(0x228)](0x0,0x1),null,0x2)),_0x1fddf6;}async function insertVectors(_0x245b69,_0x18bfd5=null,_0x2dc10c){const _0x39869a=_0x5d3107;if(!_0x2dc10c)throw new Error('insertVectors\x20必须接收一个有效的\x20collectionId\x20参数。');if(_0x245b69['length']===0x0)return{'success':!![],'count':0x0};const _0x1c8832=_0x245b69[_0x39869a(0x153)]((_0x5ad5a6,_0x20a6f3)=>({'hash':generateHash(_0x5ad5a6[_0x39869a(0x15d)]+Date[_0x39869a(0x17b)]()+_0x20a6f3),'text':_0x5ad5a6['text'],'metadata':_0x5ad5a6[_0x39869a(0x20b)]||{'source':'unknown','timestamp':new Date()['toISOString']()}})),_0x205296=_0x1c8832['reduce']((_0x648a31,_0x4760e3,_0x5301f3)=>{const _0x1b9085=_0x39869a;return _0x648a31[_0x4760e3[_0x1b9085(0x15d)]]=_0x245b69[_0x5301f3][_0x1b9085(0x1b2)],_0x648a31;},{}),_0x55cf61={'collectionId':_0x2dc10c,'items':_0x1c8832,'source':_0x39869a(0x184),'embeddings':_0x205296},_0xd7e13c=await fetch(_0x39869a(0x1ea),{'method':_0x39869a(0x151),'headers':context[_0x39869a(0x15a)](),'body':JSON[_0x39869a(0x239)](_0x55cf61),'signal':_0x18bfd5});if(!_0xd7e13c['ok']){const _0x44dd48=await _0xd7e13c[_0x39869a(0x15d)]();console['error'](_0x39869a(0x14e),_0x44dd48);throw new Error(_0x39869a(0x1ae)+_0xd7e13c[_0x39869a(0x1f5)]+':\x20'+_0x44dd48);}return{'success':!![],'count':_0x1c8832['length']};}async function getVectorCount(_0x4586de=null,_0x268f5b=_0x5d3107(0x17a)){const _0x304fe0=_0x5d3107,_0x3f7f2b=getCharacterStableId();if(_0x4586de){const _0x5c1e4a=_0x268f5b===_0x304fe0(0x202)?getGlobalKnowledgeBases():getLocalKnowledgeBases(),_0x34e64b=_0x5c1e4a[_0x4586de];if(!_0x34e64b)return console[_0x304fe0(0x16a)](_0x304fe0(0x17f)+_0x268f5b+_0x304fe0(0x1fe)+_0x4586de+'\x20的知识库。'),0x0;const _0x371a66=_0x268f5b===_0x304fe0(0x202)?_0x34e64b[_0x304fe0(0x1ac)]||GLOBAL_SCOPE_ID:_0x3f7f2b,_0x2a1bd9=_0x371a66+'_'+_0x4586de;return await countVectorsInCollection(_0x2a1bd9);}else{console[_0x304fe0(0x1f2)]('[翰林院-日志]\x20开始获取所有知识库的向量总数...');const _0x4175fa=Object['values'](getLocalKnowledgeBases()),_0x43313b=Object[_0x304fe0(0x15b)](getGlobalKnowledgeBases()),_0x30bc79=[];_0x4175fa['forEach'](_0x1c56d5=>{const _0x44170d=_0x304fe0,_0x2fb9bc=_0x3f7f2b+'_'+_0x1c56d5['id'];_0x30bc79[_0x44170d(0x1bb)](countVectorsInCollection(_0x2fb9bc));}),_0x43313b[_0x304fe0(0x1e7)](_0x165016=>{const _0x3d4727=_0x304fe0,_0x363a56=_0x165016[_0x3d4727(0x1ac)]||GLOBAL_SCOPE_ID,_0xc988=_0x363a56+'_'+_0x165016['id'];_0x30bc79[_0x3d4727(0x1bb)](countVectorsInCollection(_0xc988));});const _0x20b64e=await _0x5bd7f2();_0x30bc79[_0x304fe0(0x1bb)](countVectorsInCollection(_0x20b64e));const _0x577509=await Promise[_0x304fe0(0x143)](_0x30bc79),_0x54168a=_0x577509[_0x304fe0(0x1b5)]((_0x1f7242,_0x53405a)=>_0x1f7242+_0x53405a,0x0);return console[_0x304fe0(0x1f2)](_0x304fe0(0x148)+_0x54168a),_0x54168a;}}async function countVectorsInCollection(_0x5b24aa){const _0x510448=_0x5d3107;if(!_0x5b24aa)return 0x0;console[_0x510448(0x1f2)](_0x510448(0x1d5)+_0x5b24aa);const _0x567c2a={'collectionId':_0x5b24aa,'source':_0x510448(0x184),'embeddings':{}};try{const _0x32dc62=await fetch(_0x510448(0x1dc),{'method':_0x510448(0x151),'headers':context['getRequestHeaders'](),'body':JSON['stringify'](_0x567c2a)});if(!_0x32dc62['ok']){if(_0x32dc62[_0x510448(0x1f5)]===0x194)console['log'](_0x510448(0x157)+_0x5b24aa+_0x510448(0x1c0));else{const _0xab9aa2=await _0x32dc62[_0x510448(0x15d)]();console['warn'](_0x510448(0x209)+_0x5b24aa+'\x20列表API时出现问题\x20(状态:\x20'+_0x32dc62[_0x510448(0x1f5)]+'):',_0xab9aa2);}return 0x0;}const _0x2a9a5f=await _0x32dc62[_0x510448(0x182)]();let _0x4769b5=0x0;if(Array[_0x510448(0x1b4)](_0x2a9a5f))_0x4769b5=_0x2a9a5f[_0x510448(0x168)];else _0x2a9a5f&&_0x2a9a5f['hashes']&&(_0x4769b5=_0x2a9a5f[_0x510448(0x1c3)][_0x510448(0x168)]);return _0x4769b5;}catch(_0x136254){return console[_0x510448(0x164)](_0x510448(0x177)+_0x5b24aa+_0x510448(0x231),_0x136254),0x0;}}async function purgeStorage(_0xef88c5=null){const _0xf9fac=_0x5d3107;console[_0xf9fac(0x1f2)](_0xf9fac(0x16e));const _0x139e32=_0xef88c5||await getCollectionId();if(!_0x139e32)return console[_0xf9fac(0x164)](_0xf9fac(0x188)),toastr['error']('无法确定要清空的目标宝库。'),![];console[_0xf9fac(0x1f2)](_0xf9fac(0x187)+_0x139e32);const _0x898cf5={'collectionId':_0x139e32};console[_0xf9fac(0x1f2)]('[翰林院-日志]\x20发送到\x20/api/vector/purge\x20的请求体:',JSON[_0xf9fac(0x239)](_0x898cf5,null,0x2));const _0x23806d=await fetch('/api/vector/purge',{'method':_0xf9fac(0x151),'headers':context[_0xf9fac(0x15a)](),'body':JSON['stringify'](_0x898cf5)});console[_0xf9fac(0x1f2)](_0xf9fac(0x1d8)+_0x23806d[_0xf9fac(0x1f5)]);if(!_0x23806d['ok']){const _0x29c7a7=await _0x23806d[_0xf9fac(0x15d)]();console[_0xf9fac(0x164)]('[翰林院-日志]\x20清空宝库API错误:',_0x29c7a7);}else console[_0xf9fac(0x1f2)]('[翰林院-日志]\x20清空宝库API调用成功。');return _0x23806d['ok'];}function getMessagesForCondensation(_0x521cc8=null){const _0x32e3f8=_0x5d3107;if(!settings[_0x32e3f8(0x1e1)][_0x32e3f8(0x193)])return showNotification(_0x32e3f8(0x199),'warning'),[];const {layerStart:_0x45e5ab,layerEnd:_0x23cb9f}=settings['condensation'],_0x18bbcb=_0x521cc8||settings[_0x32e3f8(0x1e1)][_0x32e3f8(0x237)],_0x5df843=context[_0x32e3f8(0x249)][_0x32e3f8(0x168)],_0x7c600c=Math[_0x32e3f8(0x18c)](0x0,_0x45e5ab-0x1),_0x5a0a45=_0x23cb9f===0x0||_0x23cb9f>_0x5df843?_0x5df843:Math['min'](_0x5df843,_0x23cb9f),_0x29b196=context[_0x32e3f8(0x249)][_0x32e3f8(0x228)](_0x7c600c,_0x5a0a45);return _0x29b196[_0x32e3f8(0x1bc)](_0x190f31=>{const _0x2fce62=_0x32e3f8,_0x2c91f0=_0x190f31['is_user']===!![],_0x57a148=_0x190f31[_0x2fce62(0x207)]===![];if(!_0x190f31[_0x2fce62(0x23e)]||!_0x190f31['mes'][_0x2fce62(0x171)]())return![];return _0x18bbcb[_0x2fce62(0x165)]&&_0x2c91f0||_0x18bbcb['ai']&&_0x57a148;});}async function processCondensation(_0x25d71d,_0x4da27f=()=>{},_0x4fa2c5=null){const _0x39a674=_0x5d3107;if(!_0x25d71d||_0x25d71d['length']===0x0)return{'success':![],'error':_0x39a674(0x215)};try{let _0x1b79fb,_0x18324a;const _0x4cff7f=getCharacterName()||_0x39a674(0x1dd);if(_0x4fa2c5){const _0x1c49b0=_0x4fa2c5[_0x39a674(0x1a6)]??'?',_0x2180f1=_0x4fa2c5[_0x39a674(0x1ce)]===0x0?'末':_0x4fa2c5[_0x39a674(0x1ce)]??'?';_0x1b79fb=_0x4cff7f+':\x20'+_0x1c49b0+'楼-'+_0x2180f1+'楼';}else{const _0x5246dd=new Date()[_0x39a674(0x1a0)]('zh-CN',{'hour12':![]});_0x1b79fb=_0x39a674(0x1b0)+_0x5246dd;}const _0x56821a=Object[_0x39a674(0x15b)](getLocalKnowledgeBases()),_0x5869ba=_0x56821a[_0x39a674(0x197)](_0x39fd5b=>_0x39fd5b['name']===_0x1b79fb);if(_0x5869ba)_0x18324a=_0x5869ba['id'],_0x4da27f('[翰林院-核心]\x20检测到同名知识库\x20\x22'+_0x1b79fb+'\x22将数据合并入库。',_0x39a674(0x149));else{_0x4da27f(_0x39a674(0x1b6)+_0x1b79fb+_0x39a674(0x1a3),'info');const _0x29a75b=addKnowledgeBase(_0x1b79fb);_0x18324a=_0x29a75b['id'];}const _0x27d842=getCharacterStableId(),_0x420ae0=_0x27d842+'_'+_0x18324a;_0x4da27f(_0x39a674(0x203)+_0x1b79fb+_0x39a674(0x1a2)+_0x420ae0+')',_0x39a674(0x1f1));const _0x3ad4c3=[],_0x2eefb4=context[_0x39a674(0x249)];for(const _0x51eec4 of _0x25d71d){const _0x33068e=(_0x51eec4[_0x39a674(0x23e)]||'')['replace'](/<[^>]*>/g,'')[_0x39a674(0x171)]();if(_0x33068e[_0x39a674(0x168)]===0x0)continue;let _0xfef282;if(_0x51eec4['floor']!==undefined&&_0x51eec4['floor']!==null)_0xfef282=_0x51eec4['floor'];else{const _0x2f5f75=_0x2eefb4[_0x39a674(0x16d)](_0x63bb6e=>_0x63bb6e===_0x51eec4);_0xfef282=_0x2f5f75!==-0x1?_0x2f5f75+0x1:-0x1;}const _0x374aaa=new Date(_0x51eec4[_0x39a674(0x172)]),_0x1dd0fc=isNaN(_0x374aaa[_0x39a674(0x155)]())?new Date()[_0x39a674(0x1ec)]():_0x374aaa[_0x39a674(0x1ec)](),_0x378c96=splitIntoChunks(_0x33068e,_0x39a674(0x1e0),{'floor':_0xfef282,'is_user':_0x51eec4['is_user'],'timestamp':_0x1dd0fc});_0x3ad4c3['push'](..._0x378c96);}if(_0x3ad4c3['length']===0x0)return{'success':!![],'count':0x0};_0x4da27f(_0x39a674(0x210)+_0x25d71d[_0x39a674(0x168)]+_0x39a674(0x183)+_0x3ad4c3[_0x39a674(0x168)]+'\x20个知识块准备入库。',_0x39a674(0x149));const _0x27ca25=settings[_0x39a674(0x1d3)][_0x39a674(0x1ab)]||0x5;let _0x44184b=0x0;for(let _0x26d9cc=0x0;_0x26d9cc<_0x3ad4c3[_0x39a674(0x168)];_0x26d9cc+=_0x27ca25){const _0x245069=_0x3ad4c3[_0x39a674(0x228)](_0x26d9cc,_0x26d9cc+_0x27ca25),_0x3f5252=_0x245069[_0x39a674(0x153)](_0xcd0638=>_0xcd0638[_0x39a674(0x15d)]),_0x4250a6=await getEmbeddings(_0x3f5252);if(_0x245069[_0x39a674(0x168)]!==_0x4250a6[_0x39a674(0x168)])throw new Error(_0x39a674(0x178));const _0x18ad1b=_0x245069[_0x39a674(0x153)]((_0x5e4d4d,_0x523497)=>({..._0x5e4d4d,'vector':_0x4250a6[_0x523497]}));await insertVectors(_0x18ad1b,null,_0x420ae0),_0x44184b+=_0x245069[_0x39a674(0x168)];}if(_0x4fa2c5){const _0x45f1f6=_0x4fa2c5[_0x39a674(0x1ce)]===0x0?context[_0x39a674(0x249)][_0x39a674(0x168)]:_0x4fa2c5['end'],_0x1a2e5b=getCharacterStableId();!settings[_0x39a674(0x1cc)][_0x1a2e5b]&&(settings[_0x39a674(0x1cc)][_0x1a2e5b]={}),settings[_0x39a674(0x1cc)][_0x1a2e5b][_0x420ae0]={'start':_0x4fa2c5['start'],'end':_0x45f1f6,'timestamp':new Date()[_0x39a674(0x1ec)]()},saveSettings(),_0x4da27f(_0x39a674(0x1a9)+_0x420ae0+'\x20记录凝识范围:\x20'+_0x4fa2c5[_0x39a674(0x1a6)]+'-'+_0x45f1f6,_0x39a674(0x149));}_0x4da27f(_0x39a674(0x14b)+_0x44184b+_0x39a674(0x201),_0x39a674(0x1f1));const _0x14e5ac=_0x25d71d[_0x39a674(0x153)](_0x49d7d8=>{const _0x59427=_0x39a674,_0x314bdd=_0x2eefb4['findIndex'](_0x5025d4=>_0x5025d4===_0x49d7d8),_0xa0d5d4=_0x314bdd!==-0x1?_0x314bdd+0x1:-0x1,_0x371e0f=_0x49d7d8['is_user']?'用户':getCharacterName()||'AI';return'['+_0x371e0f+_0x59427(0x1c4)+_0xa0d5d4+_0x59427(0x1f9);});return{'success':!![],'count':_0x44184b,'messages':_0x14e5ac};}catch(_0x5042c0){return console[_0x39a674(0x164)]('[翰林院-核心]\x20processCondensation\x20失败:',_0x5042c0),_0x4da27f(_0x39a674(0x17e)+_0x5042c0[_0x39a674(0x19a)],_0x39a674(0x164)),{'success':![],'error':_0x5042c0['message']};}}async function rerankResults(_0x246c77,_0x51b175,_0x49fcc7){const _0x2ce6cb=_0x5d3107;let _0x1572a6=_0x246c77;if(_0x49fcc7['rerank'][_0x2ce6cb(0x193)]&&_0x246c77[_0x2ce6cb(0x168)]>0x0){console[_0x2ce6cb(0x1f2)](_0x2ce6cb(0x169));try{const _0x461710=_0x246c77[_0x2ce6cb(0x153)](_0x3a3fbf=>_0x3a3fbf[_0x2ce6cb(0x15d)]),_0x4dda62=await executeRerank(_0x51b175,_0x461710,_0x49fcc7['rerank']),_0x4bc00f=_0x246c77[_0x2ce6cb(0x153)]((_0x3f129c,_0x2f27c2)=>({..._0x3f129c,'original_index':_0x2f27c2}));_0x1572a6=_0x4bc00f[_0x2ce6cb(0x153)](_0x1fa20b=>{const _0x1d5cfe=_0x2ce6cb,_0x433b06=_0x4dda62[_0x1d5cfe(0x1aa)]['find'](_0x221c9a=>_0x221c9a[_0x1d5cfe(0x1b1)]===_0x1fa20b['original_index']),_0x470dc2=_0x433b06?_0x433b06[_0x1d5cfe(0x1d7)]:0x0;return{..._0x1fa20b,'rerank_score':_0x470dc2};});if(_0x49fcc7[_0x2ce6cb(0x200)][_0x2ce6cb(0x160)])showNotification('外部Rerank完成',_0x2ce6cb(0x1f1));}catch(_0x87586a){console['error'](_0x2ce6cb(0x1e5),_0x87586a);if(_0x49fcc7[_0x2ce6cb(0x200)][_0x2ce6cb(0x160)])showNotification('Rerank失败:\x20'+_0x87586a[_0x2ce6cb(0x19a)],'error');_0x1572a6[_0x2ce6cb(0x1e7)](_0xeabf66=>_0xeabf66[_0x2ce6cb(0x223)]=0x0);}}else _0x1572a6['forEach'](_0x5adf20=>_0x5adf20[_0x2ce6cb(0x223)]=0x0);console[_0x2ce6cb(0x1f2)](_0x2ce6cb(0x1d0));const _0x5331b8=context[_0x2ce6cb(0x249)]['length'],_0x45c969=_0x49fcc7[_0x2ce6cb(0x200)][_0x2ce6cb(0x24a)],_0xa868da=_0x1572a6[_0x2ce6cb(0x153)](_0x121d01=>{const _0x4a3d8d=_0x2ce6cb;let _0x244c38=0x1;const _0x124f68=_0x121d01[_0x4a3d8d(0x20b)]||{};switch(_0x124f68['source']){case _0x4a3d8d(0x191):_0x244c38*=1.2;break;case _0x4a3d8d(0x161):_0x244c38*=1.1;break;case'chat_history':if(_0x124f68[_0x4a3d8d(0x17d)]&&_0x5331b8>0x0){const _0x594730=_0x124f68[_0x4a3d8d(0x17d)]/_0x5331b8;_0x244c38*=0x1+_0x594730;}break;}const _0x41826c=_0x121d01[_0x4a3d8d(0x223)]*_0x45c969+(_0x121d01[_0x4a3d8d(0x140)]||0x0)*(0x1-_0x45c969),_0x2ccb05=_0x41826c*_0x244c38;return{'text':_0x121d01['text'],'score':_0x121d01['score'],'rerank_score':_0x121d01[_0x4a3d8d(0x223)],'final_score':_0x2ccb05,'metadata':_0x121d01[_0x4a3d8d(0x20b)]};});return _0xa868da[_0x2ce6cb(0x1a5)]((_0x1aea69,_0x20114d)=>(_0x20114d['final_score']||0x0)-(_0x1aea69[_0x2ce6cb(0x1ee)]||0x0)),console[_0x2ce6cb(0x1f2)](_0x2ce6cb(0x227)),_0xa868da[_0x2ce6cb(0x228)](0x0,_0x49fcc7['rerank'][_0x2ce6cb(0x186)]);}async function rearrangeChat(_0x3f3d2f,_0x22371d,_0x5c3d24,_0x4f2eb6){const _0x1615a1=_0x5d3107,_0x2fe77c={'novel':_0x1615a1(0x185),'chat_history':_0x1615a1(0x22a),'lorebook':_0x1615a1(0x204),'manual':_0x1615a1(0x166)};Object[_0x1615a1(0x15b)](_0x2fe77c)[_0x1615a1(0x1e7)](_0x49507a=>{setExtensionPrompt(_0x49507a,'',0x0,0x0,![],0x0);});if(_0x4f2eb6===_0x1615a1(0x244)||!settings[_0x1615a1(0x1d3)][_0x1615a1(0x193)])return;const _0xa1e659=_0x3f3d2f[_0x1615a1(0x228)](-settings['advanced'][_0x1615a1(0x24b)]);if(_0xa1e659[_0x1615a1(0x168)]===0x0)return;const _0x35e9ef=_0xa1e659[_0x1615a1(0x153)](_0x1b9fd5=>_0x1b9fd5[_0x1615a1(0x23e)])[_0x1615a1(0x1df)]('\x20')[_0x1615a1(0x1fa)](/<[^>]*>/g,'')[_0x1615a1(0x171)]();if(!_0x35e9ef)return;try{const _0x433cd4=await queryVectors(_0x35e9ef);console['log'](_0x1615a1(0x196),JSON[_0x1615a1(0x239)](_0x433cd4[_0x1615a1(0x153)](_0x42c190=>_0x42c190[_0x1615a1(0x20b)]),null,0x2));if(_0x433cd4[_0x1615a1(0x168)]===0x0)return;const _0x1660ca=await rerankResults(_0x433cd4,_0x35e9ef,settings);if(_0x1660ca[_0x1615a1(0x168)]===0x0)return;console[_0x1615a1(0x1f2)](_0x1615a1(0x18f),JSON['stringify'](_0x1660ca[_0x1615a1(0x153)](_0x113fef=>_0x113fef[_0x1615a1(0x20b)]),null,0x2));const _0x437750={'novel':[],'chat_history':[],'lorebook':[],'manual':[]};_0x1660ca[_0x1615a1(0x1e7)](_0xdd69b3=>{const _0x280bd8=_0x1615a1,_0x5a66ce=_0xdd69b3['metadata']?.[_0x280bd8(0x175)];_0x5a66ce&&_0x437750[_0x280bd8(0x1bf)](_0x5a66ce)&&_0x437750[_0x5a66ce][_0x280bd8(0x1bb)](_0xdd69b3);}),console['log'](_0x1615a1(0x226),JSON[_0x1615a1(0x239)](Object['keys'](_0x437750)['reduce']((_0x10490d,_0x2215f6)=>{const _0xb2e890=_0x1615a1;return _0x10490d[_0x2215f6]=_0x437750[_0x2215f6][_0xb2e890(0x168)],_0x10490d;},{}),null,0x2));for(const _0x7ff579 in _0x437750){const _0x5f8dc4=_0x437750[_0x7ff579];if(_0x5f8dc4[_0x1615a1(0x168)]===0x0)continue;const _0x4a6375=settings[_0x1615a1(0x15e)+_0x7ff579['replace']('_history','')];if(!_0x4a6375){console['warn']('[翰林院]\x20未找到来源\x20\x27'+_0x7ff579+_0x1615a1(0x1cf));continue;}const _0x2e1546=_0x5f8dc4[_0x1615a1(0x153)](_0x3268b3=>_0x3268b3[_0x1615a1(0x15d)])[_0x1615a1(0x1df)]('\x0a\x0a'),_0x731ca9='{{'+_0x7ff579[_0x1615a1(0x1fa)](_0x1615a1(0x1fd),'')+'_text}}';let _0x4072b=_0x4a6375[_0x1615a1(0x1f6)][_0x1615a1(0x1fa)](_0x731ca9,_0x2e1546);_0x4072b[_0x1615a1(0x171)]()&&(_0x4072b='%%'+_0x2fe77c[_0x7ff579]+'%%'+_0x4072b),setExtensionPrompt(_0x2fe77c[_0x7ff579],_0x4072b,_0x4a6375['position'],_0x4a6375[_0x1615a1(0x205)],![],_0x4a6375[_0x1615a1(0x14d)]),console['log']('[翰林院]\x20已为来源\x20\x27'+_0x7ff579+_0x1615a1(0x1da)+_0x5f8dc4[_0x1615a1(0x168)]+_0x1615a1(0x233));}}catch(_0x463c88){console[_0x1615a1(0x164)](_0x1615a1(0x220),_0x463c88);if(settings[_0x1615a1(0x1d3)]['notify'])showNotification(_0x1615a1(0x214)+_0x463c88[_0x1615a1(0x19a)],_0x1615a1(0x164));}}async function moveKnowledgeBase(_0x43a7d3,_0x3c1849){const _0xfaaff8=_0x5d3107,_0x469b79=_0x3c1849===_0xfaaff8(0x202)?_0xfaaff8(0x17a):_0xfaaff8(0x202),_0x4d2a75=getCharacterStableId();if(!_0x4d2a75&&_0x469b79===_0xfaaff8(0x17a)){toastr[_0xfaaff8(0x164)](_0xfaaff8(0x24c));return;}const _0x11f8ca=_0x3c1849===_0xfaaff8(0x202)?getGlobalKnowledgeBases():getLocalKnowledgeBases(),_0x5627e2=_0x469b79===_0xfaaff8(0x202)?getGlobalKnowledgeBases():getLocalKnowledgeBases(),_0x9cb586=_0x11f8ca[_0x43a7d3];if(!_0x9cb586){const _0x34629d=_0xfaaff8(0x216)+_0x3c1849+_0xfaaff8(0x1fe)+_0x43a7d3+_0xfaaff8(0x20d);console[_0xfaaff8(0x164)](_0xfaaff8(0x18e)+_0x34629d),toastr[_0xfaaff8(0x164)](_0xfaaff8(0x152));return;}_0x3c1849===_0xfaaff8(0x17a)&&_0x469b79===_0xfaaff8(0x202)&&!_0x9cb586[_0xfaaff8(0x1ac)]&&(console[_0xfaaff8(0x1f2)](_0xfaaff8(0x222)+_0x43a7d3+_0xfaaff8(0x23d)+_0x4d2a75),_0x9cb586['owner']=_0x4d2a75);delete _0x11f8ca[_0x43a7d3],_0x5627e2[_0x43a7d3]=_0x9cb586,saveSettings();const _0x52970d=_0xfaaff8(0x22f)+_0x9cb586[_0xfaaff8(0x19d)]+_0xfaaff8(0x1c5)+(_0x469b79===_0xfaaff8(0x202)?'全局':'局部')+'。';console[_0xfaaff8(0x1f2)](_0xfaaff8(0x18e)+_0x52970d);}async function getAllVectorsFromCollection(_0x3d76d1){const _0x3a9709=_0x5d3107,_0x56c26c='*',_0x504ad7={'collectionId':_0x3d76d1,'searchText':_0x56c26c,'topK':0x2710,'threshold':0x0,'source':'webllm','embeddings':{}},_0x4aeba4=(await getEmbeddings([_0x56c26c]))[0x0];_0x504ad7[_0x3a9709(0x1a1)]={[_0x56c26c]:_0x4aeba4};const _0x4275f5=await fetch(_0x3a9709(0x1b8),{'method':_0x3a9709(0x151),'headers':context['getRequestHeaders'](),'body':JSON[_0x3a9709(0x239)](_0x504ad7)});if(!_0x4275f5['ok']){if(_0x4275f5['status']===0x194)return console[_0x3a9709(0x1f2)](_0x3a9709(0x17c)+_0x3d76d1+'\x20不存在返回空数组。'),[];const _0x4e8025=await _0x4275f5['text']();throw new Error('查询集合\x20'+_0x3d76d1+_0x3a9709(0x192)+_0x4e8025);}const _0x417b42=await _0x4275f5[_0x3a9709(0x182)]();return _0x417b42[_0x3a9709(0x20b)]||_0x417b42[_0x3a9709(0x1aa)]||_0x417b42[_0x3a9709(0x16c)]||[];}