@ckeditor/ckeditor5-ai 40.0.0 → 40.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -2
- package/README.md +1 -1
- package/build/ai.js +77 -2
- package/build/translations/af.js +1 -1
- package/build/translations/ar.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/es-co.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/ckeditor5-metadata.json +1 -1
- package/lang/contexts.json +4 -1
- package/lang/translations/af.po +60 -16
- package/lang/translations/ar.po +60 -16
- package/lang/translations/bg.po +60 -16
- package/lang/translations/bn.po +60 -16
- package/lang/translations/bs.po +60 -16
- package/lang/translations/ca.po +60 -16
- package/lang/translations/cs.po +60 -16
- package/lang/translations/da.po +60 -16
- package/lang/translations/de-ch.po +60 -16
- package/lang/translations/de.po +60 -16
- package/lang/translations/el.po +60 -16
- package/lang/translations/en-au.po +60 -16
- package/lang/translations/en.po +60 -16
- package/lang/translations/es-co.po +60 -16
- package/lang/translations/es.po +60 -16
- package/lang/translations/et.po +60 -16
- package/lang/translations/fa.po +60 -16
- package/lang/translations/fi.po +60 -16
- package/lang/translations/fr.po +60 -16
- package/lang/translations/gl.po +95 -51
- package/lang/translations/he.po +60 -16
- package/lang/translations/hi.po +60 -16
- package/lang/translations/hr.po +93 -49
- package/lang/translations/hu.po +60 -16
- package/lang/translations/id.po +60 -16
- package/lang/translations/it.po +60 -16
- package/lang/translations/ja.po +60 -16
- package/lang/translations/jv.po +60 -16
- package/lang/translations/ko.po +60 -16
- package/lang/translations/lt.po +60 -16
- package/lang/translations/lv.po +60 -16
- package/lang/translations/ms.po +60 -16
- package/lang/translations/nl.po +60 -16
- package/lang/translations/no.po +60 -16
- package/lang/translations/pl.po +60 -16
- package/lang/translations/pt-br.po +60 -16
- package/lang/translations/pt.po +60 -16
- package/lang/translations/ro.po +60 -16
- package/lang/translations/ru.po +60 -16
- package/lang/translations/sk.po +60 -16
- package/lang/translations/sr-latn.po +95 -51
- package/lang/translations/sr.po +60 -16
- package/lang/translations/sv.po +60 -16
- package/lang/translations/th.po +60 -16
- package/lang/translations/tk.po +60 -16
- package/lang/translations/tr.po +60 -16
- package/lang/translations/ug.po +96 -52
- package/lang/translations/uk.po +60 -16
- package/lang/translations/ur.po +60 -16
- package/lang/translations/uz.po +226 -0
- package/lang/translations/vi.po +60 -16
- package/lang/translations/zh-cn.po +60 -16
- package/lang/translations/zh.po +60 -16
- package/package.json +4 -3
- package/src/adapters/aiadapter.d.ts +48 -0
- package/src/adapters/aiadapter.js +23 -0
- package/src/adapters/aitextadapter.d.ts +146 -0
- package/src/adapters/aitextadapter.js +23 -0
- package/src/adapters/awstextadapter.d.ts +178 -0
- package/src/adapters/awstextadapter.js +23 -0
- package/src/adapters/openaitextadapter.d.ts +181 -0
- package/src/adapters/openaitextadapter.js +23 -0
- package/src/aiassistant.d.ts +386 -419
- package/src/aiassistant.js +1 -1
- package/src/aiassistantediting.d.ts +45 -45
- package/src/aiassistantediting.js +1 -1
- package/src/aiassistantui.d.ts +52 -46
- package/src/aiassistantui.js +1 -1
- package/src/aiconfig.d.ts +69 -0
- package/src/aiconfig.js +23 -0
- package/src/augmentation.d.ts +27 -26
- package/src/index.d.ts +13 -9
- package/src/index.js +1 -1
- package/src/ui/aiassistantcontroller.d.ts +109 -59
- package/src/ui/aiassistantcontroller.js +1 -1
- package/src/ui/dropdown/aicommandslistview.d.ts +22 -22
- package/src/ui/dropdown/aicommandslistview.js +1 -1
- package/src/ui/dropdown/buttonlabelwithhighlightview.d.ts +29 -29
- package/src/ui/dropdown/buttonlabelwithhighlightview.js +1 -1
- package/src/ui/dropdown/labelwithhighlightview.d.ts +25 -0
- package/src/ui/dropdown/labelwithhighlightview.js +23 -0
- package/src/ui/form/aiformcontentarea.d.ts +48 -48
- package/src/ui/form/aiformcontentarea.js +1 -1
- package/src/ui/form/aiformerrorview.d.ts +26 -26
- package/src/ui/form/aiformerrorview.js +1 -1
- package/src/ui/form/aiformpromptview.d.ts +46 -46
- package/src/ui/form/aiformpromptview.js +1 -1
- package/src/ui/form/aiformtoolbarview.d.ts +54 -41
- package/src/ui/form/aiformtoolbarview.js +1 -1
- package/src/ui/form/aiformview.d.ts +142 -131
- package/src/ui/form/aiformview.js +1 -1
- package/src/ui/form/aihistorylistitemview.d.ts +18 -18
- package/src/ui/form/aihistorylistitemview.js +1 -1
- package/src/ui/form/aihistorylistview.d.ts +35 -35
- package/src/ui/form/aihistorylistview.js +1 -1
- package/src/ui/form/prompthistory.d.ts +20 -20
- package/src/ui/form/prompthistory.js +1 -1
- package/src/ui/showaiassistantcommand.d.ts +29 -26
- package/src/ui/showaiassistantcommand.js +1 -1
- package/src/utils/common-translations.d.ts +9 -9
- package/src/utils/common-translations.js +1 -1
- package/theme/ai-form.css +58 -11
- package/theme/ai.css +20 -15
- package/src/aiconnector.d.ts +0 -44
- package/src/aiconnector.js +0 -23
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module ai/ui/aihistorylistitemview
|
|
7
|
-
*/
|
|
8
|
-
import { ListItemView } from 'ckeditor5/src/ui';
|
|
9
|
-
import type { PromptHistoryEntry } from './prompthistory';
|
|
10
|
-
/**
|
|
11
|
-
* A list item view that displays a historical prompt
|
|
12
|
-
*/
|
|
13
|
-
export default class AIHistoryListItemView extends ListItemView {
|
|
14
|
-
/**
|
|
15
|
-
* @inheritDoc
|
|
16
|
-
*/
|
|
17
|
-
constructor(promptHistoryEntry: PromptHistoryEntry);
|
|
18
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/ui/aihistorylistitemview
|
|
7
|
+
*/
|
|
8
|
+
import { ListItemView } from 'ckeditor5/src/ui';
|
|
9
|
+
import type { PromptHistoryEntry } from './prompthistory';
|
|
10
|
+
/**
|
|
11
|
+
* A list item view that displays a historical prompt
|
|
12
|
+
*/
|
|
13
|
+
export default class AIHistoryListItemView extends ListItemView {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
constructor(promptHistoryEntry: PromptHistoryEntry);
|
|
18
|
+
}
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x35dc=['fire','locale','execute','children','prompt','add','set'];(function(_0x546f54,_0x35dc86){const _0x2f68e5=function(_0x13289d){while(--_0x13289d){_0x546f54['push'](_0x546f54['shift']());}};_0x2f68e5(++_0x35dc86);}(_0x35dc,0x7a));const _0x2f68=function(_0x546f54,_0x35dc86){_0x546f54=_0x546f54-0x0;let _0x2f68e5=_0x35dc[_0x546f54];return _0x2f68e5;};import{ListItemView as _0x56287e,ButtonView as _0x4fe861}from'ckeditor5/src/ui';import _0x5e63be from'../dropdown/buttonlabelwithhighlightview';import{unescape as _0x572a25}from'lodash-es';export default class pt extends _0x56287e{constructor(_0x429b4c){super();const _0x54e236=new _0x5e63be(),_0x524a0f=new _0x4fe861(this[_0x2f68('0x5')],_0x54e236);this[_0x2f68('0x0')][_0x2f68('0x2')](_0x524a0f),_0x524a0f[_0x2f68('0x3')]({'label':_0x429b4c[_0x2f68('0x1')],'withText':!0x0}),_0x524a0f['on'](_0x2f68('0x6'),()=>{this[_0x2f68('0x4')](_0x2f68('0x6'),{'value':_0x572a25(_0x429b4c[_0x2f68('0x1')])});});}}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module ai/ui/aihistorylistview
|
|
7
|
-
*/
|
|
8
|
-
import { ListView, ListItemGroupView, ButtonView, type FilteredView } from 'ckeditor5/src/ui';
|
|
9
|
-
import type { Locale } from 'ckeditor5/src/utils';
|
|
10
|
-
/**
|
|
11
|
-
* A list view that displays a list of AI prompts with filter pass-through.
|
|
12
|
-
*
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
export default class AIHistoryListView extends ListView implements FilteredView {
|
|
16
|
-
historyGroupView: ListItemGroupView;
|
|
17
|
-
clearHistoryButton: ButtonView;
|
|
18
|
-
constructor(locale: Locale);
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
filter(): {
|
|
23
|
-
resultsCount: number;
|
|
24
|
-
totalItemsCount: number;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Fired when the clear history button was executed by the user.
|
|
29
|
-
*
|
|
30
|
-
* @eventName ~AIHistoryListView#clearHistory
|
|
31
|
-
*/
|
|
32
|
-
export type AIHistoryListViewClearHistoryEvent = {
|
|
33
|
-
name: 'clearHistory';
|
|
34
|
-
args: [];
|
|
35
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/ui/aihistorylistview
|
|
7
|
+
*/
|
|
8
|
+
import { ListView, ListItemGroupView, ButtonView, type FilteredView } from 'ckeditor5/src/ui';
|
|
9
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
|
10
|
+
/**
|
|
11
|
+
* A list view that displays a list of AI prompts with filter pass-through.
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
export default class AIHistoryListView extends ListView implements FilteredView {
|
|
16
|
+
historyGroupView: ListItemGroupView;
|
|
17
|
+
clearHistoryButton: ButtonView;
|
|
18
|
+
constructor(locale: Locale);
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
filter(): {
|
|
23
|
+
resultsCount: number;
|
|
24
|
+
totalItemsCount: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fired when the clear history button was executed by the user.
|
|
29
|
+
*
|
|
30
|
+
* @eventName ~AIHistoryListView#clearHistory
|
|
31
|
+
*/
|
|
32
|
+
export type AIHistoryListViewClearHistoryEvent = {
|
|
33
|
+
name: 'clearHistory';
|
|
34
|
+
args: [];
|
|
35
|
+
};
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x4f95=['locale','add','children','historyGroupView','execute','clearHistory','fire','items','_createClearHistoryButton','delegate','clearHistoryButton','Prompt\x20history','Clear'];(function(_0x23faf1,_0x4f952f){const _0x3ce790=function(_0x465884){while(--_0x465884){_0x23faf1['push'](_0x23faf1['shift']());}};_0x3ce790(++_0x4f952f);}(_0x4f95,0xfb));const _0x3ce7=function(_0x23faf1,_0x4f952f){_0x23faf1=_0x23faf1-0x0;let _0x3ce790=_0x4f95[_0x23faf1];return _0x3ce790;};import{ListView as _0x3276da,ListItemGroupView as _0x303995,ButtonView as _0x3e2e1d}from'ckeditor5/src/ui';import{getTranslation as _0x2aaab3}from'../../utils/common-translations';export default class ut extends _0x3276da{constructor(_0x548d1d){super(_0x548d1d),this[_0x3ce7('0x6')]=this[_0x3ce7('0x4')](),this['historyGroupView']=new _0x303995(),this[_0x3ce7('0xc')][_0x3ce7('0xb')][_0x3ce7('0xa')](this[_0x3ce7('0x6')],0x1),this[_0x3ce7('0xc')]['label']=_0x2aaab3(_0x548d1d,_0x3ce7('0x7')),this[_0x3ce7('0xc')][_0x3ce7('0x3')][_0x3ce7('0x5')](_0x3ce7('0x0'))['to'](this),this['items']['add'](this[_0x3ce7('0xc')]);}['filter'](){let _0x4a59f1=0x0;for(const _0x85ff85 of this[_0x3ce7('0x3')])_0x4a59f1+=_0x85ff85[_0x3ce7('0x3')]['length'];return{'resultsCount':_0x4a59f1,'totalItemsCount':_0x4a59f1};}[_0x3ce7('0x4')](){const _0xa17eaf=this['locale'],_0x1204b5=new _0x3e2e1d(this[_0x3ce7('0x9')]);return _0x1204b5['set']({'label':'('+_0x2aaab3(_0xa17eaf,_0x3ce7('0x8'))+')','withText':!0x0}),_0x1204b5['on']('execute',()=>this[_0x3ce7('0x2')](_0x3ce7('0x1'))),_0x1204b5;}}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
import { Collection } from 'ckeditor5/src/utils';
|
|
6
|
-
/**
|
|
7
|
-
* A collection that stores the prompt history in the session storage as a side effect.
|
|
8
|
-
*/
|
|
9
|
-
export default class PromptHistory extends Collection<PromptHistoryEntry> {
|
|
10
|
-
/**
|
|
11
|
-
* @inheritDoc
|
|
12
|
-
*/
|
|
13
|
-
constructor();
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* An object that represents a historical prompt.
|
|
17
|
-
*/
|
|
18
|
-
export type PromptHistoryEntry = {
|
|
19
|
-
prompt: string;
|
|
20
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import { Collection } from 'ckeditor5/src/utils';
|
|
6
|
+
/**
|
|
7
|
+
* A collection that stores the prompt history in the session storage as a side effect.
|
|
8
|
+
*/
|
|
9
|
+
export default class PromptHistory extends Collection<PromptHistoryEntry> {
|
|
10
|
+
/**
|
|
11
|
+
* @inheritDoc
|
|
12
|
+
*/
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* An object that represents a historical prompt.
|
|
17
|
+
*/
|
|
18
|
+
export type PromptHistoryEntry = {
|
|
19
|
+
prompt: string;
|
|
20
|
+
};
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x249f=['_loadFromSessionStorage','add','map','last','remove','_saveToSessionStorage','toLowerCase','stringify','CKEditor/AIFormView/PromptHistory','length','addMany','trim','setItem','getItem','prompt'];(function(_0x25c4c3,_0x249fb7){const _0x516582=function(_0x9431f3){while(--_0x9431f3){_0x25c4c3['push'](_0x25c4c3['shift']());}};_0x516582(++_0x249fb7);}(_0x249f,0x102));const _0x5165=function(_0x25c4c3,_0x249fb7){_0x25c4c3=_0x25c4c3-0x0;let _0x516582=_0x249f[_0x25c4c3];return _0x516582;};import{Collection as _0x396808}from'ckeditor5/src/utils';const ts=_0x5165('0x5');export default class dt extends _0x396808{constructor(){super(),this[_0x5165('0xc')](),this['on'](_0x5165('0xd'),(_0x809c23,_0x2ab92e)=>{const _0x467a55=os(_0x2ab92e[_0x5165('0xb')]);for(const _0x26f08a of this)if(_0x26f08a!=_0x2ab92e&&os(_0x26f08a[_0x5165('0xb')])===_0x467a55){this['remove'](_0x26f08a);break;}this[_0x5165('0x6')]>0x14&&this['remove'](this[_0x5165('0x0')]),this[_0x5165('0x2')]();}),this['on'](_0x5165('0x1'),()=>{this[_0x5165('0x2')]();});}['_loadFromSessionStorage'](){const _0x3bbdee=sessionStorage[_0x5165('0xa')](ts)||'[]';this[_0x5165('0x7')](JSON['parse'](_0x3bbdee));}[_0x5165('0x2')](){sessionStorage[_0x5165('0x9')](ts,JSON[_0x5165('0x4')](this[_0x5165('0xe')](_0x530358=>_0x530358)));}}function os(_0xb5b7b2){return _0xb5b7b2[_0x5165('0x3')]()[_0x5165('0x8')]();}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module ai/ui/showaiassistantcommand
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { Command } from 'ckeditor5/src/core';
|
|
10
|
-
/**
|
|
11
|
-
* Command that shows the AI Assistant user interface.
|
|
12
|
-
*/
|
|
13
|
-
export default class ShowAIAssistantCommand extends Command {
|
|
14
|
-
/**
|
|
15
|
-
* @inheritDoc
|
|
16
|
-
*/
|
|
17
|
-
refresh(): void;
|
|
18
|
-
/**
|
|
19
|
-
* Opens AI Assistant user interface for the current document selection.
|
|
20
|
-
*
|
|
21
|
-
* @param
|
|
22
|
-
* @param label Label to be displayed in the AI assistant query input field while the AI assistant processes the initial
|
|
23
|
-
* @
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/ui/showaiassistantcommand
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Command } from 'ckeditor5/src/core';
|
|
10
|
+
/**
|
|
11
|
+
* Command that shows the AI Assistant user interface.
|
|
12
|
+
*/
|
|
13
|
+
export default class ShowAIAssistantCommand extends Command {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
refresh(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Opens AI Assistant user interface for the current document selection.
|
|
20
|
+
*
|
|
21
|
+
* @param query The initial query. If set, the AI assistant will automatically submit given query to the AI service.
|
|
22
|
+
* @param label Label to be displayed in the AI assistant query input field while the AI assistant processes the initial query.
|
|
23
|
+
* @param actionId The id of the executed action. It can be used in extended and custom adapters to customize the request. It
|
|
24
|
+
* will be prefixed with `aiAssistant:`. See also
|
|
25
|
+
* {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `AITextAdapterRequestData#actionId`}.
|
|
26
|
+
* @fires execute
|
|
27
|
+
*/
|
|
28
|
+
execute(query?: string, label?: string, actionId?: string): void;
|
|
29
|
+
}
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x218c=['model','showUI','getRanges','get','selection','editor','element','ai.aiAssistant.disabledElements','getItems','custom','plugins','isEnabled','includes','document'];(function(_0x4b9bee,_0x218c26){const _0x34e3a9=function(_0x52c64e){while(--_0x52c64e){_0x4b9bee['push'](_0x4b9bee['shift']());}};_0x34e3a9(++_0x218c26);}(_0x218c,0x1a1));const _0x34e3=function(_0x4b9bee,_0x218c26){_0x4b9bee=_0x4b9bee-0x0;let _0x34e3a9=_0x218c[_0x4b9bee];return _0x34e3a9;};import{Command as _0x4a67c9}from'ckeditor5/src/core';import _0x23b8a8 from'../aiassistantui';export default class I extends _0x4a67c9{['refresh'](){const _0x467a38=this['editor'][_0x34e3('0x3')][_0x34e3('0x2')][_0x34e3('0x7')],_0x56b682=this[_0x34e3('0x8')]['config'][_0x34e3('0x6')](_0x34e3('0xa'));for(const _0x2562e3 of _0x467a38[_0x34e3('0x5')]())for(const _0x4bb82d of _0x2562e3[_0x34e3('0xb')]())if(_0x4bb82d['is'](_0x34e3('0x9'))&&_0x56b682[_0x34e3('0x1')](_0x4bb82d['name']))return void(this[_0x34e3('0x0')]=!0x1);this[_0x34e3('0x0')]=!0x0;}['execute'](_0x49c74f='',_0x41faf0='',_0x1c3269=_0x34e3('0xc')){this[_0x34e3('0x8')][_0x34e3('0xd')]['get'](_0x23b8a8)[_0x34e3('0x4')](_0x49c74f,_0x41faf0,_0x1c3269);}}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module ai/utils/common-translations
|
|
7
|
-
*/
|
|
8
|
-
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
-
export declare function getTranslation(locale: Locale, id: string, values?: string | Array<string> | number): string;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/utils/common-translations
|
|
7
|
+
*/
|
|
8
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
export declare function getTranslation(locale: Locale, id: string, values?: string | Array<string> | number): string;
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
export function getTranslation(
|
|
23
|
+
export function getTranslation(_0x28a569,_0x40dec0,_0x17b838){const t=_0x28a569['t'];switch(_0x40dec0){case'Edit\x20or\x20review':return t('Edit\x20or\x20review');case'Improve\x20writing':return t('Improve\x20writing');case'Make\x20shorter':return t('Make\x20shorter');case'Make\x20longer':return t('Make\x20longer');case'Simplify\x20language':return t('Simplify\x20language');case'Generate\x20from\x20selection':return t('Generate\x20from\x20selection');case'Summarize':return t('Summarize');case'Continue':return t('Continue');case'Change\x20tone':return t('Change\x20tone');case'Professional':return t('Professional');case'Casual':return t('Casual');case'Direct':return t('Direct');case'Confident':return t('Confident');case'Friendly':return t('Friendly');case'Change\x20style':return t('Change\x20style');case'Business':return t('Business');case'Legal':return t('Legal');case'Journalism':return t('Journalism');case'Poetic':return t('Poetic');case'Translate':return t('Translate');case'Translate\x20to\x20%0':return t('Translate\x20to\x20%0',_0x17b838);case'English':return t('English');case'Spanish':return t('Spanish');case'German':return t('German');case'Portuguese':return t('Portuguese');case'French':return t('French');case'Simplified\x20Chinese':return t('Simplified\x20Chinese');case'Hindi':return t('Hindi');case'Arabic':return t('Arabic');case'AI\x20Assistant':return t('AI\x20Assistant');case'AI\x20Commands':return t('AI\x20Commands');case'Ask\x20AI\x20to\x20edit\x20or\x20generate':return t('Ask\x20AI\x20to\x20edit\x20or\x20generate');case'Ask\x20AI\x20to\x20improve\x20generated\x20text':return t('Ask\x20AI\x20to\x20improve\x20generated\x20text');case'Copy':return t('Copy');case'Submit':return t('Submit');case'Insert\x20below':return t('Insert\x20below');case'Try\x20again':return t('Try\x20again');case'Stop':return t('Stop');case'AI\x20is\x20writing...':return t('AI\x20is\x20writing...');case'History':return t('History');case'Empty\x20history':return t('Empty\x20history');case'Ask\x20AI\x20and\x20your\x20prompts\x20will\x20be\x20listed\x20here\x20for\x20you\x20to\x20use\x20later.':return t('Ask\x20AI\x20and\x20your\x20prompts\x20will\x20be\x20listed\x20here\x20for\x20you\x20to\x20use\x20later.');case'Prompt\x20history':return t('Prompt\x20history');case'Search\x20AI\x20command':return t('Search\x20AI\x20command');case'No\x20commands\x20found':return t('No\x20commands\x20found');case'No\x20commands\x20available':return t('No\x20commands\x20available');case'Clear':return t('Clear');case'AI_REPLACE_CONTENT':return t({'id':'AI_REPLACE_CONTENT','string':'Replace'});case'AI_INSERT_CONTENT':return t({'id':'AI_INSERT_CONTENT','string':'Insert'});case'AI_ERROR_GET_HEADERS':return t({'id':'AI_ERROR_GET_HEADERS','string':'Preparing\x20request\x20headers\x20failed'});case'AI_ERROR_GET_PARAMETERS':return t({'id':'AI_ERROR_GET_PARAMETERS','string':'Preparing\x20request\x20parameters\x20failed'});case'AI_ERROR_UNSUPPORTED_MODEL':return t({'id':'AI_ERROR_UNSUPPORTED_MODEL','string':'The\x20requested\x20AI\x20model\x20(\x22%0\x22)\x20is\x20not\x20supported'},_0x17b838);case'AI_ERROR_CONTEXT_LENGTH':return t({'id':'AI_ERROR_CONTEXT_LENGTH','string':'Selected\x20content\x20is\x20too\x20long'});case'AI_ERROR_MODERATION':return t({'id':'AI_ERROR_MODERATION','string':'Requested\x20query\x20does\x20not\x20pass\x20moderation\x20rules'});case'AI_ERROR_FAILED':return t({'id':'AI_ERROR_FAILED','string':'Failed\x20to\x20communicate\x20with\x20the\x20AI\x20service'});default:return _0x40dec0;}}
|
package/theme/ai-form.css
CHANGED
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
--ck-ai-form-content-background: hsl(0, 0%, 98%);
|
|
17
17
|
--ck-ai-form-history-font-size: .9em;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
--ck-ai-form-error-background: hsl(0, 100%, 90%);
|
|
19
|
+
--ck-ai-form-error-background: var(--ck-color-light-red);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
/* Note: This class name is mentioned in the guide and acts like a public API. */
|
|
@@ -64,10 +63,17 @@
|
|
|
64
63
|
width: 100%;
|
|
65
64
|
white-space: normal;
|
|
66
65
|
padding: var(--ck-spacing-tiny) var(--ck-spacing-medium);
|
|
67
|
-
padding-right: 0;
|
|
68
66
|
min-height: calc( var(--ck-line-height-base) * var(--ck-font-size-base) );
|
|
69
67
|
box-sizing: content-box;
|
|
70
68
|
|
|
69
|
+
@mixin ck-dir ltr {
|
|
70
|
+
padding-right: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@mixin ck-dir rtl {
|
|
74
|
+
padding-left: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
71
77
|
& > * {
|
|
72
78
|
white-space: normal;
|
|
73
79
|
color: inherit;
|
|
@@ -75,7 +81,14 @@
|
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
& .ck-spinner-container {
|
|
78
|
-
|
|
84
|
+
@mixin ck-dir ltr {
|
|
85
|
+
margin-right: var(--ck-spacing-medium);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@mixin ck-dir rtl {
|
|
89
|
+
margin-left: var(--ck-spacing-medium);
|
|
90
|
+
}
|
|
91
|
+
|
|
79
92
|
}
|
|
80
93
|
|
|
81
94
|
& .ck-ai-form__copy-button-wrapper {
|
|
@@ -126,14 +139,36 @@
|
|
|
126
139
|
flex-grow: 1;
|
|
127
140
|
}
|
|
128
141
|
|
|
129
|
-
& > .ck.ck-
|
|
130
|
-
|
|
142
|
+
& > .ck.ck-ai-form__submit {
|
|
143
|
+
@mixin ck-dir ltr {
|
|
144
|
+
margin-left: var(--ck-spacing-medium);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@mixin ck-dir rtl {
|
|
148
|
+
margin-right: var(--ck-spacing-medium);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
border-color: var(--ck-ai-form-submit-button-border-color);
|
|
152
|
+
color: var(--ck-ai-form-submit-button-text-color);
|
|
153
|
+
|
|
154
|
+
&.ck-disabled {
|
|
155
|
+
border-color: var(--ck-ai-form-submit-button-disabled-border-color);
|
|
156
|
+
}
|
|
131
157
|
}
|
|
132
158
|
|
|
133
|
-
|
|
159
|
+
/* Toggle history button */
|
|
160
|
+
& > .ck-labeled-field-view .ck-ai-form__toggle-history {
|
|
134
161
|
position: absolute;
|
|
135
162
|
font-size: var(--ck-font-size-tiny);
|
|
136
|
-
|
|
163
|
+
|
|
164
|
+
@mixin ck-dir ltr {
|
|
165
|
+
right: var(--ck-spacing-medium);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@mixin ck-dir rtl {
|
|
169
|
+
left: var(--ck-spacing-medium);
|
|
170
|
+
}
|
|
171
|
+
|
|
137
172
|
bottom: var(--ck-spacing-small);
|
|
138
173
|
top: var(--ck-spacing-small);
|
|
139
174
|
padding: 4px;
|
|
@@ -142,7 +177,14 @@
|
|
|
142
177
|
}
|
|
143
178
|
|
|
144
179
|
& .ck-textarea {
|
|
145
|
-
|
|
180
|
+
/* Give the toggle history button some space */
|
|
181
|
+
@mixin ck-dir ltr {
|
|
182
|
+
padding-right: 30px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@mixin ck-dir rtl {
|
|
186
|
+
padding-left: 30px;
|
|
187
|
+
}
|
|
146
188
|
}
|
|
147
189
|
|
|
148
190
|
/* Prompt history group */
|
|
@@ -166,9 +208,14 @@
|
|
|
166
208
|
font-size: var(--ck-ai-form-history-font-size);
|
|
167
209
|
justify-self: start;
|
|
168
210
|
background: none;
|
|
211
|
+
margin: var(--ck-spacing-medium) 0 0;
|
|
212
|
+
|
|
213
|
+
& .ck-button__label {
|
|
214
|
+
line-height: inherit;
|
|
169
215
|
|
|
170
|
-
|
|
171
|
-
|
|
216
|
+
&:hover {
|
|
217
|
+
text-decoration: underline;
|
|
218
|
+
}
|
|
172
219
|
}
|
|
173
220
|
}
|
|
174
221
|
|
package/theme/ai.css
CHANGED
|
@@ -10,7 +10,15 @@
|
|
|
10
10
|
/*
|
|
11
11
|
* These definitions bring violet accents (tint) across the AI UI.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
:root {
|
|
14
|
+
--ck-ai-form-submit-button-text-color: var(--ck-color-text);
|
|
15
|
+
--ck-ai-form-submit-button-border-color: transparent;
|
|
16
|
+
--ck-ai-form-submit-button-disabled-border-color: transparent;
|
|
17
|
+
--ck-ai-toolbar-button-hover-color: var(--ck-color-text);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Note: This class name is mentioned in the guide and acts like a public API. */
|
|
21
|
+
.ck-ai-assistant-ui_theme {
|
|
14
22
|
--ck-color-button-default-hover-background: hsl(262.1,100%,96.3%);
|
|
15
23
|
--ck-color-button-default-active-background: hsl(262.1,100%,96.3%);
|
|
16
24
|
|
|
@@ -28,22 +36,19 @@
|
|
|
28
36
|
--ck-color-list-button-hover-background: hsl(262.1,100%,96.3%);
|
|
29
37
|
|
|
30
38
|
--ck-ai-form-content-background: hsl(0,0%,97.6%);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
&.ck-disabled {
|
|
37
|
-
border-color: var(--ck-color-button-action-disabled-background);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&.ck-ai-commands-dropdown > .ck-button:hover,
|
|
42
|
-
&.ck-ai-assistant-button:hover {
|
|
43
|
-
color: var(--ck-color-button-on-color);
|
|
44
|
-
}
|
|
39
|
+
--ck-ai-form-submit-button-text-color: var(--ck-color-button-on-color);
|
|
40
|
+
--ck-ai-form-submit-button-border-color: var(--ck-color-button-action-background);
|
|
41
|
+
--ck-ai-form-submit-button-disabled-border-color: var(--ck-color-button-action-disabled-background);
|
|
42
|
+
--ck-ai-toolbar-button-hover-color: var(--ck-color-button-on-color);
|
|
45
43
|
}
|
|
46
44
|
|
|
45
|
+
/*
|
|
46
|
+
* Apply the theme colors for specific elements.
|
|
47
|
+
*/
|
|
48
|
+
.ck-ai-commands-dropdown > .ck-button:hover,
|
|
49
|
+
.ck-ai-assistant-button:hover {
|
|
50
|
+
color: var(--ck-ai-toolbar-button-hover-color);
|
|
51
|
+
}
|
|
47
52
|
|
|
48
53
|
/*
|
|
49
54
|
* Classes used by the "fake visual selection" displayed in the content when an input
|
package/src/aiconnector.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
6
|
-
/**
|
|
7
|
-
* The AI handler plugin that is responsible for the whole communication with AI.
|
|
8
|
-
* It uses the Adapter for OpenAI by default.
|
|
9
|
-
*/
|
|
10
|
-
export default class AIConnector extends Plugin {
|
|
11
|
-
/**
|
|
12
|
-
* The adapter instance which is used to handle the communication with AI API.
|
|
13
|
-
*/
|
|
14
|
-
adapter: Adapter;
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
static get pluginName(): "AIConnector";
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
constructor(editor: Editor);
|
|
23
|
-
/**
|
|
24
|
-
* Processes a user prompt and sends it to the AI API.
|
|
25
|
-
*
|
|
26
|
-
* @param prompt The user's prompt to be processed.
|
|
27
|
-
* @param context The context on which the prompt is used.
|
|
28
|
-
* @param onDataCallback The callback that is called after receiving content from AI API.
|
|
29
|
-
* @returns A Promise that resolves with the AI-generated response.
|
|
30
|
-
* @throws If sending the prompt to the AI API fails.
|
|
31
|
-
*/
|
|
32
|
-
processPrompt(prompt: string, context: string, onDataCallback: (content: string) => any): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* The method that stops the current request and then recreates the abort controller instance.
|
|
35
|
-
*/
|
|
36
|
-
abort(): void;
|
|
37
|
-
}
|
|
38
|
-
interface Adapter {
|
|
39
|
-
sendPrompt(systemMessage: string, userMessage: string, abortSignal: AbortSignal, onDataCallback: (content: string) => any): Promise<void>;
|
|
40
|
-
}
|
|
41
|
-
export declare class AIRequestError extends Error {
|
|
42
|
-
constructor(message: string);
|
|
43
|
-
}
|
|
44
|
-
export {};
|
package/src/aiconnector.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* +---------------------------------------------------------------------------------+
|
|
8
|
-
* | |
|
|
9
|
-
* | Hello stranger! |
|
|
10
|
-
* | |
|
|
11
|
-
* | |
|
|
12
|
-
* | What you're currently looking at is the source code of a legally protected, |
|
|
13
|
-
* | proprietary software. Any attempts to deobfuscate / disassemble this code |
|
|
14
|
-
* | are forbidden and will result in legal consequences. |
|
|
15
|
-
* | |
|
|
16
|
-
* | |
|
|
17
|
-
* +---------------------------------------------------------------------------------+
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
const _0x103a=['_cleanUpData','data:\x20','Instruction:\x0a','data','aiAssistant.requestParameters.model','Authorization','choices','user','match','aiconnector-send-prompt-failed','processor','aiAssistant.requestParameters.top_p','string','get','error','aiAssistant.requestParameters.max_tokens','authKey','_processStream','_domParser','content','body','reject','Bearer\x20','aiAssistant.requestParameters.temperature','aiAssistant.apiUrl','document','define','abort','adapter','toModel','startsWith','AI_ERROR_CONTEXT_LENGTH','text/html','filter','stringify','editing','top_p','join','processPrompt','_parseAndNormalizeContent','push','aborted','model','\x0aYou\x20must\x20keep\x20the\x20text\x20formatting.\x0a\x0aContent:\x0a','AIRequestError','https://api.openai.com/v1/chat/completions','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.','resolve','_authKey','serializeToString','_isBufferIncomplete','gpt-3.5-turbo','catch','<span>','AI_ERROR_MODERATION','toView','_apiUrl','length','includes','name','config','replace','_abortController','_requestParameters','parseFromString','_prepareMessages','[DONE]','_xmlSerializer','_normalizeResponseHeadings','signal','editor','aiAssistant.requestParameters','max_tokens','context_length_exceeded','split','getReader','AbortError','view','temperature','sendPrompt'];(function(_0x1ef6f4,_0x103aeb){const _0x214239=function(_0x50986a){while(--_0x50986a){_0x1ef6f4['push'](_0x1ef6f4['shift']());}};_0x214239(++_0x103aeb);}(_0x103a,0xe6));const _0x2142=function(_0x1ef6f4,_0x103aeb){_0x1ef6f4=_0x1ef6f4-0x0;let _0x214239=_0x103a[_0x1ef6f4];return _0x214239;};import{Matcher as _0x19670b,UpcastWriter as _0x5ea036}from'ckeditor5/src/engine';import{Plugin as _0x5dd575}from'ckeditor5/src/core';import{CKEditorError as _0x300097}from'ckeditor5/src/utils';import{getTranslation as _0x1e8118}from'./utils/common-translations';export default class o extends _0x5dd575{static get['pluginName'](){return'AIConnector';}constructor(_0x225eff){super(_0x225eff),_0x225eff[_0x2142('0x46')][_0x2142('0x24')](_0x2142('0x22'),_0x2142('0x37')),_0x225eff[_0x2142('0x46')][_0x2142('0x24')](_0x2142('0xe'),_0x2142('0x3d')),_0x225eff['config'][_0x2142('0x24')](_0x2142('0x19'),0x7d0),_0x225eff[_0x2142('0x46')][_0x2142('0x24')](_0x2142('0x21'),0x1),_0x225eff[_0x2142('0x46')]['define'](_0x2142('0x15'),0x1);const _0x46d1e2=_0x225eff[_0x2142('0x46')][_0x2142('0x17')](_0x2142('0x22')),_0x3b0781=_0x225eff['config'][_0x2142('0x17')]('aiAssistant')[_0x2142('0x1a')],_0x34da0=_0x225eff[_0x2142('0x46')][_0x2142('0x17')](_0x2142('0x1'));this[_0x2142('0x48')]=new AbortController(),this[_0x2142('0x26')]=new OpenAIAdapter(_0x225eff,_0x46d1e2,_0x34da0,_0x3b0781);}async[_0x2142('0x30')](_0x1388d7,_0x2deebb,_0x277f0f){const {systemMessage:_0xe954e4,userMessage:_0x197ede}=this[_0x2142('0x4b')](_0x1388d7,_0x2deebb);return this['adapter'][_0x2142('0x9')](_0xe954e4,_0x197ede,this[_0x2142('0x48')][_0x2142('0x4f')],_0x277f0f)[_0x2142('0x3e')](_0x4c14b1=>{if(_0x4c14b1 instanceof AIRequestError)return Promise[_0x2142('0x1f')](_0x4c14b1);if(_0x2142('0x6')==_0x4c14b1['name'])return Promise[_0x2142('0x39')]();throw console[_0x2142('0x18')](_0x4c14b1),new _0x300097(_0x2142('0x13'),null);});}[_0x2142('0x25')](){this[_0x2142('0x48')][_0x2142('0x4f')][_0x2142('0x33')]||(this[_0x2142('0x48')]['abort'](),this[_0x2142('0x48')]=new AbortController());}[_0x2142('0x4b')](_0x3d9883,_0x2c445c){let _0x23ceb6,_0x49f0ae;return _0x2c445c?(_0x23ceb6=_0x2142('0x38'),_0x49f0ae=_0x2142('0xc')+_0x3d9883+_0x2142('0x35')+(_0x2c445c[_0x2142('0x28')]('<')?_0x2c445c:_0x2142('0x3f')+_0x2c445c+'</span>')):(_0x23ceb6='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.',_0x49f0ae=_0x3d9883),{'systemMessage':_0x23ceb6,'userMessage':_0x49f0ae};}}export class OpenAIAdapter{constructor(_0x50e370,_0x518e06,_0x1ac30d,_0x4da0ab){this[_0x2142('0x0')]=_0x50e370,this['_apiUrl']=_0x518e06,this[_0x2142('0x3a')]=_0x4da0ab,this[_0x2142('0x49')]=_0x1ac30d,this[_0x2142('0x1c')]=new DOMParser(),this[_0x2142('0x4d')]=new XMLSerializer();}async[_0x2142('0x9')](_0x52614e,_0x352a8a,_0x10a71e,_0x5c2f2f){const _0x2b2d8a=this[_0x2142('0x0')]['locale'],_0x1ea3dd={'Content-Type':'application/json'};if(_0x2142('0x16')==typeof this[_0x2142('0x3a')])_0x1ea3dd[_0x2142('0xf')]='Bearer\x20'+this[_0x2142('0x3a')];else{if(this[_0x2142('0x3a')])try{const _0x4d127f=await this['_authKey']();_0x1ea3dd['Authorization']=_0x2142('0x20')+_0x4d127f;}catch(_0x29cf4f){return Promise['reject'](new AIRequestError(_0x1e8118(_0x2b2d8a,'AI_ERROR_AUTH_REQUEST')));}}const _0x20a17e={'model':this[_0x2142('0x49')][_0x2142('0x34')],'messages':[{'role':'system','content':_0x52614e},{'role':_0x2142('0x11'),'content':_0x352a8a}],'stream':!0x0,'max_tokens':this[_0x2142('0x49')][_0x2142('0x2')],'temperature':this[_0x2142('0x49')][_0x2142('0x8')],'top_p':this['_requestParameters'][_0x2142('0x2e')]};this[_0x2142('0x49')][_0x2142('0x11')]&&(_0x20a17e['user']=this['_requestParameters'][_0x2142('0x11')]);const _0x5d3232={'method':'POST','headers':_0x1ea3dd,'body':JSON[_0x2142('0x2c')](_0x20a17e),'signal':_0x10a71e},_0x425b87=await fetch(this[_0x2142('0x42')],_0x5d3232);if(_0x425b87['ok']){const _0x4dd59a=_0x425b87[_0x2142('0x1e')];return await this[_0x2142('0x1b')](_0x4dd59a,_0x5c2f2f),Promise[_0x2142('0x39')]();}{const _0x3912e6=await _0x425b87['text']();return _0x3912e6['includes'](_0x2142('0x3'))?Promise[_0x2142('0x1f')](new AIRequestError(_0x1e8118(_0x2b2d8a,_0x2142('0x29')))):_0x3912e6[_0x2142('0x44')]('Moderation')?Promise[_0x2142('0x1f')](new AIRequestError(_0x1e8118(_0x2b2d8a,_0x2142('0x40')))):Promise[_0x2142('0x1f')](new Error(_0x3912e6));}}async[_0x2142('0x1b')](_0x2a9f17,_0x5a7ba4){const _0x73ddc4=_0x2a9f17[_0x2142('0x5')](),_0x1d695b=new TextDecoder();let _0x54fa8f='',_0x167187='',_0x3569ba='',_0x239610=!0x1;for(;!_0x239610;){const {done:_0x1f3520,value:_0xbd38c7}=await _0x73ddc4['read'](),_0xdb8720=_0x54fa8f+_0x1d695b['decode'](_0xbd38c7);let _0x21d4f2='';_0x239610=_0x1f3520;try{_0x21d4f2=this[_0x2142('0xa')](_0xdb8720),_0x54fa8f='';}catch(_0x433d4f){_0x54fa8f+=_0xdb8720;continue;}_0x167187+=_0x21d4f2,!_0x1f3520&&this[_0x2142('0x3c')](_0x167187)||_0x167187&&(_0x3569ba+=_0x167187,_0x5a7ba4(this[_0x2142('0x31')](_0x3569ba)),_0x167187='');}return Promise[_0x2142('0x39')]();}[_0x2142('0x3c')](_0xa0d9e8){const _0x5131c1=_0xa0d9e8[_0x2142('0x4')]('<')[_0x2142('0x43')]!==_0xa0d9e8[_0x2142('0x4')]('>')['length'],_0x43a494=_0xa0d9e8[_0x2142('0x43')]<0x1e;return _0x5131c1&&_0x43a494;}['_parseAndNormalizeContent'](_0x1f6bea){const _0x1abe00=this[_0x2142('0x1c')][_0x2142('0x4a')](_0x1f6bea,_0x2142('0x2a')),_0x5332ad=this[_0x2142('0x0')][_0x2142('0xd')][_0x2142('0x14')][_0x2142('0x41')](this[_0x2142('0x4d')][_0x2142('0x3b')](_0x1abe00['body']));return this[_0x2142('0x4e')](_0x5332ad),this['editor']['data'][_0x2142('0x2c')](this[_0x2142('0x0')][_0x2142('0xd')][_0x2142('0x27')](_0x5332ad));}[_0x2142('0x4e')](_0x271f94){const _0x37bdb3=new _0x5ea036(this[_0x2142('0x0')][_0x2142('0x2d')][_0x2142('0x7')][_0x2142('0x23')]),_0x440035=new _0x19670b({'name':/^h[1-5]$/}),_0x1f1228=[];let _0x349e7f=!0x1;for(const _0x104f4f of _0x271f94)_0x104f4f['is']('element')&&_0x440035[_0x2142('0x12')](_0x104f4f)&&(_0x1f1228[_0x2142('0x32')](_0x104f4f),'h1'==_0x104f4f[_0x2142('0x45')]&&(_0x349e7f=!0x0));if(_0x349e7f)for(const _0x203ad3 of _0x1f1228)_0x37bdb3['rename']('h'+(parseInt(_0x203ad3[_0x2142('0x45')][0x1])+0x1),_0x203ad3);}[_0x2142('0xa')](_0x1ac8d3){return _0x1ac8d3['split']('\x0a')['map'](_0x17ec5b=>_0x17ec5b[_0x2142('0x47')](_0x2142('0xb'),''))['filter'](_0x122c73=>_0x122c73&&_0x122c73[_0x2142('0x43')]>0x0&&_0x2142('0x4c')!==_0x122c73)['map'](_0x389cb3=>JSON['parse'](_0x389cb3)[_0x2142('0x10')][0x0]['delta'][_0x2142('0x1d')])[_0x2142('0x2b')](_0x114a60=>_0x114a60)[_0x2142('0x2f')]('');}}export class AIRequestError extends Error{constructor(_0x1d0aff){super(_0x1d0aff),this[_0x2142('0x45')]=_0x2142('0x36');}}
|