From c9500f6a942b6dbada72cc2791ec454210ec4c5d Mon Sep 17 00:00:00 2001 From: Wx-2025 <351320169@qq.com> Date: Wed, 13 Aug 2025 09:29:27 +0800 Subject: [PATCH] Update googleAdapter.js --- core/utils/googleAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/utils/googleAdapter.js b/core/utils/googleAdapter.js index 70dc04b..792916b 100644 --- a/core/utils/googleAdapter.js +++ b/core/utils/googleAdapter.js @@ -1 +1 @@ -const _0x37c83d=_0x3fde;(function(_0x246fe1,_0x20c8b1){const _0x1b501b=_0x3fde,_0x3bd7ef=_0x246fe1();while(!![]){try{const _0x335185=-parseInt(_0x1b501b(0x1b0))/0x1*(-parseInt(_0x1b501b(0x194))/0x2)+parseInt(_0x1b501b(0x1be))/0x3+parseInt(_0x1b501b(0x1ad))/0x4+-parseInt(_0x1b501b(0x1bd))/0x5+-parseInt(_0x1b501b(0x1a8))/0x6+parseInt(_0x1b501b(0x19f))/0x7*(parseInt(_0x1b501b(0x1a2))/0x8)+-parseInt(_0x1b501b(0x1ab))/0x9;if(_0x335185===_0x20c8b1)break;else _0x3bd7ef['push'](_0x3bd7ef['shift']());}catch(_0x18dc4a){_0x3bd7ef['push'](_0x3bd7ef['shift']());}}}(_0x33c1,0x2bada));function _0x33c1(){const _0x2ad785=['us-central1-aiplatform.googleapis.com','href','HARM_CATEGORY_DANGEROUS_CONTENT','error','message','endsWith','7LPCSFJ','/v1beta',':generateContent','1675376wWMhPS','HARM_CATEGORY_HATE_SPEECH','无效的API地址:\x20','includes','string','BLOCK_NONE','2111928cTBiqf','HARM_CATEGORY_HARASSMENT','some','64467BQPeQF','candidates','878008ZwQnHH','user','[GoogleAdapter]\x20URL解析错误:','1gqxOIs','text','finishReason','map','join','pathname','toLowerCase','temperature','Google\x20API需要模型名称','content','hostname','[GoogleAdapter]\x20URL构建错误:','v1beta/models/','1266035FJedwT','743754elRShm','max_tokens','ai.google.dev','assistant','stop','role','228844xmswfw','trim','原始Google响应:','generativelanguage.googleapis.com','code'];_0x33c1=function(){return _0x2ad785;};return _0x33c1();}function _0x3fde(_0x4a4ad4,_0x2ab59d){const _0x33c16c=_0x33c1();return _0x3fde=function(_0x3fdec8,_0x45a6ce){_0x3fdec8=_0x3fdec8-0x194;let _0x2c387b=_0x33c16c[_0x3fdec8];return _0x2c387b;},_0x3fde(_0x4a4ad4,_0x2ab59d);}const GOOGLE_DOMAINS=[_0x37c83d(0x197),_0x37c83d(0x1c0),_0x37c83d(0x199)];export function isGoogleEndpoint(_0x5a4beb){const _0x332235=_0x37c83d;try{if(!_0x5a4beb||typeof _0x5a4beb!==_0x332235(0x1a6))return![];const _0x1a2e0a=new URL(_0x5a4beb),_0x328f3a=_0x1a2e0a[_0x332235(0x1ba)][_0x332235(0x1b6)](),_0x427a05=_0x1a2e0a[_0x332235(0x1b5)]['toLowerCase']();if(_0x427a05[_0x332235(0x1a5)]('/openai'))return![];return GOOGLE_DOMAINS[_0x332235(0x1aa)](_0x8b9884=>_0x328f3a[_0x332235(0x1a5)](_0x8b9884));}catch(_0x4f6eb3){return console[_0x332235(0x19c)](_0x332235(0x1af),_0x5a4beb,_0x4f6eb3),![];}}export function convertToGoogleRequest(_0x52d7b0){const _0x52af62=_0x37c83d,{model:_0x3df384,..._0x153539}=_0x52d7b0,_0x2bace0=_0x52d7b0['messages'][_0x52af62(0x1b3)](_0x37bc23=>({'role':_0x37bc23[_0x52af62(0x1c3)]==='system'?_0x52af62(0x1ae):_0x37bc23['role'],'parts':[{'text':_0x37bc23[_0x52af62(0x1b9)]}]}));return{'contents':_0x2bace0,'generationConfig':{'maxOutputTokens':_0x52d7b0[_0x52af62(0x1bf)],'temperature':_0x52d7b0[_0x52af62(0x1b7)]||0.7,'topP':0.95},'safetySettings':[{'category':_0x52af62(0x1a9),'threshold':_0x52af62(0x1a7)},{'category':_0x52af62(0x1a3),'threshold':'BLOCK_NONE'},{'category':'HARM_CATEGORY_SEXUALLY_EXPLICIT','threshold':_0x52af62(0x1a7)},{'category':_0x52af62(0x19b),'threshold':_0x52af62(0x1a7)}]};}export function parseGoogleResponse(_0x298877){const _0x282875=_0x37c83d;try{if(_0x298877[_0x282875(0x19c)])throw new Error('Google\x20API错误:\x20'+(_0x298877['error'][_0x282875(0x19d)]||'未知错误')+'\x0a代码:\x20'+_0x298877['error'][_0x282875(0x198)]);const _0x4f55f6=_0x298877[_0x282875(0x1ac)]?.[0x0];if(!_0x4f55f6||!_0x4f55f6['content'])throw new Error('无效的Google\x20API响应:\x20未找到候选内容');const _0x3935cc=_0x4f55f6[_0x282875(0x1b9)]['parts'][_0x282875(0x1b3)](_0x541deb=>_0x541deb[_0x282875(0x1b1)]||'')[_0x282875(0x1b4)]('\x0a')[_0x282875(0x195)]();return{'choices':[{'index':0x0,'message':{'role':_0x282875(0x1c1),'content':_0x3935cc},'finish_reason':_0x4f55f6[_0x282875(0x1b2)]||_0x282875(0x1c2)}]};}catch(_0xc0f79b){console['error']('[GoogleAdapter]\x20响应解析错误:',_0xc0f79b),console['log'](_0x282875(0x196),_0x298877);throw _0xc0f79b;}}export function buildGoogleApiUrl(_0x32feb0,_0xedb6e8){const _0x810c5f=_0x37c83d;try{const _0x343071=new URL(_0x32feb0);if(_0x343071[_0x810c5f(0x1b5)][_0x810c5f(0x19e)](_0x810c5f(0x1a0))||_0x343071[_0x810c5f(0x1b5)]['endsWith']('/v1beta/')){if(!_0xedb6e8)throw new Error(_0x810c5f(0x1b8));return _0x343071[_0x810c5f(0x1b5)]=_0x810c5f(0x1bc)+_0xedb6e8+_0x810c5f(0x1a1),_0x343071[_0x810c5f(0x19a)];}return _0x343071['href'];}catch(_0x3c7835){console[_0x810c5f(0x19c)](_0x810c5f(0x1bb),_0x32feb0,_0xedb6e8,_0x3c7835);throw new Error(_0x810c5f(0x1a4)+_0x32feb0);}} +const _0xa4d2b3=_0xfcf6;(function(_0x258600,_0x5858fd){const _0x1963a1=_0xfcf6,_0x4ec149=_0x258600();while(!![]){try{const _0x653f50=parseInt(_0x1963a1(0xc1))/0x1*(-parseInt(_0x1963a1(0xbb))/0x2)+-parseInt(_0x1963a1(0xb2))/0x3+parseInt(_0x1963a1(0xc6))/0x4*(-parseInt(_0x1963a1(0x99))/0x5)+parseInt(_0x1963a1(0xb4))/0x6+-parseInt(_0x1963a1(0x8f))/0x7*(parseInt(_0x1963a1(0x9b))/0x8)+-parseInt(_0x1963a1(0xba))/0x9*(parseInt(_0x1963a1(0xaf))/0xa)+parseInt(_0x1963a1(0xa7))/0xb*(parseInt(_0x1963a1(0xc3))/0xc);if(_0x653f50===_0x5858fd)break;else _0x4ec149['push'](_0x4ec149['shift']());}catch(_0x1c38a9){_0x4ec149['push'](_0x4ec149['shift']());}}}(_0xe0b5,0x5f18d));const GOOGLE_DOMAINS=[_0xa4d2b3(0x92),_0xa4d2b3(0x9d),_0xa4d2b3(0x94)];export function isGoogleEndpoint(_0x2c039b){const _0x2b84cb=_0xa4d2b3;try{if(!_0x2c039b||typeof _0x2c039b!=='string')return![];const _0x212257=new URL(_0x2c039b),_0x463cb8=_0x212257['hostname'][_0x2b84cb(0xbd)](),_0x28852c=_0x212257['pathname'][_0x2b84cb(0xbd)]();if(_0x28852c[_0x2b84cb(0x96)]('/openai'))return![];return GOOGLE_DOMAINS[_0x2b84cb(0xb5)](_0x47c97b=>_0x463cb8['includes'](_0x47c97b));}catch(_0x4b2de7){return console[_0x2b84cb(0xaa)](_0x2b84cb(0x97),_0x2c039b,_0x4b2de7),![];}}function _0xfcf6(_0x3bba17,_0x27a13e){const _0xe0b5a=_0xe0b5();return _0xfcf6=function(_0xfcf6d5,_0x1a0468){_0xfcf6d5=_0xfcf6d5-0x8f;let _0xa1b592=_0xe0b5a[_0xfcf6d5];return _0xa1b592;},_0xfcf6(_0x3bba17,_0x27a13e);}export function convertToGoogleRequest(_0x3239e2){const _0x10a05d=_0xa4d2b3,{model:_0xb36bad,..._0x231413}=_0x3239e2,_0x3c91a5=_0x3239e2[_0x10a05d(0xac)][_0x10a05d(0xbe)](_0x18e6f3=>({'role':_0x18e6f3[_0x10a05d(0xb6)]==='system'?_0x10a05d(0xa0):_0x18e6f3[_0x10a05d(0xb6)],'parts':[{'text':_0x18e6f3['content']}]}));return{'contents':_0x3c91a5,'generationConfig':{'maxOutputTokens':_0x3239e2[_0x10a05d(0xa6)],'temperature':_0x3239e2[_0x10a05d(0xb0)]||0.7,'topP':0.95},'safetySettings':[{'category':_0x10a05d(0xa8),'threshold':_0x10a05d(0xb8)},{'category':_0x10a05d(0x9c),'threshold':'BLOCK_NONE'},{'category':_0x10a05d(0x9f),'threshold':_0x10a05d(0xb8)},{'category':_0x10a05d(0xb7),'threshold':_0x10a05d(0xb8)}]};}function _0xe0b5(){const _0x16031c=['[GoogleAdapter]\x20响应解析错误:','us-central1-aiplatform.googleapis.com','text','includes','[GoogleAdapter]\x20URL解析错误:','message','2435460xhJXPD','stop','24KBpnpf','HARM_CATEGORY_HATE_SPEECH','ai.google.dev','href','HARM_CATEGORY_SEXUALLY_EXPLICIT','user','join','无效的Google\x20API响应:\x20未找到候选内容',':batchEmbedContents','v1beta/models/','content','max_tokens','2071883ILydVW','HARM_CATEGORY_HARASSMENT','未知错误','error','value','messages','pathname','\x0a代码:\x20','67380EzNFeT','temperature','embeddings','1538514WPnVBx','/v1beta','298410hizsHG','some','role','HARM_CATEGORY_DANGEROUS_CONTENT','BLOCK_NONE','Google\x20API错误:\x20','774fHFoTZ','1042UgLmev','endsWith','toLowerCase','map','candidates','/v1beta/models/','15itNFwK','[GoogleAdapter]\x20URL构建错误:','168sImTIl',':generateContent','无效的API地址:\x20','4cZbUZs','1656543rMGWCc','models/','log','generativelanguage.googleapis.com'];_0xe0b5=function(){return _0x16031c;};return _0xe0b5();}export function parseGoogleResponse(_0x56178e){const _0x4611b6=_0xa4d2b3;try{if(_0x56178e[_0x4611b6(0xaa)])throw new Error(_0x4611b6(0xb9)+(_0x56178e[_0x4611b6(0xaa)][_0x4611b6(0x98)]||_0x4611b6(0xa9))+_0x4611b6(0xae)+_0x56178e['error']['code']);const _0x32cf68=_0x56178e[_0x4611b6(0xbf)]?.[0x0];if(!_0x32cf68||!_0x32cf68[_0x4611b6(0xa5)])throw new Error(_0x4611b6(0xa2));const _0x1fe196=_0x32cf68[_0x4611b6(0xa5)]['parts'][_0x4611b6(0xbe)](_0x4f41a4=>_0x4f41a4[_0x4611b6(0x95)]||'')[_0x4611b6(0xa1)]('\x0a')['trim']();return{'choices':[{'index':0x0,'message':{'role':'assistant','content':_0x1fe196},'finish_reason':_0x32cf68['finishReason']||_0x4611b6(0x9a)}]};}catch(_0x248ca2){console[_0x4611b6(0xaa)](_0x4611b6(0x93),_0x248ca2),console[_0x4611b6(0x91)]('原始Google响应:',_0x56178e);throw _0x248ca2;}}export function buildGoogleApiUrl(_0x2b9be8,_0x5ac8cf){const _0x52bd37=_0xa4d2b3;try{const _0x326690=new URL(_0x2b9be8);if(_0x326690[_0x52bd37(0xad)][_0x52bd37(0xbc)](_0x52bd37(0xb3))||_0x326690[_0x52bd37(0xad)]['endsWith']('/v1beta/')){if(!_0x5ac8cf)throw new Error('Google\x20API需要模型名称');return _0x326690[_0x52bd37(0xad)]=_0x52bd37(0xa4)+_0x5ac8cf+_0x52bd37(0xc4),_0x326690[_0x52bd37(0x9e)];}return _0x326690[_0x52bd37(0x9e)];}catch(_0x3cab9b){console[_0x52bd37(0xaa)](_0x52bd37(0xc2),_0x2b9be8,_0x5ac8cf,_0x3cab9b);throw new Error(_0x52bd37(0xc5)+_0x2b9be8);}}export function buildGoogleEmbeddingRequest(_0x56263e,_0x4c6a6d){const _0x2d0553=_0xa4d2b3,_0x302751=_0x56263e[_0x2d0553(0xbe)](_0x448f0c=>({'model':_0x2d0553(0x90)+_0x4c6a6d,'content':{'parts':[{'text':_0x448f0c}]}}));return{'requests':_0x302751};}export function parseGoogleEmbeddingResponse(_0x3c8d69){const _0x3e1063=_0xa4d2b3;if(!_0x3c8d69||!Array['isArray'](_0x3c8d69[_0x3e1063(0xb1)])){console['error']('[GoogleAdapter]\x20Google向量API响应格式无效,缺少\x20\x22embeddings\x22\x20数组:',_0x3c8d69);throw new Error('Google\x20API返回的向量数据格式不正确。');}return _0x3c8d69[_0x3e1063(0xb1)]['map'](_0x1d31eb=>_0x1d31eb[_0x3e1063(0xab)]);}export function buildGoogleEmbeddingApiUrl(_0x501411,_0x29dbea){const _0x4aa6d7=_0xa4d2b3,_0x20dd38=new URL(_0x501411);return _0x20dd38[_0x4aa6d7(0xad)]=_0x4aa6d7(0xc0)+_0x29dbea+_0x4aa6d7(0xa3),_0x20dd38['href'];}