@ckeditor/ckeditor5-ai
Version:
AI Assistant feature for CKEditor 5.
23 lines • 8.13 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 _0x44125c=_0x4fdf;(function(_0x3ec3de,_0x2a67e5){const _0x36c54b=_0x4fdf,_0xdaea47=_0x3ec3de();while(!![]){try{const _0x596fb8=parseInt(_0x36c54b(0xec))/0x1*(-parseInt(_0x36c54b(0xd3))/0x2)+-parseInt(_0x36c54b(0xee))/0x3+-parseInt(_0x36c54b(0xfe))/0x4+-parseInt(_0x36c54b(0xe9))/0x5+-parseInt(_0x36c54b(0xe6))/0x6+parseInt(_0x36c54b(0xe1))/0x7*(parseInt(_0x36c54b(0x107))/0x8)+parseInt(_0x36c54b(0xdc))/0x9;if(_0x596fb8===_0x2a67e5)break;else _0xdaea47['push'](_0xdaea47['shift']());}catch(_0x824ca3){_0xdaea47['push'](_0xdaea47['shift']());}}}(_0x1cb5,0x2811e));import{default as _0x1ddd23}from'./aitextadapter.js';import{AIRequestError as _0x4258c1}from'./aiadapter.js';function _0x4fdf(_0x2757ba,_0x5ef592){const _0x1cb563=_0x1cb5();return _0x4fdf=function(_0x4fdf14,_0x3e2486){_0x4fdf14=_0x4fdf14-0xc6;let _0x12fa31=_0x1cb563[_0x4fdf14];return _0x12fa31;},_0x4fdf(_0x2757ba,_0x5ef592);}import{getTranslation as _0xab1b2c}from'../utils/common-translations.js';export default class O extends _0x1ddd23{[_0x44125c(0x106)];[_0x44125c(0xd8)];[_0x44125c(0xd1)];static get[_0x44125c(0xfb)](){const _0x1a457c=_0x44125c;return _0x1a457c(0xfc);}constructor(_0x57122b){const _0x2666b1=_0x44125c;super(_0x57122b),_0x57122b[_0x2666b1(0xce)][_0x2666b1(0x102)](_0x2666b1(0xd0),_0x2666b1(0xfa)),_0x57122b[_0x2666b1(0xce)][_0x2666b1(0xe2)](_0x2666b1(0x109))||_0x57122b[_0x2666b1(0xce)][_0x2666b1(0x102)](_0x2666b1(0x109),{'model':_0x2666b1(0xdf),'max_tokens':0x7d0,'temperature':0x1,'top_p':0x1,'stream':!0x0}),this[_0x2666b1(0x106)]=_0x57122b[_0x2666b1(0xce)][_0x2666b1(0xe2)](_0x2666b1(0xd0)),this[_0x2666b1(0xd8)]=_0x57122b[_0x2666b1(0xce)][_0x2666b1(0xe2)](_0x2666b1(0xc7))||{},this[_0x2666b1(0xd1)]=_0x57122b[_0x2666b1(0xce)][_0x2666b1(0xe2)](_0x2666b1(0x109));}async[_0x44125c(0xc8)]({query:_0xe41ce0,context:_0x4c838d,onData:_0xc1bf3e,actionId:_0x238e1b}){const _0x4c236d=_0x44125c,_0x5d903b=this[_0x4c236d(0xf6)][_0x4c236d(0x101)],_0x2df093=await this[_0x4c236d(0xda)](_0xe41ce0,_0x4c838d,_0x238e1b),_0x3f7a8b=await this[_0x4c236d(0x103)](this[_0x4c236d(0xd8)],_0x238e1b),_0x5eb808=await this[_0x4c236d(0xd5)](this[_0x4c236d(0xd1)],_0x238e1b),_0x4a4ec5={'messages':_0x2df093,..._0x5eb808},_0x2990e8={'method':_0x4c236d(0xf9),'headers':_0x3f7a8b,'body':JSON[_0x4c236d(0xc9)](_0x4a4ec5),'signal':this[_0x4c236d(0xf3)][_0x4c236d(0x104)]},_0x1cbdd5=await fetch(this[_0x4c236d(0x106)],_0x2990e8);if(_0x1cbdd5['ok'])return _0x5eb808[_0x4c236d(0xe5)]?await this[_0x4c236d(0xef)](_0x1cbdd5,_0xc1bf3e):await this[_0x4c236d(0xf4)](_0x1cbdd5,_0xc1bf3e),Promise[_0x4c236d(0x100)]();{const _0x48704d=await _0x1cbdd5[_0x4c236d(0xf7)]();return _0x48704d[_0x4c236d(0xe4)](_0x4c236d(0xd6))?Promise[_0x4c236d(0xc6)](new _0x4258c1(_0xab1b2c(_0x5d903b,_0x4c236d(0xe3)))):_0x48704d[_0x4c236d(0xe4)](_0x4c236d(0xcb))?Promise[_0x4c236d(0xc6)](new _0x4258c1(_0xab1b2c(_0x5d903b,_0x4c236d(0xdd)))):Promise[_0x4c236d(0xc6)](new Error(_0x48704d));}}async[_0x44125c(0xda)](_0x273d8a,_0x20cd00,_0x367628){const _0x484744=_0x44125c;let _0x475f05,_0x41598b;return _0x20cd00?(_0x475f05=_0x484744(0x105),_0x41598b=_0x484744(0xd4)+_0x273d8a+_0x484744(0xf5)+_0x20cd00):(_0x475f05=_0x484744(0xf8),_0x41598b=_0x273d8a),[{'role':_0x484744(0xcd),'content':_0x475f05},{'role':_0x484744(0xe7),'content':_0x41598b}];}async[_0x44125c(0xef)](_0xb7c581,_0x49abd9){const _0x34a32b=_0x44125c,_0x13daea=_0xb7c581[_0x34a32b(0xd7)][_0x34a32b(0xde)](),_0x4efa8d=new TextDecoder();let _0x4d67cf='',_0x55e2d7='',_0x50c911='',_0x48de62=!0x1;for(;!_0x48de62;){const {done:_0x5543c0,value:_0x2924b4}=await _0x13daea[_0x34a32b(0xf0)](),_0x48a0ce=_0x4d67cf+_0x4efa8d[_0x34a32b(0xca)](_0x2924b4);let _0x955786='';_0x48de62=_0x5543c0;try{_0x955786=this[_0x34a32b(0xeb)](_0x48a0ce),_0x4d67cf='';}catch{_0x4d67cf=_0x48a0ce;continue;}_0x55e2d7+=_0x955786,!_0x48de62&&this[_0x34a32b(0xe8)](_0x55e2d7)||_0x55e2d7&&(_0x50c911+=_0x55e2d7,_0x55e2d7='',_0x49abd9(_0x50c911));}return Promise[_0x34a32b(0x100)]();}async[_0x44125c(0xf4)](_0x4bbc1b,_0x43cc52){const _0x4ef3a0=_0x44125c;return _0x43cc52((await _0x4bbc1b[_0x4ef3a0(0xd9)]())[_0x4ef3a0(0xf2)][0x0][_0x4ef3a0(0xcf)][_0x4ef3a0(0xdb)]),Promise[_0x4ef3a0(0x100)]();}[_0x44125c(0xe8)](_0x5bce37){const _0x12e8e4=_0x44125c,_0xd65562=_0x5bce37[_0x12e8e4(0xe0)]('<')[_0x12e8e4(0xea)]!==_0x5bce37[_0x12e8e4(0xe0)]('>')[_0x12e8e4(0xea)],_0x5e4acd=_0x5bce37[_0x12e8e4(0xea)]<0x1e;return _0xd65562&&_0x5e4acd;}[_0x44125c(0xeb)](_0x4d415b){const _0x53017f=_0x44125c;return _0x4d415b[_0x53017f(0xe0)](/\n(?![^{]*\})/g)[_0x53017f(0xed)](_0x35e104=>_0x35e104[_0x53017f(0xf1)](_0x53017f(0x10a),''))[_0x53017f(0xcc)](_0x361526=>_0x361526&&_0x361526[_0x53017f(0xea)]>0x0&&_0x53017f(0xd2)!==_0x361526)[_0x53017f(0xed)](_0x423269=>{const _0x5a09a6=_0x53017f,{choices:_0x3a1cfb}=JSON[_0x5a09a6(0xfd)](_0x423269);if(_0x3a1cfb[0x0]?.[_0x5a09a6(0xff)]?.[_0x5a09a6(0xdb)])return _0x3a1cfb[0x0][_0x5a09a6(0xff)][_0x5a09a6(0xdb)];})[_0x53017f(0xcc)](_0x25221b=>_0x25221b)[_0x53017f(0x108)]('');}}function _0x1cb5(){const _0x11769e=['_cleanUpData','11xScvEe','map','27840nGHFYo','_readStreamableResponse','read','replace','choices','abortController','_readStaticResponse','\x0aYou\x20must\x20keep\x20the\x20text\x20formatting.\x0a\x0aContent:\x0a','editor','text','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.','POST','https://api.openai.com/v1/chat/completions','pluginName','OpenAITextAdapter','parse','678108XTckkG','delta','resolve','locale','define','_prepareRequestHeaders','signal','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.','_apiUrl','2383552pRWHYz','join','ai.openAI.requestParameters','data:\x20','reject','ai.openAI.requestHeaders','sendRequest','stringify','decode','Moderation','filter','system','config','message','ai.openAI.apiUrl','_requestParameters','[DONE]','37204LmjJkh','Instruction:\x0a','_prepareRequestParameters','context_length_exceeded','body','_requestHeaders','json','prepareMessages','content','6971328BBtcAq','AI_ERROR_MODERATION','getReader','gpt-3.5-turbo','split','7hAlFpb','get','AI_ERROR_CONTEXT_LENGTH','includes','stream','1687932EpSXZZ','user','_isBufferIncomplete','1218295ipcfZB','length'];_0x1cb5=function(){return _0x11769e;};return _0x1cb5();}