From 3bae551a2ea0f99897673bb7e555daf22f7ea64b Mon Sep 17 00:00:00 2001
From: Wx-2025 <351320169@qq.com>
Date: Tue, 15 Jul 2025 18:09:47 +0800
Subject: [PATCH] Add files via upload
---
core/utils/googleAdapter.js | 1 +
core/utils/pollingManager.js | 1 +
2 files changed, 2 insertions(+)
create mode 100644 core/utils/googleAdapter.js
create mode 100644 core/utils/pollingManager.js
diff --git a/core/utils/googleAdapter.js b/core/utils/googleAdapter.js
new file mode 100644
index 0000000..68e7def
--- /dev/null
+++ b/core/utils/googleAdapter.js
@@ -0,0 +1 @@
+const _0x3f4ada=_0x2937;(function(_0x2cc17,_0x33dd5d){const _0x482709=_0x2937,_0x4520d3=_0x2cc17();while(!![]){try{const _0x1e32d7=parseInt(_0x482709(0x1cf))/0x1*(parseInt(_0x482709(0x1d3))/0x2)+-parseInt(_0x482709(0x1b6))/0x3+-parseInt(_0x482709(0x1d6))/0x4+parseInt(_0x482709(0x1db))/0x5+-parseInt(_0x482709(0x1bc))/0x6+-parseInt(_0x482709(0x1d2))/0x7+parseInt(_0x482709(0x1c9))/0x8*(parseInt(_0x482709(0x1cb))/0x9);if(_0x1e32d7===_0x33dd5d)break;else _0x4520d3['push'](_0x4520d3['shift']());}catch(_0x400ae8){_0x4520d3['push'](_0x4520d3['shift']());}}}(_0x2cba,0xdfa13));const GOOGLE_DOMAINS=['generativelanguage.googleapis.com',_0x3f4ada(0x1b5),_0x3f4ada(0x1d4)];export function isGoogleEndpoint(_0x174bd1){const _0x4a3c85=_0x3f4ada;try{if(!_0x174bd1||typeof _0x174bd1!=='string')return![];const _0xa2ba49=new URL(_0x174bd1)['hostname'][_0x4a3c85(0x1b7)]();return GOOGLE_DOMAINS[_0x4a3c85(0x1ca)](_0x4ab2f6=>_0xa2ba49[_0x4a3c85(0x1bb)](_0x4ab2f6));}catch(_0x2ae0c3){return console[_0x4a3c85(0x1da)]('[GoogleAdapter]\x20URL解析错误:',_0x174bd1,_0x2ae0c3),![];}}export function convertToGoogleRequest(_0x5250f8){const _0x2440e2=_0x3f4ada,{model:_0x1825eb,..._0xcd8a14}=_0x5250f8,_0x15d7c6=_0x5250f8[_0x2440e2(0x1c1)][_0x2440e2(0x1be)](_0x4425f3=>({'role':_0x4425f3['role']==='system'?'user':_0x4425f3[_0x2440e2(0x1c5)],'parts':[{'text':_0x4425f3[_0x2440e2(0x1cc)]}]}));return{'contents':_0x15d7c6,'generationConfig':{'maxOutputTokens':_0x5250f8[_0x2440e2(0x1b0)],'temperature':_0x5250f8[_0x2440e2(0x1ae)]||0.7,'topP':0.95},'safetySettings':[{'category':_0x2440e2(0x1d7),'threshold':'BLOCK_NONE'},{'category':_0x2440e2(0x1dc),'threshold':_0x2440e2(0x1c2)},{'category':_0x2440e2(0x1c0),'threshold':_0x2440e2(0x1c2)},{'category':_0x2440e2(0x1d9),'threshold':_0x2440e2(0x1c2)}]};}function _0x2cba(){const _0x5d7058=['includes','4007268adSBQj','stop','map','\x0a代码:\x20','HARM_CATEGORY_SEXUALLY_EXPLICIT','messages','BLOCK_NONE','[GoogleAdapter]\x20URL构建错误:','code','role',':generateContent','/v1beta/','无效的API地址:\x20','8bHErUG','some','9753723Kjvfwk','content','join','endsWith','1HkJUgf','parts','未知错误','6622686XgFqsO','2673220eAqSuF','us-central1-aiplatform.googleapis.com','Google\x20API错误:\x20','890292KXBFpR','HARM_CATEGORY_HARASSMENT','candidates','HARM_CATEGORY_DANGEROUS_CONTENT','error','3381795KdJCve','HARM_CATEGORY_HATE_SPEECH','temperature','trim','max_tokens','/v1beta','log','[GoogleAdapter]\x20响应解析错误:','pathname','ai.google.dev','1032540NmZSnS','toLowerCase','text','原始Google响应:','href'];_0x2cba=function(){return _0x5d7058;};return _0x2cba();}function _0x2937(_0x3e17d5,_0xd1dd5c){const _0x2cba54=_0x2cba();return _0x2937=function(_0x293754,_0x348ab2){_0x293754=_0x293754-0x1ae;let _0x3cd183=_0x2cba54[_0x293754];return _0x3cd183;},_0x2937(_0x3e17d5,_0xd1dd5c);}export function parseGoogleResponse(_0x4d5bc2){const _0x3a0982=_0x3f4ada;try{if(_0x4d5bc2[_0x3a0982(0x1da)])throw new Error(_0x3a0982(0x1d5)+(_0x4d5bc2[_0x3a0982(0x1da)]['message']||_0x3a0982(0x1d1))+_0x3a0982(0x1bf)+_0x4d5bc2[_0x3a0982(0x1da)][_0x3a0982(0x1c4)]);const _0x1079f=_0x4d5bc2[_0x3a0982(0x1d8)]?.[0x0];if(!_0x1079f||!_0x1079f[_0x3a0982(0x1cc)])throw new Error('无效的Google\x20API响应:\x20未找到候选内容');const _0x23e015=_0x1079f[_0x3a0982(0x1cc)][_0x3a0982(0x1d0)][_0x3a0982(0x1be)](_0x1098fc=>_0x1098fc[_0x3a0982(0x1b8)]||'')[_0x3a0982(0x1cd)]('\x0a')[_0x3a0982(0x1af)]();return{'choices':[{'index':0x0,'message':{'role':'assistant','content':_0x23e015},'finish_reason':_0x1079f['finishReason']||_0x3a0982(0x1bd)}]};}catch(_0x36285f){console[_0x3a0982(0x1da)](_0x3a0982(0x1b3),_0x36285f),console[_0x3a0982(0x1b2)](_0x3a0982(0x1b9),_0x4d5bc2);throw _0x36285f;}}export function buildGoogleApiUrl(_0x476944,_0x1f5d10){const _0x447044=_0x3f4ada;try{const _0xf78d2f=new URL(_0x476944);if(_0xf78d2f[_0x447044(0x1b4)][_0x447044(0x1ce)](_0x447044(0x1b1))||_0xf78d2f[_0x447044(0x1b4)]['endsWith'](_0x447044(0x1c7))){if(!_0x1f5d10)throw new Error('Google\x20API需要模型名称');return _0xf78d2f[_0x447044(0x1b4)]='v1beta/models/'+_0x1f5d10+_0x447044(0x1c6),_0xf78d2f[_0x447044(0x1ba)];}return _0xf78d2f[_0x447044(0x1ba)];}catch(_0x30ccc6){console[_0x447044(0x1da)](_0x447044(0x1c3),_0x476944,_0x1f5d10,_0x30ccc6);throw new Error(_0x447044(0x1c8)+_0x476944);}}
\ No newline at end of file
diff --git a/core/utils/pollingManager.js b/core/utils/pollingManager.js
new file mode 100644
index 0000000..fe06940
--- /dev/null
+++ b/core/utils/pollingManager.js
@@ -0,0 +1 @@
+(function(_0x294e55,_0x2984e3){const _0x5366a6=_0x2073,_0xfcb7a9=_0x294e55();while(!![]){try{const _0x3ad0a0=-parseInt(_0x5366a6(0x197))/0x1*(-parseInt(_0x5366a6(0x1b8))/0x2)+-parseInt(_0x5366a6(0x1c5))/0x3*(-parseInt(_0x5366a6(0x1b5))/0x4)+parseInt(_0x5366a6(0x1a4))/0x5*(parseInt(_0x5366a6(0x188))/0x6)+parseInt(_0x5366a6(0x1b6))/0x7*(-parseInt(_0x5366a6(0x1a7))/0x8)+-parseInt(_0x5366a6(0x196))/0x9+-parseInt(_0x5366a6(0x1c1))/0xa+parseInt(_0x5366a6(0x1b2))/0xb;if(_0x3ad0a0===_0x2984e3)break;else _0xfcb7a9['push'](_0xfcb7a9['shift']());}catch(_0x19f2e4){_0xfcb7a9['push'](_0xfcb7a9['shift']());}}}(_0x49dc,0x9b35a));function _0x2073(_0x48a94f,_0x10a52b){const _0x49dc52=_0x49dc();return _0x2073=function(_0x207356,_0x1c65ae){_0x207356=_0x207356-0x186;let _0x56779f=_0x49dc52[_0x207356];return _0x56779f;},_0x2073(_0x48a94f,_0x10a52b);}function _0x49dc(){const _0x237804=['秒\x20
\x0a\x20\x20\x20\x20\x20\x20\x20\x20用时:\x20','message','一次性尝试','任务处理失败','div','textContent','complete','cssText','status','1655XngFnQ','remove','0.8em','1623344AAsjYS','[轮询超时]\x20','fontSize','pow','无错误详情','\x0a\x20\x20\x20\x20position:\x20fixed;\x0a\x20\x20\x20\x20bottom:\x2020px;\x0a\x20\x20\x20\x20right:\x2020px;\x0a\x20\x20\x20\x20padding:\x2015px;\x0a\x20\x20\x20\x20background:\x20rgba(0,0,0,0.8);\x0a\x20\x20\x20\x20color:\x20white;\x0a\x20\x20\x20\x20border-radius:\x2010px;\x0a\x20\x20\x20\x20z-index:\x2010000;\x0a\x20\x20\x20\x20max-width:\x20300px;\x0a\x20\x20','API请求失败\x20(','round','[轮询错误]','value','progress-info-','1321166FOqaBe','style','错误详情:\x0a','1656676whLPpX','28uRXbbt','red','4YqPRMV','createElement','pre-wrap','text','100%','color','[轮询管理器]\x20','达到最大尝试次数但未完成\x20','轮询任务成功\x20(','3384260hblCIh','display','):\x20','block','6cJvLxA','min','body','20034rrnctu','progress-bar-','innerHTML','0\x200\x2010px\x200','rgba(80,0,0,0.9)','margin','now','\x0a\x20\x20\x20\x20\x20\x20\x20\x20进度:\x20','log','width','progress','polling-progress-','appendChild','次尝试)','7801803PWLBaF','299525blacNC','error','none','\x20
\x0a\x20\x20\x20\x20\x20\x20\x20\x20延迟:\x20'];_0x49dc=function(){return _0x237804;};return _0x49dc();}export async function intelligentPoll(_0xe118ca,_0x3e884d={}){const _0x5c5c09=_0x2073,{maxAttempts:maxAttempts=0x8,baseDelay:baseDelay=0x3e8,shouldStop:shouldStop=_0x249c62=>!!_0x249c62[_0x5c5c09(0x1a1)],onAttempt:onAttempt=(_0x498775,_0x55dd80)=>{},onError:onError=_0x2f8bd9=>console[_0x5c5c09(0x198)](_0x5c5c09(0x1af),_0x2f8bd9[_0x5c5c09(0x19c)])}=_0x3e884d;let _0x1169c5=null;for(let _0x598207=0x1;_0x598207<=maxAttempts;_0x598207++){const _0x48afd8=baseDelay*Math[_0x5c5c09(0x1aa)](0x2,_0x598207-0x1);try{onAttempt(_0x598207,_0x48afd8);_0x598207>0x1&&await new Promise(_0x412f01=>setTimeout(_0x412f01,_0x48afd8));const _0x577b2f=await _0xe118ca();if(shouldStop(_0x577b2f)){const _0x100af9=_0x5c5c09(0x1c0)+(maxAttempts>0x1?_0x598207+'/'+maxAttempts+'次尝试':_0x5c5c09(0x19d))+')';return console[_0x5c5c09(0x190)](_0x5c5c09(0x1be)+_0x100af9),_0x577b2f;}}catch(_0x42bb41){_0x1169c5=_0x42bb41,onError(_0x42bb41,_0x598207);if(_0x598207===maxAttempts)break;}}const _0x58d485=maxAttempts>0x1?'('+maxAttempts+_0x5c5c09(0x195):'',_0x213932=_0x1169c5?_0x1169c5[_0x5c5c09(0x19c)]+'\x20'+_0x58d485:_0x5c5c09(0x1bf)+_0x58d485;throw new Error(_0x5c5c09(0x1a8)+_0x213932);}export function createGooglePollingTask(_0x219080,_0x1b403e,_0x2adf47){return async()=>{const _0x154315=_0x2073,_0x32f92d=_0x1b403e+'/operations/'+_0x219080,_0x40541d=await fetch(_0x32f92d,{'method':'GET','headers':_0x2adf47});if(!_0x40541d['ok']){const _0x169bfe=await _0x40541d[_0x154315(0x1bb)]();throw new Error(_0x154315(0x1ad)+_0x40541d[_0x154315(0x1a3)]+_0x154315(0x1c3)+(_0x169bfe||_0x154315(0x1ab)));}return _0x40541d['json']();};}export function progressTracker(_0x1bf589,_0x389951){const _0x521dd7=_0x2073,_0x387510=Date[_0x521dd7(0x18e)]();let _0x3c5be9=0x0;const _0x533b92=document[_0x521dd7(0x1b9)](_0x521dd7(0x19f));_0x533b92['id']=_0x521dd7(0x193)+_0x1bf589,_0x533b92[_0x521dd7(0x1b3)][_0x521dd7(0x1a2)]=_0x521dd7(0x1ac);const _0x179267=document[_0x521dd7(0x1b9)]('h3');_0x179267['textContent']='AI任务处理中...',_0x179267[_0x521dd7(0x1b3)][_0x521dd7(0x18d)]=_0x521dd7(0x18b);const _0x10559e=document[_0x521dd7(0x1b9)](_0x521dd7(0x192));_0x10559e['id']=_0x521dd7(0x189)+_0x1bf589,_0x10559e['max']=_0x389951,_0x10559e[_0x521dd7(0x1b0)]=0x0,_0x10559e[_0x521dd7(0x1b3)][_0x521dd7(0x191)]=_0x521dd7(0x1bc);const _0x303577=document['createElement'](_0x521dd7(0x19f));return _0x303577['id']=_0x521dd7(0x1b1)+_0x1bf589,_0x303577[_0x521dd7(0x1b3)][_0x521dd7(0x1a9)]=_0x521dd7(0x1a6),_0x303577[_0x521dd7(0x1a0)]='初始连接...',_0x533b92[_0x521dd7(0x194)](_0x179267),_0x533b92[_0x521dd7(0x194)](_0x10559e),_0x533b92[_0x521dd7(0x194)](_0x303577),document[_0x521dd7(0x187)][_0x521dd7(0x194)](_0x533b92),{'start':()=>{const _0x41e9d6=_0x521dd7;_0x533b92[_0x41e9d6(0x1b3)][_0x41e9d6(0x1c2)]=_0x41e9d6(0x1c4);},'onAttempt':(_0x1fa2ec,_0x28b57b)=>{const _0x29e256=_0x521dd7;_0x10559e[_0x29e256(0x1b0)]=_0x1fa2ec,_0x3c5be9=Math[_0x29e256(0x186)](0x64,Math['round'](_0x1fa2ec/_0x389951*0x64));const _0x25831e=Math[_0x29e256(0x1ae)]((Date['now']()-_0x387510)/0x3e8);_0x303577[_0x29e256(0x18a)]=_0x29e256(0x18f)+_0x3c5be9+'%\x20
\x0a\x20\x20\x20\x20\x20\x20\x20\x20尝试:\x20'+_0x1fa2ec+'/'+_0x389951+_0x29e256(0x19a)+Math[_0x29e256(0x1ae)](_0x28b57b/0x3e8)+_0x29e256(0x19b)+_0x25831e+'秒\x0a\x20\x20\x20\x20\x20\x20';},'complete':()=>{const _0x3afe51=_0x521dd7;_0x533b92[_0x3afe51(0x1a5)]();},'error':_0x3241ec=>{const _0x229f79=_0x521dd7;_0x179267[_0x229f79(0x1a0)]=_0x229f79(0x19e),_0x179267['style'][_0x229f79(0x1bd)]=_0x229f79(0x1b7),_0x533b92[_0x229f79(0x1b3)]['backgroundColor']=_0x229f79(0x18c),_0x10559e[_0x229f79(0x1b3)][_0x229f79(0x1c2)]=_0x229f79(0x199),_0x303577['style']['whiteSpace']=_0x229f79(0x1ba),_0x303577[_0x229f79(0x18a)]=_0x229f79(0x1b4)+_0x3241ec;}};}
\ No newline at end of file