@ckeditor/ckeditor5-ai 40.2.0 → 41.1.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 +14 -6
- package/README.md +10 -11
- package/build/ai.js +8 -8
- 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 -1
- 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 +3 -3
- package/lang/translations/af.po +14 -6
- package/lang/translations/ar.po +14 -6
- package/lang/translations/bg.po +14 -6
- package/lang/translations/bn.po +14 -6
- package/lang/translations/bs.po +14 -6
- package/lang/translations/ca.po +14 -6
- package/lang/translations/cs.po +14 -6
- package/lang/translations/da.po +14 -6
- package/lang/translations/de-ch.po +14 -6
- package/lang/translations/de.po +14 -6
- package/lang/translations/el.po +14 -6
- package/lang/translations/en-au.po +14 -6
- package/lang/translations/en.po +14 -6
- package/lang/translations/es-co.po +14 -6
- package/lang/translations/es.po +14 -6
- package/lang/translations/et.po +14 -6
- package/lang/translations/fa.po +14 -6
- package/lang/translations/fi.po +14 -6
- package/lang/translations/fr.po +14 -6
- package/lang/translations/gl.po +14 -6
- package/lang/translations/he.po +14 -6
- package/lang/translations/hi.po +14 -6
- package/lang/translations/hr.po +14 -6
- package/lang/translations/hu.po +14 -6
- package/lang/translations/id.po +14 -6
- package/lang/translations/it.po +28 -20
- package/lang/translations/ja.po +14 -6
- package/lang/translations/jv.po +14 -6
- package/lang/translations/ko.po +14 -6
- package/lang/translations/lt.po +14 -6
- package/lang/translations/lv.po +14 -6
- package/lang/translations/ms.po +14 -6
- package/lang/translations/nl.po +14 -6
- package/lang/translations/no.po +14 -6
- package/lang/translations/pl.po +14 -6
- package/lang/translations/pt-br.po +14 -6
- package/lang/translations/pt.po +14 -6
- package/lang/translations/ro.po +14 -6
- package/lang/translations/ru.po +14 -6
- package/lang/translations/sk.po +14 -6
- package/lang/translations/sr-latn.po +14 -6
- package/lang/translations/sr.po +14 -6
- package/lang/translations/sv.po +14 -6
- package/lang/translations/th.po +14 -6
- package/lang/translations/tk.po +14 -6
- package/lang/translations/tr.po +14 -6
- package/lang/translations/ug.po +14 -6
- package/lang/translations/uk.po +14 -6
- package/lang/translations/ur.po +14 -6
- package/lang/translations/uz.po +14 -6
- package/lang/translations/vi.po +14 -6
- package/lang/translations/zh-cn.po +14 -6
- package/lang/translations/zh.po +14 -6
- package/package.json +7 -5
- package/src/adapters/aiadapter.d.ts +3 -3
- package/src/adapters/aiadapter.js +2 -2
- package/src/adapters/aitextadapter.d.ts +3 -3
- package/src/adapters/aitextadapter.js +2 -2
- package/src/adapters/awstextadapter.d.ts +24 -24
- package/src/adapters/awstextadapter.js +2 -2
- package/src/adapters/openaitextadapter.d.ts +3 -3
- package/src/adapters/openaitextadapter.js +2 -2
- package/src/aiassistant.d.ts +5 -5
- package/src/aiassistant.js +2 -2
- package/src/aiassistantediting.d.ts +13 -12
- package/src/aiassistantediting.js +2 -2
- package/src/aiassistantui.d.ts +8 -8
- package/src/aiassistantui.js +2 -2
- package/src/aiconfig.d.ts +5 -5
- package/src/aiconfig.js +1 -1
- package/src/augmentation.d.ts +7 -7
- package/src/augmentation.js +1 -1
- package/src/index.d.ts +7 -7
- package/src/index.js +2 -2
- package/src/ui/aiassistantcontroller.d.ts +12 -12
- package/src/ui/aiassistantcontroller.js +2 -2
- package/src/ui/dropdown/aicommandslistview.d.ts +2 -2
- package/src/ui/dropdown/aicommandslistview.js +2 -2
- package/src/ui/dropdown/buttonlabelwithhighlightview.d.ts +2 -2
- package/src/ui/dropdown/buttonlabelwithhighlightview.js +2 -2
- package/src/ui/dropdown/labelwithhighlightview.d.ts +2 -2
- package/src/ui/dropdown/labelwithhighlightview.js +2 -2
- package/src/ui/form/aiformcontentarea.d.ts +3 -3
- package/src/ui/form/aiformcontentarea.js +2 -2
- package/src/ui/form/aiformerrorview.d.ts +3 -3
- package/src/ui/form/aiformerrorview.js +2 -2
- package/src/ui/form/aiformpromptview.d.ts +3 -3
- package/src/ui/form/aiformpromptview.js +2 -2
- package/src/ui/form/aiformtoolbarview.d.ts +12 -8
- package/src/ui/form/aiformtoolbarview.js +2 -2
- package/src/ui/form/aiformview.d.ts +13 -14
- package/src/ui/form/aiformview.js +2 -2
- package/src/ui/form/aihistorylistitemview.d.ts +3 -3
- package/src/ui/form/aihistorylistitemview.js +2 -2
- package/src/ui/form/aihistorylistview.d.ts +3 -3
- package/src/ui/form/aihistorylistview.js +2 -2
- package/src/ui/form/prompthistory.d.ts +2 -2
- package/src/ui/form/prompthistory.js +2 -2
- package/src/ui/showaiassistantcommand.d.ts +2 -2
- package/src/ui/showaiassistantcommand.js +2 -2
- package/src/utils/common-translations.d.ts +2 -2
- package/src/utils/common-translations.js +2 -2
- package/theme/ai-dropdown.css +1 -1
- package/theme/ai-form.css +16 -4
- package/theme/ai.css +17 -4
- package/theme/icons/robot-pencil.svg +0 -1
package/lang/translations/zh.po
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2003-
|
|
1
|
+
# Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
2
|
#
|
|
3
3
|
# !!! IMPORTANT !!!
|
|
4
4
|
#
|
|
@@ -133,7 +133,7 @@ msgctxt "Translate to (Arabic)"
|
|
|
133
133
|
msgid "Arabic"
|
|
134
134
|
msgstr "阿拉伯文"
|
|
135
135
|
|
|
136
|
-
msgctxt "The heading element name displayed in the AI
|
|
136
|
+
msgctxt "The heading element name displayed in the AI dialog and the button tooltip that opens the dialog."
|
|
137
137
|
msgid "AI Assistant"
|
|
138
138
|
msgstr "AI 助理"
|
|
139
139
|
|
|
@@ -173,7 +173,7 @@ msgctxt "The label that indicates the AI is generating content."
|
|
|
173
173
|
msgid "AI is writing..."
|
|
174
174
|
msgstr "AI 撰寫中..."
|
|
175
175
|
|
|
176
|
-
msgctxt "The label of the button that toggles the prompt history pane in the AI
|
|
176
|
+
msgctxt "The label of the button that toggles the prompt history pane in the AI dialog."
|
|
177
177
|
msgid "History"
|
|
178
178
|
msgstr "紀錄"
|
|
179
179
|
|
|
@@ -185,7 +185,7 @@ msgctxt "The secondary information text displayed when the prompt history is emp
|
|
|
185
185
|
msgid "Ask AI and your prompts will be listed here for you to use later."
|
|
186
186
|
msgstr "要求 AI 和您的提示詞會列出在此處,供您稍後使用。"
|
|
187
187
|
|
|
188
|
-
msgctxt "The label of the list group that hosts historical user prompts in the AI
|
|
188
|
+
msgctxt "The label of the list group that hosts historical user prompts in the AI dialog."
|
|
189
189
|
msgid "Prompt history"
|
|
190
190
|
msgstr "提示詞紀錄"
|
|
191
191
|
|
|
@@ -209,10 +209,18 @@ msgctxt "The label for the button that inserts the generated AI response."
|
|
|
209
209
|
msgid "AI_INSERT_CONTENT"
|
|
210
210
|
msgstr "插入"
|
|
211
211
|
|
|
212
|
-
msgctxt "Error message displayed when
|
|
213
|
-
msgid "
|
|
212
|
+
msgctxt "Error message displayed when preparing request headers fails."
|
|
213
|
+
msgid "AI_ERROR_GET_HEADERS"
|
|
214
214
|
msgstr "要求標頭準備失敗"
|
|
215
215
|
|
|
216
|
+
msgctxt "Error message displayed when preparing request parameters fails."
|
|
217
|
+
msgid "AI_ERROR_GET_PARAMETERS"
|
|
218
|
+
msgstr "要求參數準備失敗"
|
|
219
|
+
|
|
220
|
+
msgctxt "Error message displayed when the requested AI model is not supported."
|
|
221
|
+
msgid "AI_ERROR_UNSUPPORTED_MODEL"
|
|
222
|
+
msgstr "不支援要求的 AI 模型(\"%0\")"
|
|
223
|
+
|
|
216
224
|
msgctxt "Error message displayed when the content selected for AI processing is too long"
|
|
217
225
|
msgid "AI_ERROR_CONTEXT_LENGTH"
|
|
218
226
|
msgstr "選取內容過長"
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-ai",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "AI
|
|
3
|
+
"version": "41.1.0",
|
|
4
|
+
"description": "AI Assistant feature for CKEditor 5.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "CKSource (http://cksource.com/)",
|
|
7
|
-
"homepage": "https://ckeditor.com/
|
|
7
|
+
"homepage": "https://ckeditor.com/ckeditor-5",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"CKEditor",
|
|
10
10
|
"ckeditor5",
|
|
@@ -23,11 +23,13 @@
|
|
|
23
23
|
"framework"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"ckeditor5": "
|
|
26
|
+
"ckeditor5": "41.1.0",
|
|
27
|
+
"ckeditor5-collaboration": "41.1.0",
|
|
27
28
|
"@aws-sdk/client-bedrock-runtime": "3.470.0",
|
|
28
|
-
"@ckeditor/ckeditor5-ui": "
|
|
29
|
+
"@ckeditor/ckeditor5-ui": "41.1.0",
|
|
29
30
|
"lodash-es": "4.17.21"
|
|
30
31
|
},
|
|
32
|
+
"type": "module",
|
|
31
33
|
"main": "src/index.js",
|
|
32
34
|
"files": [
|
|
33
35
|
"lang",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module ai/adapters/aiadapter
|
|
7
7
|
* @publicApi
|
|
8
8
|
*/
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
-
import type AITextAdapter from './aitextadapter';
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
+
import type AITextAdapter from './aitextadapter.js';
|
|
11
11
|
/**
|
|
12
12
|
* Main adapter plugin that is a common interface between AI features and AI adapters.
|
|
13
13
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2003-
|
|
2
|
+
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
*
|
|
5
5
|
*
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
var
|
|
23
|
+
var _0x3e1a=['afterInit','textAdapter','aiadapter-text-adapter-not-set','AIAdapter'];(function(_0x2858ee,_0x3e1a7e){var _0x358868=function(_0x5e2924){while(--_0x5e2924){_0x2858ee['push'](_0x2858ee['shift']());}};_0x358868(++_0x3e1a7e);}(_0x3e1a,0x10d));var _0x3588=function(_0x2858ee,_0x3e1a7e){_0x2858ee=_0x2858ee-0x0;var _0x358868=_0x3e1a[_0x2858ee];return _0x358868;};import{Plugin as _0x2936d1}from'ckeditor5/src/core.js';import{CKEditorError as _0xa67f6d}from'ckeditor5/src/utils.js';export default class I extends _0x2936d1{static get['pluginName'](){return _0x3588('0x2');}[_0x3588('0x3')](){if(!this[_0x3588('0x0')])throw new _0xa67f6d(_0x3588('0x1'),null);}}export class AIRequestError extends Error{constructor(_0x18183f){super(_0x18183f),this['name']='AIRequestError';}}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module ai/adapters/aitextadapter
|
|
7
7
|
* @publicApi
|
|
8
8
|
*/
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
-
import { default as AIAdapter } from './aiadapter';
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
+
import { default as AIAdapter } from './aiadapter.js';
|
|
11
11
|
/**
|
|
12
12
|
* Abstract base class for AI adapters that perform text-related requests.
|
|
13
13
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2003-
|
|
2
|
+
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
*
|
|
5
5
|
*
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x4cc4=['_prepareRequestHeaders','object','textAdapter','AI_ERROR_GET_HEADERS','assign','get','editor','abortController','name','locale','AI_ERROR_GET_PARAMETERS','aitextadapter-send-request-failed','requires','catch','_prepareRequestParameters','reject','aborted','sendRequest','error'];(function(_0x5ce10e,_0x4cc4a5){const _0x4c57af=function(_0x442832){while(--_0x442832){_0x5ce10e['push'](_0x5ce10e['shift']());}};_0x4c57af(++_0x4cc4a5);}(_0x4cc4,0x1ea));const _0x4c57=function(_0x5ce10e,_0x4cc4a5){_0x5ce10e=_0x5ce10e-0x0;let _0x4c57af=_0x4cc4[_0x5ce10e];return _0x4c57af;};import{Plugin as _0x309e29}from'ckeditor5/src/core.js';import{CKEditorError as _0x15d04f}from'ckeditor5/src/utils.js';import{default as _0x54ce66,AIRequestError as _0x202888}from'./aiadapter.js';import{getTranslation as _0x4d3a16}from'../utils/common-translations.js';export default class _ extends _0x309e29{static get[_0x4c57('0x10')](){return[_0x54ce66];}constructor(_0x715b2c){super(_0x715b2c),this[_0x4c57('0xb')]=new AbortController();}['init'](){this[_0x4c57('0xa')]['plugins'][_0x4c57('0x9')](_0x54ce66)[_0x4c57('0x6')]=this;}['abort'](){this[_0x4c57('0xb')]['signal'][_0x4c57('0x1')]||(this[_0x4c57('0xb')]['abort'](),this[_0x4c57('0xb')]=new AbortController());}async['makeRequest'](_0x4759db){return this[_0x4c57('0x2')](_0x4759db)[_0x4c57('0x11')](_0x43f1c9=>{if(_0x43f1c9 instanceof _0x202888)return Promise['reject'](_0x43f1c9);if('AbortError'==_0x43f1c9[_0x4c57('0xc')])return Promise['resolve']();throw console[_0x4c57('0x3')](_0x43f1c9),new _0x15d04f(_0x4c57('0xf'),null);});}async[_0x4c57('0x4')](_0x2dcc84,_0x46e1ff){const _0x5bb98f=this['editor'][_0x4c57('0xd')],_0x55e616={'Content-Type':'application/json'};if(_0x4c57('0x5')==typeof _0x2dcc84)Object[_0x4c57('0x8')](_0x55e616,_0x2dcc84);else{if(_0x2dcc84)try{const _0x1ff915=await _0x2dcc84(_0x46e1ff);Object[_0x4c57('0x8')](_0x55e616,_0x1ff915);}catch(_0x58be44){return Promise['reject'](new _0x202888(_0x4d3a16(_0x5bb98f,_0x4c57('0x7'))));}}return _0x55e616;}async[_0x4c57('0x12')](_0x36792c,_0x120151){const _0x42efb7=this[_0x4c57('0xa')][_0x4c57('0xd')];if(_0x4c57('0x5')==typeof _0x36792c)return _0x36792c;try{return await _0x36792c(_0x120151);}catch(_0x45fd88){return Promise[_0x4c57('0x0')](new _0x202888(_0x4d3a16(_0x42efb7,_0x4c57('0xe'))));}}}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module ai/adapters/awstextadapter
|
|
7
7
|
* @publicApi
|
|
8
8
|
*/
|
|
9
|
-
import { type Editor } from 'ckeditor5/src/core';
|
|
10
|
-
import { default as AITextAdapter, type AITextAdapterRequestData, type RequestHeaders, type RequestParameters } from './aitextadapter';
|
|
9
|
+
import { type Editor } from 'ckeditor5/src/core.js';
|
|
10
|
+
import { default as AITextAdapter, type AITextAdapterRequestData, type RequestHeaders, type RequestParameters } from './aitextadapter.js';
|
|
11
11
|
import { type BedrockRuntimeClientConfig } from '@aws-sdk/client-bedrock-runtime';
|
|
12
12
|
/**
|
|
13
|
-
* Adapter for AI text-related requests that supports
|
|
13
|
+
* Adapter for AI text-related requests that supports the Amazon Bedrock service.
|
|
14
14
|
*
|
|
15
15
|
* See also {@link module:ai/adapters/aitextadapter~AITextAdapter}.
|
|
16
16
|
*/
|
|
@@ -24,13 +24,13 @@ export default class AWSTextAdapter extends AITextAdapter {
|
|
|
24
24
|
*/
|
|
25
25
|
constructor(editor: Editor);
|
|
26
26
|
/**
|
|
27
|
-
* Performs the request to the
|
|
27
|
+
* Performs the request to the Amazon Bedrock service or to the endpoint provided in the editor configuration.
|
|
28
28
|
*
|
|
29
29
|
* If you want to extend this adapter, you can overload this method to do some additional processing or make an external call.
|
|
30
30
|
*/
|
|
31
31
|
sendRequest({ query, context, onData, actionId }: AITextAdapterRequestData): Promise<void>;
|
|
32
32
|
/**
|
|
33
|
-
* Prepares the actual full prompt for the request to the
|
|
33
|
+
* Prepares the actual full prompt for the request to the Amazon Bedrock API.
|
|
34
34
|
*
|
|
35
35
|
* The prompt may differ depending on what model is used.
|
|
36
36
|
*
|
|
@@ -43,18 +43,18 @@ export default class AWSTextAdapter extends AITextAdapter {
|
|
|
43
43
|
*/
|
|
44
44
|
preparePrompt(query: string, context: string, model: string, actionId: string): Promise<string>;
|
|
45
45
|
/**
|
|
46
|
-
* For given
|
|
46
|
+
* For a given model, it returns the family to which this model belongs.
|
|
47
47
|
*
|
|
48
|
-
* For example, for `anthropic.claude-instant-v1` will return `anthropic.claude`.
|
|
48
|
+
* For example, for `anthropic.claude-instant-v1` it will return `anthropic.claude`.
|
|
49
49
|
*
|
|
50
|
-
* Throws {@link module:ai/adapters/aiadapter~AIRequestError `AIRequestError`} if given
|
|
50
|
+
* Throws {@link module:ai/adapters/aiadapter~AIRequestError `AIRequestError`} if a given model is not supported.
|
|
51
51
|
*/
|
|
52
52
|
getModelFamily(model: string): AWSModelFamily;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* The configuration for the
|
|
55
|
+
* The configuration for the Amazon Bedrock adapter.
|
|
56
56
|
*
|
|
57
|
-
* The properties defined in this
|
|
57
|
+
* The properties defined in this configuration are set in the `config.ai.aws` namespace.
|
|
58
58
|
*
|
|
59
59
|
* ```ts
|
|
60
60
|
* ClassicEditor
|
|
@@ -77,20 +77,20 @@ export interface AWSTextAdapterConfig {
|
|
|
77
77
|
/**
|
|
78
78
|
* The URL to which the AI service request will be sent.
|
|
79
79
|
*
|
|
80
|
-
* Set this value only if you want to connect to
|
|
80
|
+
* Set this value only if you want to connect to Amazon Bedrock using a proxy endpoint.
|
|
81
81
|
*
|
|
82
82
|
* If `apiUrl` is not provided, the AWS-SDK library will be used to process the request. It will set a proper URL on its own.
|
|
83
83
|
*/
|
|
84
84
|
apiUrl?: string;
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* An object with headers to set in the request to the AI service.
|
|
87
87
|
*
|
|
88
|
-
* **These headers are only used when connecting to AWS through the proxy endpoint (
|
|
88
|
+
* **These headers are only used when connecting to AWS through the proxy endpoint (that is, when `apiUrl` is set).**
|
|
89
89
|
*
|
|
90
|
-
* Otherwise, AWS-SDK library is used, and it sets the request headers on its own. In this mode, the request headers cannot be
|
|
90
|
+
* Otherwise, the AWS-SDK library is used, and it sets the request headers on its own. In this mode, the request headers cannot be
|
|
91
91
|
* customized.
|
|
92
92
|
*
|
|
93
|
-
* If the provided value is an
|
|
93
|
+
* If the provided value is an object, it is simply used as provided.
|
|
94
94
|
*
|
|
95
95
|
* ```js
|
|
96
96
|
* {
|
|
@@ -105,9 +105,9 @@ export interface AWSTextAdapterConfig {
|
|
|
105
105
|
* }
|
|
106
106
|
* ```
|
|
107
107
|
*
|
|
108
|
-
* If the provided value is a function, it should be a function that returns a
|
|
108
|
+
* If the provided value is a function, it should be a function that returns a promise which resolves with the headers object.
|
|
109
109
|
* This way, you can perform an authorization request to your application and receive the authorization token (and also implement
|
|
110
|
-
* any custom logic on the
|
|
110
|
+
* any custom logic on the backend side). The headers object is then used to make the actual call to the AI service.
|
|
111
111
|
*
|
|
112
112
|
* ```js
|
|
113
113
|
* {
|
|
@@ -126,7 +126,7 @@ export interface AWSTextAdapterConfig {
|
|
|
126
126
|
* }
|
|
127
127
|
* ```
|
|
128
128
|
*
|
|
129
|
-
* The function is passed {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
|
|
129
|
+
* The function is passed the {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
|
|
130
130
|
* possible to further customize the headers.
|
|
131
131
|
*
|
|
132
132
|
* If the function fails for any reason, the promise should be rejected. In this case, a feature that made the request should display
|
|
@@ -141,12 +141,12 @@ export interface AWSTextAdapterConfig {
|
|
|
141
141
|
*
|
|
142
142
|
* See [AWS model parameters reference](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html) to learn more.
|
|
143
143
|
*
|
|
144
|
-
* If the provided value is an
|
|
144
|
+
* If the provided value is an object, it is passed to the request as provided.
|
|
145
145
|
*
|
|
146
|
-
* If the provided value is a function, it should be a function that returns a
|
|
146
|
+
* If the provided value is a function, it should be a function that returns a promise which resolves with the request parameters
|
|
147
147
|
* object. This gives you more flexibility to provide parameters for the AI model.
|
|
148
148
|
*
|
|
149
|
-
* The function is passed {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
|
|
149
|
+
* The function is passed the {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
|
|
150
150
|
* possible to further customize the parameters.
|
|
151
151
|
*
|
|
152
152
|
* If the function fails for any reason, the promise should be rejected. In this case, the feature that made the request should display
|
|
@@ -168,10 +168,10 @@ export interface AWSTextAdapterConfig {
|
|
|
168
168
|
*/
|
|
169
169
|
requestParameters?: RequestParameters;
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
171
|
+
* The configuration for AWS-SDK Bedrock Runtime Client.
|
|
172
172
|
*
|
|
173
173
|
* If `apiUrl` is not provided, this configuration will be used to initialize the Bedrock Runtime Client which will be used to process
|
|
174
|
-
* the requests. The adapter will make requests directly to the
|
|
174
|
+
* the requests. The adapter will make requests directly to the Amazon Bedrock service.
|
|
175
175
|
*/
|
|
176
176
|
bedrockClientConfig?: BedrockRuntimeClientConfig;
|
|
177
177
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2003-
|
|
2
|
+
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
*
|
|
5
5
|
*
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x5de3=['generations','parse','join','define','length','split','_getGeneratedText','meta.llama','_readStaticResponse','map','chunk','startsWith','editor','_apiUrl','bytes','pluginName','_prepareRequestParameters','decode','preparePrompt','utf8','\x0aYou\x20must\x20keep\x20the\x20text\x20formatting.\x0a\x0aContent:\x0a','_prepareRequestHeaders','cohere.command','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.','anthropic.claude-v2','text','AI_ERROR_UNSUPPORTED_MODEL','config','POST','ai.aws.requestParameters','data','ai.aws.requestParameters.model','utf-8','read','sendRequest','locale','send','_requestParameters','_processProxyRequest','<<SYS>>\x0a','ai.aws.requestParameters.temperature','_requestHeaders','ai.aws.requestParameters.top_p','anthropic.claude','json','ai.aws.requestParameters.anthropic_version','\x0a[/INST]','resolve','generation','signal','Human:\x0a','_processAWSRequest','application/json','<span>','_readAsyncIterableResponse','_bedrockClientConfig','ai.aws.requestParameters.max_tokens_to_sample','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.','get','\x0a\x0aAssistant:','getModelFamily','from','abortController','AWSTextAdapter','ai.aws.apiUrl','ai21.j2','_readStreamableResponse','test','\x0a<</SYS>>\x0a[INST]\x0a','body','bedrock-2023-05-31','ai.aws.requestParameters.stream','toString'];(function(_0x32001c,_0x5de3e2){const _0x18bdbb=function(_0x3fa6e2){while(--_0x3fa6e2){_0x32001c['push'](_0x32001c['shift']());}};_0x18bdbb(++_0x5de3e2);}(_0x5de3,0x136));const _0x18bd=function(_0x32001c,_0x5de3e2){_0x32001c=_0x32001c-0x0;let _0x18bdbb=_0x5de3[_0x32001c];return _0x18bdbb;};import{default as _0x13f561}from'./aitextadapter.js';import{AIRequestError as _0x1d4e40}from'./aiadapter.js';import{BedrockRuntimeClient as _0x2ae28e,InvokeModelCommand as _0x553b5e,InvokeModelWithResponseStreamCommand as _0xe6f000}from'@aws-sdk/client-bedrock-runtime';import{getTranslation as _0x345e6f}from'../utils/common-translations.js';export default class H extends _0x13f561{static get[_0x18bd('0x46')](){return _0x18bd('0x2d');}constructor(_0x5c09a4){super(_0x5c09a4),_0x5c09a4[_0x18bd('0x9')][_0x18bd('0x28')](_0x18bd('0xb'))||(_0x5c09a4[_0x18bd('0x9')][_0x18bd('0x3a')](_0x18bd('0xd'),_0x18bd('0x6')),_0x5c09a4[_0x18bd('0x9')][_0x18bd('0x3a')](_0x18bd('0x26'),0x7d0),_0x5c09a4['config'][_0x18bd('0x3a')](_0x18bd('0x16'),0x1),_0x5c09a4['config']['define'](_0x18bd('0x18'),0x1),_0x5c09a4[_0x18bd('0x9')]['define']('ai.aws.requestParameters.top_k',0xfa),_0x5c09a4[_0x18bd('0x9')][_0x18bd('0x3a')](_0x18bd('0x1b'),_0x18bd('0x34')),_0x5c09a4[_0x18bd('0x9')][_0x18bd('0x3a')](_0x18bd('0x35'),!0x0)),this[_0x18bd('0x44')]=_0x5c09a4[_0x18bd('0x9')][_0x18bd('0x28')](_0x18bd('0x2e')),this[_0x18bd('0x25')]=_0x5c09a4[_0x18bd('0x9')]['get']('ai.aws.bedrockClientConfig'),this['_requestHeaders']=_0x5c09a4[_0x18bd('0x9')][_0x18bd('0x28')]('ai.aws.requestHeaders'),this[_0x18bd('0x13')]=_0x5c09a4[_0x18bd('0x9')][_0x18bd('0x28')](_0x18bd('0xb'));}async[_0x18bd('0x10')]({query:_0x28f2ba,context:_0x477c7a,onData:_0x32819f,actionId:_0x36ce98}){const {model:_0x2d9519,stream:_0x351950,..._0x5cc5a7}=await this[_0x18bd('0x47')](this[_0x18bd('0x13')],_0x36ce98),_0x30dfd2={'prompt':await this[_0x18bd('0x0')](_0x28f2ba,_0x477c7a,_0x2d9519,_0x36ce98),..._0x5cc5a7};this[_0x18bd('0x44')]?await this[_0x18bd('0x14')](_0x30dfd2,_0x2d9519,_0x351950,_0x32819f,_0x36ce98):await this[_0x18bd('0x21')](_0x30dfd2,_0x2d9519,_0x351950,_0x32819f);}async['preparePrompt'](_0x3c9fdf,_0x2bb000,_0x2c71c5,_0x22df88){let _0x4f040c,_0x5b4662;return _0x2bb000?(_0x4f040c=_0x18bd('0x5'),_0x5b4662='Instruction:\x0a'+_0x3c9fdf+_0x18bd('0x2')+(_0x2bb000[_0x18bd('0x42')]('<')?_0x2bb000:_0x18bd('0x23')+_0x2bb000+'</span>')):(_0x4f040c=_0x18bd('0x27'),_0x5b4662=_0x3c9fdf),_0x18bd('0x3e')==this[_0x18bd('0x2a')](_0x2c71c5)?_0x18bd('0x15')+_0x4f040c+_0x18bd('0x32')+_0x5b4662+_0x18bd('0x1c'):_0x18bd('0x20')+_0x4f040c+'\x0a'+_0x5b4662+_0x18bd('0x29');}['getModelFamily'](_0xf34857){if(/^anthropic\.claude/['test'](_0xf34857))return _0x18bd('0x19');if(/^ai21\.j2/['test'](_0xf34857))return _0x18bd('0x2f');if(/^cohere\.command/[_0x18bd('0x31')](_0xf34857))return _0x18bd('0x4');if(/^meta\.llama/[_0x18bd('0x31')](_0xf34857))return _0x18bd('0x3e');throw new _0x1d4e40(_0x345e6f(this[_0x18bd('0x43')][_0x18bd('0x11')],_0x18bd('0x8'),_0xf34857));}async[_0x18bd('0x14')](_0x51dcff,_0x40d99e,_0x3eab8a,_0xe11e73,_0x9b79a){const _0x55f2cb={'method':_0x18bd('0xa'),'headers':await this[_0x18bd('0x3')](this[_0x18bd('0x17')],_0x9b79a),'body':JSON['stringify']({..._0x51dcff,'model':_0x40d99e,'stream':_0x3eab8a}),'signal':this[_0x18bd('0x2c')][_0x18bd('0x1f')]},_0x586dbe=await fetch(this[_0x18bd('0x44')],_0x55f2cb);_0x3eab8a?await this[_0x18bd('0x30')](_0x586dbe,_0x40d99e,_0xe11e73):await this[_0x18bd('0x3f')](_0x586dbe,_0x40d99e,_0xe11e73);}async[_0x18bd('0x21')](_0x1fb200,_0x46b3d8,_0x388b5b,_0x36695d){const _0x112a63=new _0x2ae28e(this['_bedrockClientConfig']),_0x11b4d0={'body':JSON['stringify'](_0x1fb200),'contentType':_0x18bd('0x22'),'accept':_0x18bd('0x22'),'modelId':_0x46b3d8};let _0x45bd74;if(_0x388b5b){const _0x36c55f=new _0xe6f000(_0x11b4d0);_0x45bd74=await _0x112a63[_0x18bd('0x12')](_0x36c55f,{'abortSignal':this[_0x18bd('0x2c')]['signal']}),await this[_0x18bd('0x24')](_0x45bd74,_0x46b3d8,_0x36695d);}else{const _0x51fcbc=new _0x553b5e(_0x11b4d0);_0x45bd74=await _0x112a63[_0x18bd('0x12')](_0x51fcbc,{'abortSignal':this[_0x18bd('0x2c')][_0x18bd('0x1f')]}),await this[_0x18bd('0x3f')](_0x45bd74,_0x46b3d8,_0x36695d);}}async['_readAsyncIterableResponse'](_0x354bce,_0x5af67d,_0x2bef6b){const _0x7653c9=_0x354bce['body'],_0x14e6cd=new TextDecoder(_0x18bd('0xe'));let _0x219d2c='';for await(const _0x4e67d5 of _0x7653c9)if(_0x4e67d5[_0x18bd('0x41')]){const _0x865ffc=_0x14e6cd[_0x18bd('0x48')](_0x4e67d5[_0x18bd('0x41')][_0x18bd('0x45')]),_0x2f4295=JSON[_0x18bd('0x38')](_0x865ffc);_0x219d2c+=this['_getGeneratedText'](_0x2f4295,_0x5af67d),_0x2bef6b(_0x219d2c);}return Promise[_0x18bd('0x1d')]();}async[_0x18bd('0x30')](_0x119c9f,_0xc5eeae,_0x2af72e){const _0x177d38=_0x119c9f[_0x18bd('0x33')],_0x3df6c8=new TextDecoder(_0x18bd('0xe')),_0x31b2cf=_0x177d38['getReader']();let _0x49446d='',_0x21a66e='',_0xfb0c20=!0x1;for(;!_0xfb0c20;){const {done:_0x215369,value:_0x24e6ea}=await _0x31b2cf[_0x18bd('0xf')]();if(_0xfb0c20=_0x215369,_0xfb0c20)break;const _0xea4002=(_0x49446d+_0x3df6c8[_0x18bd('0x48')](_0x24e6ea))[_0x18bd('0x3c')]('\x0a')[_0x18bd('0x40')](_0x37cbe6=>{try{return _0x49446d='',JSON[_0x18bd('0x38')](_0x37cbe6);}catch(_0x1e64b8){return _0x49446d=_0x37cbe6,null;}})['filter'](_0x2d56b1=>null!==_0x2d56b1);_0xea4002[_0x18bd('0x3b')]&&(_0x21a66e+=_0xea4002[_0x18bd('0x40')](_0x4acd94=>this[_0x18bd('0x3d')](_0x4acd94,_0xc5eeae))[_0x18bd('0x39')](''),_0x2af72e(_0x21a66e));}return Promise['resolve']();}async[_0x18bd('0x3f')](_0x129914,_0x503985,_0x422db2){let _0x113856;return _0x113856=_0x129914 instanceof Response?await _0x129914[_0x18bd('0x1a')]():JSON[_0x18bd('0x38')](Buffer[_0x18bd('0x2b')](_0x129914[_0x18bd('0x33')])[_0x18bd('0x36')](_0x18bd('0x1'))),(_0x422db2(this[_0x18bd('0x3d')](_0x113856,_0x503985)),Promise[_0x18bd('0x1d')]());}[_0x18bd('0x3d')](_0x43c510,_0x4ecbcf){switch(this['getModelFamily'](_0x4ecbcf)){case _0x18bd('0x19'):return _0x43c510['completion'];case _0x18bd('0x2f'):return _0x43c510['completions'][0x0][_0x18bd('0xc')][_0x18bd('0x7')];case _0x18bd('0x4'):return _0x43c510[_0x18bd('0x37')][0x0]['text'];case _0x18bd('0x3e'):return _0x43c510[_0x18bd('0x1e')];}}}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module ai/adapters/openaitextadapter
|
|
7
7
|
* @publicApi
|
|
8
8
|
*/
|
|
9
|
-
import { type Editor } from 'ckeditor5/src/core';
|
|
10
|
-
import { default as AITextAdapter, type AITextAdapterRequestData, type RequestHeaders, type RequestParameters } from './aitextadapter';
|
|
9
|
+
import { type Editor } from 'ckeditor5/src/core.js';
|
|
10
|
+
import { default as AITextAdapter, type AITextAdapterRequestData, type RequestHeaders, type RequestParameters } from './aitextadapter.js';
|
|
11
11
|
/**
|
|
12
12
|
* Adapter for AI text-related requests that supports OpenAI and Azure OpenAI services.
|
|
13
13
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2003-
|
|
2
|
+
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
*
|
|
5
5
|
*
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x13a4=['_readStaticResponse','ai.openAI.requestHeaders','system','decode','ai.openAI.requestParameters.stream','ai.openAI.requestParameters.temperature','AI_ERROR_CONTEXT_LENGTH','pluginName','get','startsWith','gpt-3.5-turbo','text','sendRequest','_cleanUpData','user','_isBufferIncomplete','ai.openAI.requestParameters.max_tokens','stringify','https://api.openai.com/v1/chat/completions','filter','json','message','_requestParameters','config','signal','ai.openAI.requestParameters.top_p','_apiUrl','_prepareRequestParameters','includes','locale','body','resolve','length','context_length_exceeded','join','split','replace','AI_ERROR_MODERATION','\x0aYou\x20must\x20keep\x20the\x20text\x20formatting.\x0a\x0aContent:\x0a','ai.openAI.requestParameters','define','reject','getReader','</span>','content','abortController','_prepareRequestHeaders','map','read','parse','editor','_readStreamableResponse','delta','_requestHeaders','ai.openAI.apiUrl','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.'];(function(_0x1d5d48,_0x13a402){const _0x48e6e9=function(_0x43a03f){while(--_0x43a03f){_0x1d5d48['push'](_0x1d5d48['shift']());}};_0x48e6e9(++_0x13a402);}(_0x13a4,0xdf));const _0x48e6=function(_0x1d5d48,_0x13a402){_0x1d5d48=_0x1d5d48-0x0;let _0x48e6e9=_0x13a4[_0x1d5d48];return _0x48e6e9;};import{default as _0x300c5b}from'./aitextadapter.js';import{AIRequestError as _0x166f65}from'./aiadapter.js';import{getTranslation as _0x24a014}from'../utils/common-translations.js';export default class M extends _0x300c5b{static get[_0x48e6('0x8')](){return'OpenAITextAdapter';}constructor(_0x26a33a){super(_0x26a33a),_0x26a33a[_0x48e6('0x18')][_0x48e6('0x29')](_0x48e6('0x37'),_0x48e6('0x13')),_0x26a33a[_0x48e6('0x18')][_0x48e6('0x29')]('ai.openAI.requestParameters.model',_0x48e6('0xb')),_0x26a33a['config'][_0x48e6('0x29')](_0x48e6('0x11'),0x7d0),_0x26a33a[_0x48e6('0x18')]['define'](_0x48e6('0x6'),0x1),_0x26a33a['config'][_0x48e6('0x29')](_0x48e6('0x1a'),0x1),_0x26a33a[_0x48e6('0x18')][_0x48e6('0x29')](_0x48e6('0x5'),!0x0),this[_0x48e6('0x1b')]=_0x26a33a['config'][_0x48e6('0x9')]('ai.openAI.apiUrl'),this[_0x48e6('0x36')]=_0x26a33a[_0x48e6('0x18')]['get'](_0x48e6('0x2'))||{},this[_0x48e6('0x17')]=_0x26a33a[_0x48e6('0x18')][_0x48e6('0x9')](_0x48e6('0x28'));}async[_0x48e6('0xd')]({query:_0x49853b,context:_0x7c03d3,onData:_0x309e72,actionId:_0x208c9d}){const _0x37b476=this[_0x48e6('0x33')][_0x48e6('0x1e')],_0x57f78e=await this['prepareMessages'](_0x49853b,_0x7c03d3,_0x208c9d),_0x38413f=await this[_0x48e6('0x2f')](this[_0x48e6('0x36')],_0x208c9d),_0x128b9c=await this[_0x48e6('0x1c')](this['_requestParameters'],_0x208c9d),_0x45c089={'messages':_0x57f78e,..._0x128b9c},_0x22a242={'method':'POST','headers':_0x38413f,'body':JSON[_0x48e6('0x12')](_0x45c089),'signal':this[_0x48e6('0x2e')][_0x48e6('0x19')]},_0x4a1ba3=await fetch(this[_0x48e6('0x1b')],_0x22a242);if(_0x4a1ba3['ok'])return _0x128b9c['stream']?await this[_0x48e6('0x34')](_0x4a1ba3,_0x309e72):await this[_0x48e6('0x1')](_0x4a1ba3,_0x309e72),Promise[_0x48e6('0x20')]();{const _0x13e3c0=await _0x4a1ba3[_0x48e6('0xc')]();return _0x13e3c0['includes'](_0x48e6('0x22'))?Promise[_0x48e6('0x2a')](new _0x166f65(_0x24a014(_0x37b476,_0x48e6('0x7')))):_0x13e3c0[_0x48e6('0x1d')]('Moderation')?Promise['reject'](new _0x166f65(_0x24a014(_0x37b476,_0x48e6('0x26')))):Promise[_0x48e6('0x2a')](new Error(_0x13e3c0));}}async['prepareMessages'](_0x588b4f,_0x523609,_0x5b8ab6){let _0x51d716,_0x4c40d8;return _0x523609?(_0x51d716=_0x48e6('0x0'),_0x4c40d8='Instruction:\x0a'+_0x588b4f+_0x48e6('0x27')+(_0x523609[_0x48e6('0xa')]('<')?_0x523609:'<span>'+_0x523609+_0x48e6('0x2c'))):(_0x51d716='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.',_0x4c40d8=_0x588b4f),[{'role':_0x48e6('0x3'),'content':_0x51d716},{'role':_0x48e6('0xf'),'content':_0x4c40d8}];}async[_0x48e6('0x34')](_0x313dd8,_0x1912f0){const _0xc7fd1c=_0x313dd8[_0x48e6('0x1f')][_0x48e6('0x2b')](),_0x233351=new TextDecoder();let _0x4d94fe='',_0x460bf4='',_0x3d4d6f='',_0x75efc7=!0x1;for(;!_0x75efc7;){const {done:_0x7ead19,value:_0x2d90ab}=await _0xc7fd1c[_0x48e6('0x31')](),_0x394a6e=_0x4d94fe+_0x233351[_0x48e6('0x4')](_0x2d90ab);let _0x25c5f4='';_0x75efc7=_0x7ead19;try{_0x25c5f4=this[_0x48e6('0xe')](_0x394a6e),_0x4d94fe='';}catch(_0x165c95){_0x4d94fe=_0x394a6e;continue;}_0x460bf4+=_0x25c5f4,!_0x75efc7&&this[_0x48e6('0x10')](_0x460bf4)||_0x460bf4&&(_0x3d4d6f+=_0x460bf4,_0x460bf4='',_0x1912f0(_0x3d4d6f));}return Promise[_0x48e6('0x20')]();}async[_0x48e6('0x1')](_0x339ce9,_0x54073e){return _0x54073e((await _0x339ce9[_0x48e6('0x15')]())['choices'][0x0][_0x48e6('0x16')]['content']),Promise['resolve']();}['_isBufferIncomplete'](_0x45025a){const _0x3801be=_0x45025a[_0x48e6('0x24')]('<')[_0x48e6('0x21')]!==_0x45025a[_0x48e6('0x24')]('>')['length'],_0x49edab=_0x45025a[_0x48e6('0x21')]<0x1e;return _0x3801be&&_0x49edab;}[_0x48e6('0xe')](_0x29782c){return _0x29782c[_0x48e6('0x24')](/\n(?![^{]*\})/g)['map'](_0x5ef4f5=>_0x5ef4f5[_0x48e6('0x25')]('data:\x20',''))[_0x48e6('0x14')](_0x4ceb34=>_0x4ceb34&&_0x4ceb34[_0x48e6('0x21')]>0x0&&'[DONE]'!==_0x4ceb34)[_0x48e6('0x30')](_0x1b5470=>{const {choices:_0x4b9e06}=JSON[_0x48e6('0x32')](_0x1b5470);if(_0x4b9e06[0x0]&&_0x4b9e06[0x0][_0x48e6('0x35')]&&_0x4b9e06[0x0][_0x48e6('0x35')]['content'])return _0x4b9e06[0x0][_0x48e6('0x35')][_0x48e6('0x2d')];})[_0x48e6('0x14')](_0x2047c3=>_0x2047c3)[_0x48e6('0x23')]('');}}
|
package/src/aiassistant.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module ai/aiassistant
|
|
7
7
|
* @publicApi
|
|
8
8
|
*/
|
|
9
|
-
import { type Locale } from 'ckeditor5/src/utils';
|
|
10
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
11
|
-
import AIAssistantUI from './aiassistantui';
|
|
12
|
-
import AIAssistantEditing from './aiassistantediting';
|
|
9
|
+
import { type Locale } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
11
|
+
import AIAssistantUI from './aiassistantui.js';
|
|
12
|
+
import AIAssistantEditing from './aiassistantediting.js';
|
|
13
13
|
/**
|
|
14
14
|
* AI assistant plugin that allows you to use external AI models to generate content or improve existing content.
|
|
15
15
|
*
|
package/src/aiassistant.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2003-
|
|
2
|
+
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
*
|
|
5
5
|
*
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x453f=['translatePortuguese','Translate\x20to\x20%0','Casual','makeLonger','define','AIAssistant','German','locale','friendly','Improve\x20this\x20content\x20by\x20using\x20descriptive\x20language\x20and\x20inserting\x20more\x20information\x20and\x20more\x20detailed\x20explanations.','generate','Spanish','Start\x20with\x20the\x20provided\x20content\x20and\x20write\x20at\x20the\x20end\x20of\x20it\x20continuing\x20this\x20topic.\x20Keep\x20the\x20added\x20part\x20short.','push','Remove\x20any\x20repetitive,\x20redundant,\x20or\x20non-essential\x20writing\x20in\x20this\x20content\x20without\x20changing\x20the\x20meaning\x20or\x20losing\x20any\x20key\x20information.','Simplify\x20the\x20writing\x20style\x20of\x20this\x20content\x20and\x20reduce\x20the\x20complexity,\x20so\x20that\x20the\x20content\x20is\x20easy\x20to\x20understand.','Fix\x20spelling\x20mistakes,\x20use\x20proper\x20grammar\x20and\x20apply\x20good\x20writing\x20practices.\x20Do\x20not\x20lose\x20the\x20original\x20meaning.','editor','init','legal','_licenseKeyCheckInterval','Direct','Generate\x20from\x20selection','translateArabic','translateGerman','Translate\x20the\x20content\x20to\x20French\x20language.','destroy','groupId','ai-invalid-license-key','Improve\x20using\x20polished,\x20formal,\x20and\x20respectful\x20language\x20to\x20convey\x20professional\x20expertise\x20and\x20competence.','French','Translate\x20the\x20content\x20to\x20Simplified\x20Chinese\x20language.','Translate\x20the\x20content\x20to\x20Arabic\x20language.','pluginName','Arabic','Change\x20tone','Rewrite\x20this\x20content\x20as\x20a\x20business\x20professional\x20with\x20formal\x20language.','Improve\x20using\x20friendly,\x20comforting\x20language,\x20to\x20convey\x20understanding\x20and\x20empathy.','ai.aiAssistant.removeCommands','casual','Poetic','makeShorter','translateChinese','changeTone','aiLicenseKeyTrial','simplifyLanguage','includes','Portuguese','editOrReview','ai.aiAssistant.commands','poetic','get','licenseKey','forEach','journalism','professional','Hindi','aiLicenseKeyInvalid','Improve\x20writing','Friendly','Business','Rewrite\x20this\x20content\x20as\x20a\x20poem\x20using\x20poetic\x20techniques\x20without\x20losing\x20the\x20original\x20meaning.','Change\x20style','Legal','translateSpanish','Professional','ai-trial-license-key-reached-limit-changes','commands','Translate\x20the\x20content\x20to\x20German\x20language.','Translate\x20the\x20content\x20to\x20Hindi\x20language.','find','changeStyle','Make\x20shorter','Journalism','config','English','concat','translateFrench','Translate\x20the\x20content\x20to\x20English\x20language.','ai.aiAssistant.extraCommandGroups','info','set','Improve\x20using\x20direct\x20language,\x20using\x20only\x20the\x20essential\x20information.','Improve\x20using\x20compelling,\x20optimistic\x20language\x20to\x20convey\x20confidence\x20in\x20the\x20writing.'];(function(_0x3d06f4,_0x453f57){const _0x7c465c=function(_0x2b06ed){while(--_0x2b06ed){_0x3d06f4['push'](_0x3d06f4['shift']());}};_0x7c465c(++_0x453f57);}(_0x453f,0x164));const _0x7c46=function(_0x3d06f4,_0x453f57){_0x3d06f4=_0x3d06f4-0x0;let _0x7c465c=_0x453f[_0x3d06f4];return _0x7c465c;};import{CKEditorError as _0x3f8275}from'ckeditor5/src/utils.js';import{Plugin as _0x27f973}from'ckeditor5/src/core.js';import _0x857330 from'./aiassistantui.js';import _0x5f228e from'./aiassistantediting.js';import{getTranslation as _0x2087c7}from'./utils/common-translations.js';export default class r extends _0x27f973{static get['requires'](){return[_0x857330,_0x5f228e];}static get[_0x7c46('0xd')](){return _0x7c46('0x45');}constructor(_0x4d4583){super(_0x4d4583);const _0x37e020=_0x4d4583[_0x7c46('0x36')];_0x37e020['define'](_0x7c46('0x1d'),getDefaultCommands(_0x4d4583[_0x7c46('0x47')])),_0x37e020[_0x7c46('0x44')](_0x7c46('0x3b'),[]),_0x37e020['define'](_0x7c46('0x12'),[]);const _0x1c57f1=_0x37e020['get'](_0x7c46('0x1d')),_0x4b5221=_0x37e020[_0x7c46('0x1f')](_0x7c46('0x3b')),_0x395d67=_0x37e020[_0x7c46('0x1f')](_0x7c46('0x12'));_0x4b5221[_0x7c46('0x21')](_0x45db38=>{const _0x1ea416=_0x1c57f1[_0x7c46('0x32')](_0xb295bc=>_0xb295bc[_0x7c46('0x7')]===_0x45db38['groupId']);_0x1ea416?_0x1ea416[_0x7c46('0x2f')]=_0x1ea416['commands'][_0x7c46('0x38')](_0x45db38['commands']):_0x1c57f1[_0x7c46('0x4d')](_0x45db38);}),_0x1c57f1[_0x7c46('0x21')](_0x1cd7e0=>{_0x1cd7e0[_0x7c46('0x2f')]=_0x1cd7e0[_0x7c46('0x2f')]['filter'](_0x5d52b4=>!_0x395d67[_0x7c46('0x1a')](_0x5d52b4['id']));}),_0x37e020[_0x7c46('0x3d')]('ai.aiAssistant.commands',_0x1c57f1);}[_0x7c46('0x52')](){const _0x194094=this[_0x7c46('0x51')];this[_0x7c46('0x20')]=_0x194094['config'][_0x7c46('0x1f')]('licenseKey'),this['_licenseKeyCheckInterval']=setInterval(()=>{let _0x60b37f;for(const _0xacb410 in _0x194094){const _0x29935b=_0xacb410,_0x250b06=_0x194094[_0x29935b];if(_0x7c46('0x18')===_0x250b06||_0x7c46('0x25')===_0x250b06||'aiLicenseKeyValid'===_0x250b06||'aiLicenseKeyTrialLimit:operations'===_0x250b06){delete _0x194094[_0x29935b],_0x60b37f=_0x250b06;break;}}if(_0x7c46('0x25')===_0x60b37f)throw clearInterval(this[_0x7c46('0x0')]),new _0x3f8275(_0x7c46('0x8'),null);if('aiLicenseKeyTrial'===_0x60b37f&&console[_0x7c46('0x3c')]('You\x20are\x20using\x20the\x20trial\x20version\x20of\x20CKEditor\x205\x20ai\x20plugin\x20with\x20limited\x20usage.\x20Make\x20sure\x20you\x20will\x20not\x20use\x20it\x20in\x20the\x20production\x20environment.'),'aiLicenseKeyTrialLimit:operations'===_0x60b37f)throw clearInterval(this['_licenseKeyCheckInterval']),new _0x3f8275(_0x7c46('0x2e'),null);'aiLicenseKeyValid'===_0x60b37f&&clearInterval(this[_0x7c46('0x0')]);},0x3e8);}[_0x7c46('0x6')](){this[_0x7c46('0x0')]&&clearInterval(this[_0x7c46('0x0')]);}}export function getDefaultCommands(_0x4cf557){return[{'groupId':_0x7c46('0x1c'),'groupLabel':_0x2087c7(_0x4cf557,'Edit\x20or\x20review'),'commands':[{'id':'improveWriting','label':_0x2087c7(_0x4cf557,_0x7c46('0x26')),'prompt':_0x7c46('0x50')},{'id':_0x7c46('0x15'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x34')),'prompt':_0x7c46('0x4e')},{'id':_0x7c46('0x43'),'label':_0x2087c7(_0x4cf557,'Make\x20longer'),'prompt':_0x7c46('0x49')},{'id':_0x7c46('0x19'),'label':_0x2087c7(_0x4cf557,'Simplify\x20language'),'prompt':_0x7c46('0x4f')}]},{'groupId':_0x7c46('0x4a'),'groupLabel':_0x2087c7(_0x4cf557,_0x7c46('0x2')),'commands':[{'id':'summarize','label':_0x2087c7(_0x4cf557,'Summarize'),'prompt':'Summarize\x20this\x20content\x20into\x20one\x20paragraph\x20of\x20text.\x20Include\x20only\x20the\x20key\x20ideas\x20and\x20conclusions.\x20Keep\x20it\x20short.\x20Do\x20not\x20keep\x20original\x20text\x20formatting.'},{'id':'continue','label':_0x2087c7(_0x4cf557,'Continue'),'prompt':_0x7c46('0x4c')}]},{'groupId':_0x7c46('0x17'),'groupLabel':_0x2087c7(_0x4cf557,_0x7c46('0xf')),'commands':[{'id':_0x7c46('0x23'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x2d')),'prompt':_0x7c46('0x9')},{'id':_0x7c46('0x13'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x42')),'prompt':'Improve\x20using\x20casual,\x20informal\x20language\x20to\x20convey\x20a\x20casual\x20conversation\x20with\x20a\x20real\x20person.'},{'id':'direct','label':_0x2087c7(_0x4cf557,_0x7c46('0x1')),'prompt':_0x7c46('0x3e')},{'id':'confident','label':_0x2087c7(_0x4cf557,'Confident'),'prompt':_0x7c46('0x3f')},{'id':_0x7c46('0x48'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x27')),'prompt':_0x7c46('0x11')}]},{'groupId':_0x7c46('0x33'),'groupLabel':_0x2087c7(_0x4cf557,_0x7c46('0x2a')),'commands':[{'id':'business','label':_0x2087c7(_0x4cf557,_0x7c46('0x28')),'prompt':_0x7c46('0x10')},{'id':_0x7c46('0x53'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x2b')),'prompt':'Rewrite\x20this\x20content\x20as\x20a\x20legal\x20professional\x20using\x20valid\x20legal\x20terminology.'},{'id':_0x7c46('0x22'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x35')),'prompt':'Rewrite\x20this\x20content\x20as\x20a\x20journalist\x20using\x20engaging\x20language\x20to\x20convey\x20the\x20importance\x20of\x20the\x20information.'},{'id':_0x7c46('0x1e'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x14')),'prompt':_0x7c46('0x29')}]},{'groupId':'translate','groupLabel':_0x2087c7(_0x4cf557,'Translate'),'commands':[{'id':'translateEnglish','label':_0x2087c7(_0x4cf557,_0x7c46('0x41'),[_0x2087c7(_0x4cf557,_0x7c46('0x37'))]),'prompt':_0x7c46('0x3a')},{'id':_0x7c46('0x2c'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x41'),[_0x2087c7(_0x4cf557,_0x7c46('0x4b'))]),'prompt':'Translate\x20the\x20content\x20to\x20Spanish\x20language.'},{'id':_0x7c46('0x40'),'label':_0x2087c7(_0x4cf557,'Translate\x20to\x20%0',[_0x2087c7(_0x4cf557,_0x7c46('0x1b'))]),'prompt':'Translate\x20the\x20content\x20to\x20Portuguese\x20language.'},{'id':_0x7c46('0x4'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x41'),[_0x2087c7(_0x4cf557,_0x7c46('0x46'))]),'prompt':_0x7c46('0x30')},{'id':_0x7c46('0x39'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x41'),[_0x2087c7(_0x4cf557,_0x7c46('0xa'))]),'prompt':_0x7c46('0x5')},{'id':_0x7c46('0x16'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x41'),[_0x2087c7(_0x4cf557,'Simplified\x20Chinese')]),'prompt':_0x7c46('0xb')},{'id':'translateHindi','label':_0x2087c7(_0x4cf557,_0x7c46('0x41'),[_0x2087c7(_0x4cf557,_0x7c46('0x24'))]),'prompt':_0x7c46('0x31')},{'id':_0x7c46('0x3'),'label':_0x2087c7(_0x4cf557,_0x7c46('0x41'),[_0x2087c7(_0x4cf557,_0x7c46('0xe'))]),'prompt':_0x7c46('0xc')}]}];}
|