@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
23 lines • 10.4 kB
JavaScript
/*
* Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
*
*
*
*
* +---------------------------------------------------------------------------------+
* | |
* | Hello stranger! |
* | |
* | |
* | What you're currently looking at is the source code of a legally protected, |
* | proprietary software. Any attempts to deobfuscate / disassemble this code |
* | are forbidden and will result in legal consequences. |
* | |
* | |
* +---------------------------------------------------------------------------------+
*
*
*
*
*/
const _0x2bc041=_0x5a2b;(function(_0x5b0ec1,_0x47e9a8){const _0x28b6ba=_0x5a2b,_0x2ff03e=_0x5b0ec1();while(!![]){try{const _0x48d873=-parseInt(_0x28b6ba(0xfb))/0x1*(-parseInt(_0x28b6ba(0x129))/0x2)+parseInt(_0x28b6ba(0x10d))/0x3*(-parseInt(_0x28b6ba(0x127))/0x4)+-parseInt(_0x28b6ba(0x114))/0x5*(-parseInt(_0x28b6ba(0xda))/0x6)+parseInt(_0x28b6ba(0xde))/0x7*(-parseInt(_0x28b6ba(0x10a))/0x8)+parseInt(_0x28b6ba(0x108))/0x9*(-parseInt(_0x28b6ba(0x107))/0xa)+parseInt(_0x28b6ba(0x11c))/0xb*(parseInt(_0x28b6ba(0xe8))/0xc)+parseInt(_0x28b6ba(0xfc))/0xd;if(_0x48d873===_0x47e9a8)break;else _0x2ff03e['push'](_0x2ff03e['shift']());}catch(_0x2a60cf){_0x2ff03e['push'](_0x2ff03e['shift']());}}}(_0x1f03,0xe34ca));import{AITextAdapter as _0x13fcff}from'./aitextadapter.js';import{AIRequestError as _0x55b63a}from'./aiadapter.js';function _0x1f03(){const _0xd7faa1=['meta.llama','generations','decode','stringify','anthropic.claude','ai.assistant.adapter.aws.bedrockClientConfig','_readAsyncIterableResponse','locale','cohere.command','body','editor','get','read','1197305sXqErX','27733511ZpGppB','ai.assistant.adapter.aws.requestParameters','test','anthropic.claude-v2','_apiUrl','generation','\x0aYou\x20must\x20keep\x20the\x20text\x20formatting.\x0a\x0aContent:\x0a','getModelFamily','_processProxyRequest','getReader','completion','2042320vritXQ','72SPeXdx','resolve','56qDfLlA','parse','split','51933CXuZZG','filter','text','Human:\x0a','_requestParameters','_requestHeaders','application/json','7288475ayMIes','Instruction:\x0a','Your\x20task\x20is\x20to\x20generate\x20HTML\x20content\x20accordingly\x20to\x20the\x20given\x20instruction.\x20Never\x20include\x20<img>\x20tag\x20in\x20your\x20response\x20even\x20if\x20asked\x20for.\x20Your\x20answer\x20must\x20be\x20a\x20well-structured\x20and\x20properly\x20formatted\x20HTML\x20code.\x20Answer\x20only\x20with\x20the\x20generated\x20HTML\x20content.\x20Do\x20not\x20add\x20any\x20additional\x20remarks\x20or\x20notes.\x20Do\x20not\x20act\x20like\x20a\x20chatbot\x20or\x20a\x20real\x20person.','AWSTextAdapter','\x0a[/INST]','config','preparePrompt','_getGeneratedText','1596826oGJBAY','ai21.j2','json','_readStaticResponse','AI_ERROR_UNSUPPORTED_MODEL','bytes','ai.assistant.adapter.aws.apiUrl','_prepareRequestHeaders','signal','map','join','408WhQqwJ','send','2GxFUTM','_bedrockClientConfig','ai.assistant.adapter.aws.requestHeaders','utf-8','6kfowIO','\x0a<</SYS>>\x0a[INST]\x0a','POST','_readStreamableResponse','602917Vhizdq','_prepareRequestParameters','<<SYS>>\x0a','length','_processAWSRequest','pluginName','abortController','define','chunk','\x0a\x0aAssistant:','12DFrxLg','data','sendRequest','bedrock-2023-05-31','Your\x20task\x20is\x20to\x20execute\x20the\x20instruction\x20using\x20the\x20provided\x20HTML\x20content.\x20Follow\x20the\x20instruction\x20closely.\x20Your\x20answer\x20must\x20be\x20a\x20properly\x20formatted\x20HTML\x20code.\x20Do\x20not\x20add\x20any\x20additional\x20remarks\x20or\x20notes.\x20Do\x20not\x20act\x20like\x20a\x20chatbot\x20or\x20a\x20real\x20person.','completions'];_0x1f03=function(){return _0xd7faa1;};return _0x1f03();}import{BedrockRuntimeClient as _0x31d2f1,InvokeModelCommand as _0x24333e,InvokeModelWithResponseStreamCommand as _0x363e10}from'@aws-sdk/client-bedrock-runtime';import{getTranslation as _0x45b253}from'../utils/common-translations.js';function _0x5a2b(_0x540a48,_0x2a43df){const _0x1f03a9=_0x1f03();return _0x5a2b=function(_0x5a2b16,_0x2d7547){_0x5a2b16=_0x5a2b16-0xda;let _0x44a8b2=_0x1f03a9[_0x5a2b16];return _0x44a8b2;},_0x5a2b(_0x540a48,_0x2a43df);}export class AWSTextAdapter extends _0x13fcff{[_0x2bc041(0x100)];[_0x2bc041(0x112)];[_0x2bc041(0x12a)];[_0x2bc041(0x111)];static get[_0x2bc041(0xe3)](){const _0x3b3f15=_0x2bc041;return _0x3b3f15(0x117);}constructor(_0x44b1fc){const _0x3e0c2d=_0x2bc041;super(_0x44b1fc),_0x44b1fc[_0x3e0c2d(0x119)][_0x3e0c2d(0xf9)](_0x3e0c2d(0xfd))||_0x44b1fc[_0x3e0c2d(0x119)][_0x3e0c2d(0xe5)](_0x3e0c2d(0xfd),{'model':_0x3e0c2d(0xff),'max_tokens_to_sample':0x7d0,'temperature':0x1,'top_p':0x1,'top_k':0xfa,'anthropic_version':_0x3e0c2d(0xeb),'stream':!0x0}),this[_0x3e0c2d(0x100)]=_0x44b1fc[_0x3e0c2d(0x119)][_0x3e0c2d(0xf9)](_0x3e0c2d(0x122)),this[_0x3e0c2d(0x12a)]=_0x44b1fc[_0x3e0c2d(0x119)][_0x3e0c2d(0xf9)](_0x3e0c2d(0xf3)),this[_0x3e0c2d(0x112)]=_0x44b1fc[_0x3e0c2d(0x119)][_0x3e0c2d(0xf9)](_0x3e0c2d(0x12b)),this[_0x3e0c2d(0x111)]=_0x44b1fc[_0x3e0c2d(0x119)][_0x3e0c2d(0xf9)](_0x3e0c2d(0xfd));}async[_0x2bc041(0xea)]({query:_0xcf9830,context:_0x9b37b7,onData:_0x48dd55,actionId:_0x45fa9d}){const _0x139408=_0x2bc041,{model:_0x2f8523,stream:_0x51e122,..._0x5c92cc}=await this[_0x139408(0xdf)](this[_0x139408(0x111)],_0x45fa9d),_0x51a951={'prompt':await this[_0x139408(0x11a)](_0xcf9830,_0x9b37b7,_0x2f8523,_0x45fa9d),..._0x5c92cc};this[_0x139408(0x100)]?await this[_0x139408(0x104)](_0x51a951,_0x2f8523,_0x51e122,_0x48dd55,_0x45fa9d):await this[_0x139408(0xe2)](_0x51a951,_0x2f8523,_0x51e122,_0x48dd55);}async[_0x2bc041(0x11a)](_0x14b6dd,_0x187cb2,_0x2c1cad,_0x58f0b5){const _0x41781e=_0x2bc041;let _0x4afbc4,_0x18faf0;return _0x187cb2?(_0x4afbc4=_0x41781e(0xec),_0x18faf0=_0x41781e(0x115)+_0x14b6dd+_0x41781e(0x102)+_0x187cb2):(_0x4afbc4=_0x41781e(0x116),_0x18faf0=_0x14b6dd),_0x41781e(0xee)==this[_0x41781e(0x103)](_0x2c1cad)?_0x41781e(0xe0)+_0x4afbc4+_0x41781e(0xdb)+_0x18faf0+_0x41781e(0x118):_0x41781e(0x110)+_0x4afbc4+'\x0a'+_0x18faf0+_0x41781e(0xe7);}[_0x2bc041(0x103)](_0x1c502c){const _0x48f937=_0x2bc041;if(/^anthropic\.claude/[_0x48f937(0xfe)](_0x1c502c))return _0x48f937(0xf2);if(/^ai21\.j2/[_0x48f937(0xfe)](_0x1c502c))return _0x48f937(0x11d);if(/^cohere\.command/[_0x48f937(0xfe)](_0x1c502c))return _0x48f937(0xf6);if(/^meta\.llama/[_0x48f937(0xfe)](_0x1c502c))return _0x48f937(0xee);throw new _0x55b63a(_0x45b253(this[_0x48f937(0xf8)][_0x48f937(0xf5)],_0x48f937(0x120),_0x1c502c));}async[_0x2bc041(0x104)](_0x1703ac,_0x58187b,_0x31845b,_0x1e6938,_0x479df4){const _0x321ab7=_0x2bc041,_0x2d9dc6={'method':_0x321ab7(0xdc),'headers':await this[_0x321ab7(0x123)](this[_0x321ab7(0x112)],_0x479df4),'body':JSON[_0x321ab7(0xf1)]({..._0x1703ac,'model':_0x58187b,'stream':_0x31845b}),'signal':this[_0x321ab7(0xe4)][_0x321ab7(0x124)]},_0x321edb=await fetch(this[_0x321ab7(0x100)],_0x2d9dc6);_0x31845b?await this[_0x321ab7(0xdd)](_0x321edb,_0x58187b,_0x1e6938):await this[_0x321ab7(0x11f)](_0x321edb,_0x58187b,_0x1e6938);}async[_0x2bc041(0xe2)](_0x35e6b1,_0x2c3d59,_0x1874af,_0x316f55){const _0x381eb3=_0x2bc041,_0x2327b7=new _0x31d2f1(this[_0x381eb3(0x12a)]),_0x252978={'body':JSON[_0x381eb3(0xf1)](_0x35e6b1),'contentType':_0x381eb3(0x113),'accept':_0x381eb3(0x113),'modelId':_0x2c3d59};let _0x8a79d3;if(_0x1874af){const _0x480cd3=new _0x363e10(_0x252978);_0x8a79d3=await _0x2327b7[_0x381eb3(0x128)](_0x480cd3,{'abortSignal':this[_0x381eb3(0xe4)][_0x381eb3(0x124)]}),await this[_0x381eb3(0xf4)](_0x8a79d3,_0x2c3d59,_0x316f55);}else{const _0x7dc49=new _0x24333e(_0x252978);_0x8a79d3=await _0x2327b7[_0x381eb3(0x128)](_0x7dc49,{'abortSignal':this[_0x381eb3(0xe4)][_0x381eb3(0x124)]}),await this[_0x381eb3(0x11f)](_0x8a79d3,_0x2c3d59,_0x316f55);}}async[_0x2bc041(0xf4)](_0x2e180a,_0x2c12f7,_0x16ac1d){const _0x48e927=_0x2bc041,_0x384137=_0x2e180a[_0x48e927(0xf7)],_0x3339d1=new TextDecoder(_0x48e927(0x12c));let _0x194bbe='';for await(const _0x5c6e0f of _0x384137)if(_0x5c6e0f[_0x48e927(0xe6)]){const _0x26aaa2=_0x3339d1[_0x48e927(0xf0)](_0x5c6e0f[_0x48e927(0xe6)][_0x48e927(0x121)]),_0x4854eb=JSON[_0x48e927(0x10b)](_0x26aaa2);_0x194bbe+=this[_0x48e927(0x11b)](_0x4854eb,_0x2c12f7),_0x16ac1d(_0x194bbe);}return Promise[_0x48e927(0x109)]();}async[_0x2bc041(0xdd)](_0x245d2e,_0x4b9dae,_0x267406){const _0x522e30=_0x2bc041,_0x228dff=_0x245d2e[_0x522e30(0xf7)],_0x34074c=new TextDecoder(_0x522e30(0x12c)),_0x355201=_0x228dff[_0x522e30(0x105)]();let _0x1c7bee='',_0x1918c8='',_0x5a4c83=!0x1;for(;!_0x5a4c83;){const {done:_0x11f309,value:_0x1e3151}=await _0x355201[_0x522e30(0xfa)]();if(_0x5a4c83=_0x11f309,_0x5a4c83)break;const _0x3bfe96=(_0x1c7bee+_0x34074c[_0x522e30(0xf0)](_0x1e3151))[_0x522e30(0x10c)]('\x0a')[_0x522e30(0x125)](_0x532068=>{const _0x35abe2=_0x522e30;try{return _0x1c7bee='',JSON[_0x35abe2(0x10b)](_0x532068);}catch{return _0x1c7bee=_0x532068,null;}})[_0x522e30(0x10e)](_0x138ea9=>null!==_0x138ea9);_0x3bfe96[_0x522e30(0xe1)]&&(_0x1918c8+=_0x3bfe96[_0x522e30(0x125)](_0x1a04bd=>this[_0x522e30(0x11b)](_0x1a04bd,_0x4b9dae))[_0x522e30(0x126)](''),_0x267406(_0x1918c8));}return Promise[_0x522e30(0x109)]();}async[_0x2bc041(0x11f)](_0x48d2f2,_0x4d2d1e,_0x44f26c){const _0x1f8dd6=_0x2bc041;let _0x4d31d5;return _0x4d31d5=_0x48d2f2 instanceof Response?await _0x48d2f2[_0x1f8dd6(0x11e)]():JSON[_0x1f8dd6(0x10b)](new TextDecoder(_0x1f8dd6(0x12c))[_0x1f8dd6(0xf0)](_0x48d2f2[_0x1f8dd6(0xf7)])),(_0x44f26c(this[_0x1f8dd6(0x11b)](_0x4d31d5,_0x4d2d1e)),Promise[_0x1f8dd6(0x109)]());}[_0x2bc041(0x11b)](_0x9b1131,_0x17e3b4){const _0x5c9c15=_0x2bc041;switch(this[_0x5c9c15(0x103)](_0x17e3b4)){case _0x5c9c15(0xf2):return _0x9b1131[_0x5c9c15(0x106)];case _0x5c9c15(0x11d):return _0x9b1131[_0x5c9c15(0xed)][0x0][_0x5c9c15(0xe9)][_0x5c9c15(0x10f)];case _0x5c9c15(0xf6):return _0x9b1131[_0x5c9c15(0xef)][0x0][_0x5c9c15(0x10f)];case _0x5c9c15(0xee):return _0x9b1131[_0x5c9c15(0x101)];}}}