mirror of
https://github.com/Wx-2025/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 12:45:51 +00:00
Add files via upload
This commit is contained in:
1
core/utils/googleAdapter.js
Normal file
1
core/utils/googleAdapter.js
Normal file
@@ -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);}}
|
||||
1
core/utils/pollingManager.js
Normal file
1
core/utils/pollingManager.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user