mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 12:25:51 +00:00
Create embedding-api-adapter.js
This commit is contained in:
1
core/utils/embedding-api-adapter.js
Normal file
1
core/utils/embedding-api-adapter.js
Normal file
@@ -0,0 +1 @@
|
||||
function _0x38c3(_0x14386a,_0x2ca3d4){const _0x3ac991=_0x3ac9();return _0x38c3=function(_0x38c36c,_0x147db7){_0x38c36c=_0x38c36c-0x186;let _0x21a116=_0x3ac991[_0x38c36c];return _0x21a116;},_0x38c3(_0x14386a,_0x2ca3d4);}function _0x3ac9(){const _0x362778=['7mBeBUR','437750yiSOHJ','isArray','Bearer\x20','1339314xGwcLG','13277BmJoqD','):\x20','[Embedding\x20Adapter]\x20Fetching\x20models\x20from:\x20','27PXCXWa','7836ONljjF','[Embedding\x20Adapter]\x20Connection\x20test\x20failed:','endsWith','Failed\x20to\x20fetch\x20models\x20(','340168ScyrBg','/v1/models','error','Invalid\x20response\x20format\x20from\x20models\x20API:\x20\x27data\x27\x20array\x20not\x20found.','Connection\x20successful!\x20API\x20endpoint\x20is\x20valid.','/v1','115780HufYWv','text','json','6tQazUA','sort','6pSjSMK','3072270ArozNc','API\x20URL\x20or\x20Key\x20is\x20not\x20provided.','671780LDUQcz','status','Connection\x20failed:\x20','localeCompare','trim','data'];_0x3ac9=function(){return _0x362778;};return _0x3ac9();}(function(_0x57280c,_0x58e061){const _0x2803b2=_0x38c3,_0x5cd92d=_0x57280c();while(!![]){try{const _0x1783d6=parseInt(_0x2803b2(0x19a))/0x1*(-parseInt(_0x2803b2(0x19d))/0x2)+-parseInt(_0x2803b2(0x19f))/0x3*(parseInt(_0x2803b2(0x1a2))/0x4)+-parseInt(_0x2803b2(0x188))/0x5+parseInt(_0x2803b2(0x18b))/0x6*(parseInt(_0x2803b2(0x187))/0x7)+parseInt(_0x2803b2(0x194))/0x8*(-parseInt(_0x2803b2(0x18f))/0x9)+parseInt(_0x2803b2(0x1a0))/0xa+-parseInt(_0x2803b2(0x18c))/0xb*(-parseInt(_0x2803b2(0x190))/0xc);if(_0x1783d6===_0x58e061)break;else _0x5cd92d['push'](_0x5cd92d['shift']());}catch(_0x552f37){_0x5cd92d['push'](_0x5cd92d['shift']());}}}(_0x3ac9,0x669b2));function getSanitizedBaseUrl(_0x523240){const _0x38fd2c=_0x38c3;let _0x1990dc=_0x523240[_0x38fd2c(0x1a6)]();return _0x1990dc[_0x38fd2c(0x192)]('/')&&(_0x1990dc=_0x1990dc['slice'](0x0,-0x1)),_0x1990dc['endsWith'](_0x38fd2c(0x199))&&(_0x1990dc=_0x1990dc['slice'](0x0,-0x3)),_0x1990dc;}export async function fetchEmbeddingModels(_0x275a14,_0x39c691){const _0x58b991=_0x38c3;if(!_0x275a14||!_0x39c691)throw new Error(_0x58b991(0x1a1));const _0x3b18af=getSanitizedBaseUrl(_0x275a14),_0x5b0678=_0x3b18af+_0x58b991(0x195);console['log'](_0x58b991(0x18e)+_0x5b0678);const _0x293989=await fetch(_0x5b0678,{'method':'GET','headers':{'Authorization':_0x58b991(0x18a)+_0x39c691,'Content-Type':'application/json'}});if(!_0x293989['ok']){const _0x43cd2b=await _0x293989[_0x58b991(0x19b)]();throw new Error(_0x58b991(0x193)+_0x293989[_0x58b991(0x1a3)]+_0x58b991(0x18d)+_0x43cd2b);}const _0x4be88e=await _0x293989[_0x58b991(0x19c)]();if(!_0x4be88e[_0x58b991(0x186)]||!Array[_0x58b991(0x189)](_0x4be88e['data']))throw new Error(_0x58b991(0x197));return _0x4be88e[_0x58b991(0x186)][_0x58b991(0x19e)]((_0x1dde61,_0x2d6ccb)=>_0x1dde61['id'][_0x58b991(0x1a5)](_0x2d6ccb['id']));}export async function testEmbeddingConnection(_0x538024,_0x4dd500){const _0x5aeb00=_0x38c3;try{return await fetchEmbeddingModels(_0x538024,_0x4dd500),{'success':!![],'message':_0x5aeb00(0x198)};}catch(_0x3d03b7){return console[_0x5aeb00(0x196)](_0x5aeb00(0x191),_0x3d03b7),{'success':![],'message':_0x5aeb00(0x1a4)+_0x3d03b7['message']};}}
|
||||
Reference in New Issue
Block a user