@ckeditor/ckeditor5-ai 0.0.0-internal-20241017.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/CHANGELOG.md +4 -0
- package/LICENSE.md +26 -0
- package/README.md +38 -0
- package/build/ai.js +5 -0
- package/build/translations/af.js +1 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/bs.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/es-co.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/jv.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/ti.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/tt.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/ckeditor5-metadata.json +23 -0
- package/dist/adapters/aiadapter.d.ts +60 -0
- package/dist/adapters/aitextadapter.d.ts +150 -0
- package/dist/adapters/awstextadapter.d.ts +183 -0
- package/dist/adapters/openaitextadapter.d.ts +187 -0
- package/dist/aiassistant.d.ts +393 -0
- package/dist/aiassistantediting.d.ts +59 -0
- package/dist/aiassistantui.d.ts +62 -0
- package/dist/aiconfig.d.ts +73 -0
- package/dist/augmentation.d.ts +31 -0
- package/dist/index-content.css +6 -0
- package/dist/index-editor.css +297 -0
- package/dist/index.css +392 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +24 -0
- package/dist/legacyerrors.d.ts +24 -0
- package/dist/translations/af.d.ts +8 -0
- package/dist/translations/af.js +23 -0
- package/dist/translations/af.umd.js +23 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +23 -0
- package/dist/translations/ar.umd.js +23 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +23 -0
- package/dist/translations/bg.umd.js +23 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +23 -0
- package/dist/translations/bn.umd.js +23 -0
- package/dist/translations/bs.d.ts +8 -0
- package/dist/translations/bs.js +23 -0
- package/dist/translations/bs.umd.js +23 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +23 -0
- package/dist/translations/ca.umd.js +23 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +23 -0
- package/dist/translations/cs.umd.js +23 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +23 -0
- package/dist/translations/da.umd.js +23 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +23 -0
- package/dist/translations/de-ch.umd.js +23 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +23 -0
- package/dist/translations/de.umd.js +23 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +23 -0
- package/dist/translations/el.umd.js +23 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +23 -0
- package/dist/translations/en-au.umd.js +23 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +23 -0
- package/dist/translations/en.umd.js +23 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +23 -0
- package/dist/translations/es-co.umd.js +23 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +23 -0
- package/dist/translations/es.umd.js +23 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +23 -0
- package/dist/translations/et.umd.js +23 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +23 -0
- package/dist/translations/fa.umd.js +23 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +23 -0
- package/dist/translations/fi.umd.js +23 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +23 -0
- package/dist/translations/fr.umd.js +23 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +23 -0
- package/dist/translations/gl.umd.js +23 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +23 -0
- package/dist/translations/he.umd.js +23 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +23 -0
- package/dist/translations/hi.umd.js +23 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +23 -0
- package/dist/translations/hr.umd.js +23 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +23 -0
- package/dist/translations/hu.umd.js +23 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +23 -0
- package/dist/translations/id.umd.js +23 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +23 -0
- package/dist/translations/it.umd.js +23 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +23 -0
- package/dist/translations/ja.umd.js +23 -0
- package/dist/translations/jv.d.ts +8 -0
- package/dist/translations/jv.js +23 -0
- package/dist/translations/jv.umd.js +23 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +23 -0
- package/dist/translations/ko.umd.js +23 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +23 -0
- package/dist/translations/lt.umd.js +23 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +23 -0
- package/dist/translations/lv.umd.js +23 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +23 -0
- package/dist/translations/ms.umd.js +23 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +23 -0
- package/dist/translations/nl.umd.js +23 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +23 -0
- package/dist/translations/no.umd.js +23 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +23 -0
- package/dist/translations/pl.umd.js +23 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +23 -0
- package/dist/translations/pt-br.umd.js +23 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +23 -0
- package/dist/translations/pt.umd.js +23 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +23 -0
- package/dist/translations/ro.umd.js +23 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +23 -0
- package/dist/translations/ru.umd.js +23 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +23 -0
- package/dist/translations/sk.umd.js +23 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +23 -0
- package/dist/translations/sr-latn.umd.js +23 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +23 -0
- package/dist/translations/sr.umd.js +23 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +23 -0
- package/dist/translations/sv.umd.js +23 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +23 -0
- package/dist/translations/th.umd.js +23 -0
- package/dist/translations/ti.d.ts +8 -0
- package/dist/translations/ti.js +23 -0
- package/dist/translations/ti.umd.js +23 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +23 -0
- package/dist/translations/tk.umd.js +23 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +23 -0
- package/dist/translations/tr.umd.js +23 -0
- package/dist/translations/tt.d.ts +8 -0
- package/dist/translations/tt.js +23 -0
- package/dist/translations/tt.umd.js +23 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +23 -0
- package/dist/translations/ug.umd.js +23 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +23 -0
- package/dist/translations/uk.umd.js +23 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +23 -0
- package/dist/translations/ur.umd.js +23 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +23 -0
- package/dist/translations/uz.umd.js +23 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +23 -0
- package/dist/translations/vi.umd.js +23 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +23 -0
- package/dist/translations/zh-cn.umd.js +23 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +23 -0
- package/dist/translations/zh.umd.js +23 -0
- package/dist/ui/aiassistantcontroller.d.ts +113 -0
- package/dist/ui/form/aiformcontentarea.d.ts +52 -0
- package/dist/ui/form/aiformerrorview.d.ts +30 -0
- package/dist/ui/form/aiformpromptview.d.ts +50 -0
- package/dist/ui/form/aiformtoolbarview.d.ts +62 -0
- package/dist/ui/form/aiformview.d.ts +145 -0
- package/dist/ui/form/aihistorylistitemview.d.ts +22 -0
- package/dist/ui/form/aihistorylistview.d.ts +39 -0
- package/dist/ui/form/prompthistory.d.ts +24 -0
- package/dist/ui/showaiassistantcommand.d.ts +44 -0
- package/dist/utils/common-translations.d.ts +13 -0
- package/dist/utils/normalizecommandsconfig.d.ts +18 -0
- package/lang/contexts.json +56 -0
- package/lang/translations/af.po +230 -0
- package/lang/translations/ar.po +230 -0
- package/lang/translations/bg.po +230 -0
- package/lang/translations/bn.po +230 -0
- package/lang/translations/bs.po +230 -0
- package/lang/translations/ca.po +230 -0
- package/lang/translations/cs.po +230 -0
- package/lang/translations/da.po +230 -0
- package/lang/translations/de-ch.po +230 -0
- package/lang/translations/de.po +230 -0
- package/lang/translations/el.po +230 -0
- package/lang/translations/en-au.po +230 -0
- package/lang/translations/en.po +230 -0
- package/lang/translations/es-co.po +230 -0
- package/lang/translations/es.po +230 -0
- package/lang/translations/et.po +230 -0
- package/lang/translations/fa.po +230 -0
- package/lang/translations/fi.po +230 -0
- package/lang/translations/fr.po +230 -0
- package/lang/translations/gl.po +230 -0
- package/lang/translations/he.po +230 -0
- package/lang/translations/hi.po +230 -0
- package/lang/translations/hr.po +230 -0
- package/lang/translations/hu.po +230 -0
- package/lang/translations/id.po +230 -0
- package/lang/translations/it.po +230 -0
- package/lang/translations/ja.po +230 -0
- package/lang/translations/jv.po +230 -0
- package/lang/translations/ko.po +230 -0
- package/lang/translations/lt.po +230 -0
- package/lang/translations/lv.po +230 -0
- package/lang/translations/ms.po +230 -0
- package/lang/translations/nl.po +230 -0
- package/lang/translations/no.po +230 -0
- package/lang/translations/pl.po +230 -0
- package/lang/translations/pt-br.po +230 -0
- package/lang/translations/pt.po +230 -0
- package/lang/translations/ro.po +230 -0
- package/lang/translations/ru.po +230 -0
- package/lang/translations/sk.po +230 -0
- package/lang/translations/sr-latn.po +230 -0
- package/lang/translations/sr.po +230 -0
- package/lang/translations/sv.po +230 -0
- package/lang/translations/th.po +230 -0
- package/lang/translations/ti.po +230 -0
- package/lang/translations/tk.po +230 -0
- package/lang/translations/tr.po +230 -0
- package/lang/translations/tt.po +230 -0
- package/lang/translations/ug.po +230 -0
- package/lang/translations/uk.po +230 -0
- package/lang/translations/ur.po +230 -0
- package/lang/translations/uz.po +230 -0
- package/lang/translations/vi.po +230 -0
- package/lang/translations/zh-cn.po +230 -0
- package/lang/translations/zh.po +230 -0
- package/package.json +53 -0
- package/src/adapters/aiadapter.d.ts +56 -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 +179 -0
- package/src/adapters/awstextadapter.js +23 -0
- package/src/adapters/openaitextadapter.d.ts +183 -0
- package/src/adapters/openaitextadapter.js +23 -0
- package/src/aiassistant.d.ts +389 -0
- package/src/aiassistant.js +23 -0
- package/src/aiassistantediting.d.ts +55 -0
- package/src/aiassistantediting.js +23 -0
- package/src/aiassistantui.d.ts +58 -0
- package/src/aiassistantui.js +23 -0
- package/src/aiconfig.d.ts +69 -0
- package/src/aiconfig.js +23 -0
- package/src/augmentation.d.ts +27 -0
- package/src/augmentation.js +23 -0
- package/src/index.d.ts +13 -0
- package/src/index.js +23 -0
- package/src/legacyerrors.d.ts +20 -0
- package/src/legacyerrors.js +23 -0
- package/src/ui/aiassistantcontroller.d.ts +109 -0
- package/src/ui/aiassistantcontroller.js +24 -0
- package/src/ui/form/aiformcontentarea.d.ts +48 -0
- package/src/ui/form/aiformcontentarea.js +23 -0
- package/src/ui/form/aiformerrorview.d.ts +26 -0
- package/src/ui/form/aiformerrorview.js +23 -0
- package/src/ui/form/aiformpromptview.d.ts +46 -0
- package/src/ui/form/aiformpromptview.js +23 -0
- package/src/ui/form/aiformtoolbarview.d.ts +58 -0
- package/src/ui/form/aiformtoolbarview.js +23 -0
- package/src/ui/form/aiformview.d.ts +141 -0
- package/src/ui/form/aiformview.js +23 -0
- package/src/ui/form/aihistorylistitemview.d.ts +18 -0
- package/src/ui/form/aihistorylistitemview.js +23 -0
- package/src/ui/form/aihistorylistview.d.ts +35 -0
- package/src/ui/form/aihistorylistview.js +23 -0
- package/src/ui/form/prompthistory.d.ts +20 -0
- package/src/ui/form/prompthistory.js +23 -0
- package/src/ui/showaiassistantcommand.d.ts +40 -0
- package/src/ui/showaiassistantcommand.js +23 -0
- package/src/utils/common-translations.d.ts +9 -0
- package/src/utils/common-translations.js +23 -0
- package/src/utils/normalizecommandsconfig.d.ts +14 -0
- package/src/utils/normalizecommandsconfig.js +23 -0
- package/theme/ai-dropdown.css +37 -0
- package/theme/ai-form.css +262 -0
- package/theme/ai.css +120 -0
- package/theme/icons/copy.svg +1 -0
- package/theme/icons/error.svg +1 -0
- package/theme/icons/magic-wand.svg +1 -0
- package/theme/icons/submit.svg +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ckeditor/ckeditor5-ai",
|
|
3
|
+
"version": "0.0.0-internal-20241017.0",
|
|
4
|
+
"description": "AI Assistant feature for CKEditor 5.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
|
+
"author": "CKSource (http://cksource.com/)",
|
|
7
|
+
"homepage": "https://ckeditor.com/ckeditor-5",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"CKEditor",
|
|
10
|
+
"ckeditor5",
|
|
11
|
+
"ckeditor 5",
|
|
12
|
+
"WYSIWYG",
|
|
13
|
+
"WYSIWYW",
|
|
14
|
+
"text",
|
|
15
|
+
"rich-text",
|
|
16
|
+
"richtext",
|
|
17
|
+
"editor",
|
|
18
|
+
"editing",
|
|
19
|
+
"html",
|
|
20
|
+
"operational transformation",
|
|
21
|
+
"ot",
|
|
22
|
+
"AI",
|
|
23
|
+
"framework"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@aws-sdk/client-bedrock-runtime": "3.621.0",
|
|
27
|
+
"@ckeditor/ckeditor5-clipboard": "0.0.0-internal-20241017.0",
|
|
28
|
+
"@ckeditor/ckeditor5-core": "0.0.0-internal-20241017.0",
|
|
29
|
+
"@ckeditor/ckeditor5-engine": "0.0.0-internal-20241017.0",
|
|
30
|
+
"@ckeditor/ckeditor5-ui": "0.0.0-internal-20241017.0",
|
|
31
|
+
"@ckeditor/ckeditor5-utils": "0.0.0-internal-20241017.0",
|
|
32
|
+
"ckeditor5": "0.0.0-internal-20241017.0",
|
|
33
|
+
"ckeditor5-collaboration": "0.0.0-internal-20241017.0",
|
|
34
|
+
"lodash-es": "4.17.21"
|
|
35
|
+
},
|
|
36
|
+
"type": "module",
|
|
37
|
+
"main": "src/index.js",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"lang",
|
|
41
|
+
"src/**/*.js",
|
|
42
|
+
"src/**/*.d.ts",
|
|
43
|
+
"theme",
|
|
44
|
+
"build",
|
|
45
|
+
"ckeditor5-metadata.json",
|
|
46
|
+
"CHANGELOG.md"
|
|
47
|
+
],
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://support.ckeditor.com/hc/en-us/requests/new"
|
|
50
|
+
},
|
|
51
|
+
"types": "src/index.d.ts",
|
|
52
|
+
"obfuscated": true
|
|
53
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/adapters/aiadapter
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
+
import type AITextAdapter from './aitextadapter.js';
|
|
11
|
+
/**
|
|
12
|
+
* Main adapter plugin that is a common interface between AI features and AI adapters.
|
|
13
|
+
*
|
|
14
|
+
* Various AI features require to make calls to AI services. On the other hand, there are various AI adapters that can be
|
|
15
|
+
* loaded, which provide access to different AI service providers.
|
|
16
|
+
*
|
|
17
|
+
* `AIAdapter` brings both parties together. Features use the `AIAdapter` API that is known to them. On the other hand, a concrete adapter
|
|
18
|
+
* implementation can inject itself into `AIAdapter`. This way features and adapters are decoupled.
|
|
19
|
+
*
|
|
20
|
+
* For example:
|
|
21
|
+
*
|
|
22
|
+
* * `AIAssistant` feature needs to make text AI requests, so it uses `AIAdapter#textAdapter`.
|
|
23
|
+
* * `OpenAITextAdapter` plugin, when loaded, sets itself as `AIAdapter#textAdapter`, so features can use it.
|
|
24
|
+
*/
|
|
25
|
+
export default class AIAdapter extends Plugin {
|
|
26
|
+
/**
|
|
27
|
+
* The instance of the loaded AI text adapter instance.
|
|
28
|
+
*
|
|
29
|
+
* The adapter is provided by a different plugin that has to be additionally loaded.
|
|
30
|
+
*/
|
|
31
|
+
textAdapter: AITextAdapter;
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
static get pluginName(): "AIAdapter";
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
static get isOfficialPlugin(): true;
|
|
40
|
+
/**
|
|
41
|
+
* @inheritDoc
|
|
42
|
+
*/
|
|
43
|
+
static get isPremiumPlugin(): true;
|
|
44
|
+
/**
|
|
45
|
+
* @inheritDoc
|
|
46
|
+
*/
|
|
47
|
+
afterInit(): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Error which may be thrown by various AI adapters.
|
|
51
|
+
*
|
|
52
|
+
* When this error is thrown it should be handled by the feature which used the adapter.
|
|
53
|
+
*/
|
|
54
|
+
export declare class AIRequestError extends Error {
|
|
55
|
+
constructor(message: string);
|
|
56
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2024, 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
|
+
var _0x7ccb4e=_0x1333;function _0x1333(_0xc318f4,_0x160f28){var _0xb53ac4=_0xb53a();return _0x1333=function(_0x133317,_0xb3e4bd){_0x133317=_0x133317-0xf5;var _0x4b80c7=_0xb53ac4[_0x133317];return _0x4b80c7;},_0x1333(_0xc318f4,_0x160f28);}(function(_0x4654e7,_0x1eb4ff){var _0x42e8d0=_0x1333,_0x1c5d5a=_0x4654e7();while(!![]){try{var _0x91346b=parseInt(_0x42e8d0(0x104))/0x1+-parseInt(_0x42e8d0(0xf5))/0x2+parseInt(_0x42e8d0(0xf8))/0x3*(-parseInt(_0x42e8d0(0x105))/0x4)+-parseInt(_0x42e8d0(0xfe))/0x5*(-parseInt(_0x42e8d0(0xf7))/0x6)+-parseInt(_0x42e8d0(0xf9))/0x7+parseInt(_0x42e8d0(0xfb))/0x8+parseInt(_0x42e8d0(0xfd))/0x9*(parseInt(_0x42e8d0(0xfa))/0xa);if(_0x91346b===_0x1eb4ff)break;else _0x1c5d5a['push'](_0x1c5d5a['shift']());}catch(_0x107168){_0x1c5d5a['push'](_0x1c5d5a['shift']());}}}(_0xb53a,0xa517a));function _0xb53a(){var _0x55fb69=['pluginName','AIAdapter','1144771ttNBbI','1316324KxYNWS','isPremiumPlugin','afterInit','2622714WalSli','isOfficialPlugin','374412IQCtpE','9EEkkrK','2401406xOUtKM','20sFMWCf','1003000GKtIsA','textAdapter','8653167HGhvOE','10XiZnPQ','name','aiadapter-text-adapter-not-set','AIRequestError'];_0xb53a=function(){return _0x55fb69;};return _0xb53a();}import{Plugin as _0x5e5091}from'ckeditor5/src/core.js';import{CKEditorError as _0x5b7dfd}from'ckeditor5/src/utils.js';export default class v extends _0x5e5091{static get[_0x7ccb4e(0x102)](){var _0x38979e=_0x7ccb4e;return _0x38979e(0x103);}static get[_0x7ccb4e(0xf6)](){return!0x0;}static get[_0x7ccb4e(0x106)](){return!0x0;}[_0x7ccb4e(0x107)](){var _0x598530=_0x7ccb4e;if(!this[_0x598530(0xfc)])throw new _0x5b7dfd(_0x598530(0x100),null);}}export class AIRequestError extends Error{constructor(_0x5061b3){var _0xd6c3ae=_0x7ccb4e;super(_0x5061b3),this[_0xd6c3ae(0xff)]=_0xd6c3ae(0x101);}}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/adapters/aitextadapter
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
+
import { default as AIAdapter } from './aiadapter.js';
|
|
11
|
+
/**
|
|
12
|
+
* Abstract base class for AI adapters that perform text-related requests.
|
|
13
|
+
*
|
|
14
|
+
* Concrete AI text adapter implementation plugin, after loaded by the editor, will set itself as
|
|
15
|
+
* {@link module:ai/adapters/aiadapter~AIAdapter#textAdapter `AIAdapter#textAdapter`}.
|
|
16
|
+
*
|
|
17
|
+
* Then, features making text-related AI requests will use that concrete adapter through
|
|
18
|
+
* {@link module:ai/adapters/aitextadapter~AITextAdapter#makeRequest `AIAdapter#textAdapter#makeRequest()`}.
|
|
19
|
+
*
|
|
20
|
+
* You can create your own adapter that may connect to any model by extending this abstract class.
|
|
21
|
+
*/
|
|
22
|
+
export default abstract class AITextAdapter extends Plugin {
|
|
23
|
+
/**
|
|
24
|
+
* Abort controller instance.
|
|
25
|
+
*
|
|
26
|
+
* It is used by {@link ~AITextAdapter#abort `abort()`}.
|
|
27
|
+
*
|
|
28
|
+
* It should be passed to the mechanism that performs the request (e.g. `fetch()`).
|
|
29
|
+
*/
|
|
30
|
+
abortController: AbortController;
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
static get requires(): readonly [typeof AIAdapter];
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
init(): void;
|
|
39
|
+
/**
|
|
40
|
+
* The method that stops the current request and then recreates the abort controller instance.
|
|
41
|
+
*
|
|
42
|
+
* It should be called when the currently processed request should be aborted (e.g. when the user closes the UI as the request is
|
|
43
|
+
* processed).
|
|
44
|
+
*/
|
|
45
|
+
abort(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Makes the AI request to the AI API service and processes the response from the service.
|
|
48
|
+
*
|
|
49
|
+
* Internally, it uses {@link ~AITextAdapter#sendRequest `sendRequest()`}.
|
|
50
|
+
*
|
|
51
|
+
* If you are creating a custom adapter, implement `sendRequest()` rather than extending this method.
|
|
52
|
+
*
|
|
53
|
+
* Implements basic error handling for errors thrown by `sendRequest()`:
|
|
54
|
+
*
|
|
55
|
+
* * {@link module:ai/adapters/aiadapter~AIRequestError `AIRequestError`} is re-thrown, and it is expected to be handled by the feature
|
|
56
|
+
* that made the request (e.g. by displaying some error notification).
|
|
57
|
+
* * {@link module:utils/ckeditorerror~CKEditorError `CKEditorError`} is unexpected, is logged to the console, and re-thrown.
|
|
58
|
+
* * `'AbortError'` is expected and is silenced. It is thrown when the request is aborted and does not need to be handled.
|
|
59
|
+
*
|
|
60
|
+
* @returns A Promise that resolves with the AI-generated response.
|
|
61
|
+
*/
|
|
62
|
+
makeRequest(requestData: AITextAdapterRequestData): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Abstract method.
|
|
65
|
+
*
|
|
66
|
+
* Creates the request using provided `requestData`. Makes the request to the AI service endpoint. Handles the AI service response.
|
|
67
|
+
*
|
|
68
|
+
* If you want to extend an existing adapter, you can overload this method to do some additional processing or make an external call.
|
|
69
|
+
*
|
|
70
|
+
* If you want to create a custom adapter, the main logic related to making and handling the request should be implemented here.
|
|
71
|
+
* Make sure to properly implement {@link ~AITextAdapterRequestData#onData `onData()`} callback handling.
|
|
72
|
+
*/
|
|
73
|
+
abstract sendRequest(requestData: AITextAdapterRequestData): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
export type AITextAdapterRequestData = {
|
|
76
|
+
/**
|
|
77
|
+
* The user's query.
|
|
78
|
+
*/
|
|
79
|
+
query: string;
|
|
80
|
+
/**
|
|
81
|
+
* The context on which the query is used.
|
|
82
|
+
*
|
|
83
|
+
* May be empty. In such case, it is assumed that the user wanted to create new textual content.
|
|
84
|
+
*/
|
|
85
|
+
context: string;
|
|
86
|
+
/**
|
|
87
|
+
* A callback that is called whenever the data received by the adapter is updated.
|
|
88
|
+
*
|
|
89
|
+
* If the adapter does not use streaming, and receives the whole answer at once, it should call `onData()` once, when the data is
|
|
90
|
+
* received.
|
|
91
|
+
*
|
|
92
|
+
* If the adapter uses streaming, the adapter should internally build the whole received data and fire `onData()` callback with the
|
|
93
|
+
* full update data each time. For example, if during streaming, the adapter receives following chunks: `'<p>T'`, `'his is an'`, and
|
|
94
|
+
* `' example</p>'`, then it should fire `onData()` with: `'<p>T'`, `'<p>This is an'`, and `'<p>This is an example</p>'`.
|
|
95
|
+
*/
|
|
96
|
+
onData: AITextAdapterDataCallback;
|
|
97
|
+
/**
|
|
98
|
+
* ID of the performed action. This is a unique ID for each feature and each action that triggers the AI request.
|
|
99
|
+
*
|
|
100
|
+
* The main role for `actionId` is to distinguish which feature made the call. The action ID can be used in extended and custom adapters
|
|
101
|
+
* to customize the request.
|
|
102
|
+
*
|
|
103
|
+
* Each AI feature describes what action IDs it creates and uses. For example, the AI Assistant feature uses `actionId` values like
|
|
104
|
+
* `'aiAssistant:custom'`, or `'aiAssistant:command:improveWriting'`.
|
|
105
|
+
*/
|
|
106
|
+
actionId: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Object with headers to set in the request to the AI service.
|
|
110
|
+
*
|
|
111
|
+
* If the provided value is an `object`, it is simply used as provided.
|
|
112
|
+
*
|
|
113
|
+
* If the provided value is a function, it should be a function that returns a `Promise` which resolves with the headers object.
|
|
114
|
+
* This way, you can perform an authorization request to your application and receive the authorization token (and also implement
|
|
115
|
+
* any custom logic on the back-end side). The headers object is then used to make the actual call to the AI service.
|
|
116
|
+
*
|
|
117
|
+
* The function is passed {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
|
|
118
|
+
* possible to further customize the headers.
|
|
119
|
+
*
|
|
120
|
+
* If the function fails for any reason, the promise should be rejected. In this case, a feature that made the request should display
|
|
121
|
+
* an error notification.
|
|
122
|
+
*/
|
|
123
|
+
export type RequestHeaders = Record<string, string> | ((actionId: string) => Promise<Record<string, string>>);
|
|
124
|
+
/**
|
|
125
|
+
* Additional configuration parameters for the AI request. Use it to customize how the AI service generates responses.
|
|
126
|
+
*
|
|
127
|
+
* See the reference for the AI service of your choice to learn what parameters can be used with that service or model.
|
|
128
|
+
*
|
|
129
|
+
* If the provided value is an `object`, it is passed to the request as provided.
|
|
130
|
+
*
|
|
131
|
+
* If the provided value is a function, it should be a function that returns a `Promise` which resolves with the request parameters
|
|
132
|
+
* object. This gives you more flexibility to provide parameters for the AI model.
|
|
133
|
+
*
|
|
134
|
+
* The function is passed {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
|
|
135
|
+
* possible to further customize the parameters.
|
|
136
|
+
*
|
|
137
|
+
* If the function fails for any reason, the promise should be rejected. In this case, the feature that made the request should display
|
|
138
|
+
* an error notification.
|
|
139
|
+
*/
|
|
140
|
+
export type RequestParameters = Record<string, any> | ((actionId: string) => Promise<Record<string, any>>);
|
|
141
|
+
/**
|
|
142
|
+
* Callback called each time the AI text adapter receives data.
|
|
143
|
+
*
|
|
144
|
+
* @params content The received data.
|
|
145
|
+
*/
|
|
146
|
+
export type AITextAdapterDataCallback = (content: string) => any;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2024, 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 _0x4f9ab7=_0x2547;function _0x2547(_0x25d39d,_0x513ffe){const _0x1920fd=_0x1920();return _0x2547=function(_0x2547b9,_0x5670ba){_0x2547b9=_0x2547b9-0x1ac;let _0x525b95=_0x1920fd[_0x2547b9];return _0x525b95;},_0x2547(_0x25d39d,_0x513ffe);}(function(_0x545157,_0x264efe){const _0xa3f661=_0x2547,_0x55a86d=_0x545157();while(!![]){try{const _0xd71079=-parseInt(_0xa3f661(0x1b5))/0x1+-parseInt(_0xa3f661(0x1c7))/0x2+-parseInt(_0xa3f661(0x1ad))/0x3+-parseInt(_0xa3f661(0x1c6))/0x4*(-parseInt(_0xa3f661(0x1be))/0x5)+-parseInt(_0xa3f661(0x1c4))/0x6+parseInt(_0xa3f661(0x1c9))/0x7+parseInt(_0xa3f661(0x1b8))/0x8*(parseInt(_0xa3f661(0x1bf))/0x9);if(_0xd71079===_0x264efe)break;else _0x55a86d['push'](_0x55a86d['shift']());}catch(_0x5f343f){_0x55a86d['push'](_0x55a86d['shift']());}}}(_0x1920,0xb0cb0));import{Plugin as _0x1c268c}from'ckeditor5/src/core.js';import{CKEditorError as _0x13a7fc}from'ckeditor5/src/utils.js';import{default as _0x3e8632,AIRequestError as _0x554a68}from'./aiadapter.js';function _0x1920(){const _0x29b751=['reject','AI_ERROR_GET_PARAMETERS','AI_ERROR_GET_HEADERS','1201469ZGZfUp','plugins','aitextadapter-send-request-failed','1088456hBIYve','signal','abort','error','resolve','locale','776595TiyYjk','333SmpwyR','get','assign','application/json','editor','8646648mHaVBo','object','8MMDudp','2688380LFwUhP','abortController','4298266GzsoSV','init','AbortError','_prepareRequestHeaders','textAdapter','sendRequest','_prepareRequestParameters','catch','3743622piskyO','makeRequest','name','requires','aborted'];_0x1920=function(){return _0x29b751;};return _0x1920();}import{getTranslation as _0x521a27}from'../utils/common-translations.js';export default class P extends _0x1c268c{static get[_0x4f9ab7(0x1b0)](){return[_0x3e8632];}constructor(_0xee26df){const _0x22b43e=_0x4f9ab7;super(_0xee26df),this[_0x22b43e(0x1c8)]=new AbortController();}[_0x4f9ab7(0x1ca)](){const _0x37dffb=_0x4f9ab7;this[_0x37dffb(0x1c3)][_0x37dffb(0x1b6)][_0x37dffb(0x1c0)](_0x3e8632)[_0x37dffb(0x1cd)]=this;}[_0x4f9ab7(0x1ba)](){const _0x14708d=_0x4f9ab7;this[_0x14708d(0x1c8)][_0x14708d(0x1b9)][_0x14708d(0x1b1)]||(this[_0x14708d(0x1c8)][_0x14708d(0x1ba)](),this[_0x14708d(0x1c8)]=new AbortController());}async[_0x4f9ab7(0x1ae)](_0x2ab7b5){const _0x589c8c=_0x4f9ab7;return this[_0x589c8c(0x1ce)](_0x2ab7b5)[_0x589c8c(0x1ac)](_0x46b28f=>{const _0x5b9ae4=_0x589c8c;if(_0x46b28f instanceof _0x554a68)return Promise[_0x5b9ae4(0x1b2)](_0x46b28f);if(_0x5b9ae4(0x1cb)==_0x46b28f[_0x5b9ae4(0x1af)])return Promise[_0x5b9ae4(0x1bc)]();throw console[_0x5b9ae4(0x1bb)](_0x46b28f),new _0x13a7fc(_0x5b9ae4(0x1b7),null);});}async[_0x4f9ab7(0x1cc)](_0x5c5856,_0x2cc1d9){const _0x9678cc=_0x4f9ab7,_0x5d2a61=this[_0x9678cc(0x1c3)][_0x9678cc(0x1bd)],_0x2a40e5={'Content-Type':_0x9678cc(0x1c2)};if(_0x9678cc(0x1c5)==typeof _0x5c5856)Object[_0x9678cc(0x1c1)](_0x2a40e5,_0x5c5856);else{if(_0x5c5856)try{const _0x5655fd=await _0x5c5856(_0x2cc1d9);Object[_0x9678cc(0x1c1)](_0x2a40e5,_0x5655fd);}catch(_0x58a710){return Promise[_0x9678cc(0x1b2)](new _0x554a68(_0x521a27(_0x5d2a61,_0x9678cc(0x1b4))));}}return _0x2a40e5;}async[_0x4f9ab7(0x1cf)](_0x240de5,_0x2c2208){const _0x95cbf1=_0x4f9ab7,_0x4653ef=this[_0x95cbf1(0x1c3)][_0x95cbf1(0x1bd)];if(_0x95cbf1(0x1c5)==typeof _0x240de5)return _0x240de5;try{return await _0x240de5(_0x2c2208);}catch(_0x82450f){return Promise[_0x95cbf1(0x1b2)](new _0x554a68(_0x521a27(_0x4653ef,_0x95cbf1(0x1b3))));}}}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/adapters/awstextadapter
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { type Editor } from 'ckeditor5/src/core.js';
|
|
10
|
+
import { default as AITextAdapter, type AITextAdapterRequestData, type RequestHeaders, type RequestParameters } from './aitextadapter.js';
|
|
11
|
+
import { type BedrockRuntimeClientConfig } from '@aws-sdk/client-bedrock-runtime';
|
|
12
|
+
/**
|
|
13
|
+
* Adapter for AI text-related requests that supports the Amazon Bedrock service.
|
|
14
|
+
*
|
|
15
|
+
* See also {@link module:ai/adapters/aitextadapter~AITextAdapter}.
|
|
16
|
+
*/
|
|
17
|
+
export default class AWSTextAdapter extends AITextAdapter {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): "AWSTextAdapter";
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
constructor(editor: Editor);
|
|
26
|
+
/**
|
|
27
|
+
* Performs the request to the Amazon Bedrock service or to the endpoint provided in the editor configuration.
|
|
28
|
+
*
|
|
29
|
+
* If you want to extend this adapter, you can overload this method to do some additional processing or make an external call.
|
|
30
|
+
*/
|
|
31
|
+
sendRequest({ query, context, onData, actionId }: AITextAdapterRequestData): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Prepares the actual full prompt for the request to the Amazon Bedrock API.
|
|
34
|
+
*
|
|
35
|
+
* The prompt may differ depending on what model is used.
|
|
36
|
+
*
|
|
37
|
+
* You can overload this method to customize the prompts that are sent to the AI service.
|
|
38
|
+
*
|
|
39
|
+
* @param query The user's query. The instruction which the model should perform.
|
|
40
|
+
* @param context The context for the instruction. Usually this will be a part of the editor content. Can be empty.
|
|
41
|
+
* @param model Model that is used to perform the request.
|
|
42
|
+
* @param actionId ID of the performed action. See {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId}.
|
|
43
|
+
*/
|
|
44
|
+
preparePrompt(query: string, context: string, model: string, actionId: string): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* For a given model, it returns the family to which this model belongs.
|
|
47
|
+
*
|
|
48
|
+
* For example, for `anthropic.claude-instant-v1` it will return `anthropic.claude`.
|
|
49
|
+
*
|
|
50
|
+
* Throws {@link module:ai/adapters/aiadapter~AIRequestError `AIRequestError`} if a given model is not supported.
|
|
51
|
+
*/
|
|
52
|
+
getModelFamily(model: string): AWSModelFamily;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The configuration for the Amazon Bedrock adapter.
|
|
56
|
+
*
|
|
57
|
+
* The properties defined in this configuration are set in the `config.ai.aws` namespace.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* ClassicEditor
|
|
61
|
+
* .create( editorElement, {
|
|
62
|
+
* ai: {
|
|
63
|
+
* aws: {
|
|
64
|
+
* apiUrl: 'https://url.to.your.application/ai'
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* } )
|
|
68
|
+
* .then( ... )
|
|
69
|
+
* .catch( ... );
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* See {@link module:ai/aiconfig~AIConfig the full AI configuration}.
|
|
73
|
+
*
|
|
74
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
75
|
+
*/
|
|
76
|
+
export interface AWSTextAdapterConfig {
|
|
77
|
+
/**
|
|
78
|
+
* The URL to which the AI service request will be sent.
|
|
79
|
+
*
|
|
80
|
+
* Set this value only if you want to connect to Amazon Bedrock using a proxy endpoint.
|
|
81
|
+
*
|
|
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
|
+
*/
|
|
84
|
+
apiUrl?: string;
|
|
85
|
+
/**
|
|
86
|
+
* An object with headers to set in the request to the AI service.
|
|
87
|
+
*
|
|
88
|
+
* **These headers are only used when connecting to AWS through the proxy endpoint (that is, when `apiUrl` is set).**
|
|
89
|
+
*
|
|
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
|
+
* customized.
|
|
92
|
+
*
|
|
93
|
+
* If the provided value is an object, it is simply used as provided.
|
|
94
|
+
*
|
|
95
|
+
* ```js
|
|
96
|
+
* {
|
|
97
|
+
* ai: {
|
|
98
|
+
* aws: {
|
|
99
|
+
* requestHeaders: {
|
|
100
|
+
* 'Authorization': 'Bearer YOUR_API_KEY'
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
* // ...
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* If the provided value is a function, it should be a function that returns a promise which resolves with the headers object.
|
|
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 backend side). The headers object is then used to make the actual call to the AI service.
|
|
111
|
+
*
|
|
112
|
+
* ```js
|
|
113
|
+
* {
|
|
114
|
+
* ai: {
|
|
115
|
+
* aws: {
|
|
116
|
+
* requestHeaders: async () => {
|
|
117
|
+
* const jwt = await fetch( 'https://example.com/jwt-endpoint' );
|
|
118
|
+
*
|
|
119
|
+
* return {
|
|
120
|
+
* 'Authorization': 'Bearer ' + jwt
|
|
121
|
+
* }
|
|
122
|
+
* }
|
|
123
|
+
* }
|
|
124
|
+
* // ...
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* The function is passed the {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
|
|
130
|
+
* possible to further customize the headers.
|
|
131
|
+
*
|
|
132
|
+
* If the function fails for any reason, the promise should be rejected. In this case, a feature that made the request should display
|
|
133
|
+
* an error notification.
|
|
134
|
+
*/
|
|
135
|
+
requestHeaders?: RequestHeaders;
|
|
136
|
+
/**
|
|
137
|
+
* Additional configuration parameters for the AI service request. Use it to customize how the AI service generates responses.
|
|
138
|
+
* Note that the value you will set here will fully overwrite the default value.
|
|
139
|
+
*
|
|
140
|
+
* The exact configuration (available parameters) depends on the used model. Keep in mind that some properties are not supported by some
|
|
141
|
+
* models.
|
|
142
|
+
*
|
|
143
|
+
* See [AWS model parameters reference](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html) to learn more.
|
|
144
|
+
*
|
|
145
|
+
* If the provided value is an object, it is passed to the request as provided.
|
|
146
|
+
*
|
|
147
|
+
* If the provided value is a function, it should be a function that returns a promise which resolves with the request parameters
|
|
148
|
+
* object. This gives you more flexibility to provide parameters for the AI model.
|
|
149
|
+
*
|
|
150
|
+
* The function is passed the {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
|
|
151
|
+
* possible to further customize the parameters.
|
|
152
|
+
*
|
|
153
|
+
* If the function fails for any reason, the promise should be rejected. In this case, the feature that made the request should display
|
|
154
|
+
* an error notification.
|
|
155
|
+
*
|
|
156
|
+
* Defaults to:
|
|
157
|
+
*
|
|
158
|
+
* ```json
|
|
159
|
+
* {
|
|
160
|
+
* model: 'anthropic.claude-v2',
|
|
161
|
+
* max_tokens_to_sample: 500,
|
|
162
|
+
* temperature: 1,
|
|
163
|
+
* top_k: 250,
|
|
164
|
+
* top_p: 1,
|
|
165
|
+
* anthropic_version: 'bedrock-2023-05-31',
|
|
166
|
+
* stream: true
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
requestParameters?: RequestParameters;
|
|
171
|
+
/**
|
|
172
|
+
* The configuration for AWS-SDK Bedrock Runtime Client.
|
|
173
|
+
*
|
|
174
|
+
* If `apiUrl` is not provided, this configuration will be used to initialize the Bedrock Runtime Client which will be used to process
|
|
175
|
+
* the requests. The adapter will make requests directly to the Amazon Bedrock service.
|
|
176
|
+
*/
|
|
177
|
+
bedrockClientConfig?: BedrockRuntimeClientConfig;
|
|
178
|
+
}
|
|
179
|
+
export type AWSModelFamily = 'anthropic.claude' | 'ai21.j2' | 'cohere.command' | 'meta.llama';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2024, 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
|
+
function _0x3c71(_0x27683d,_0x2bf17f){const _0x3dc665=_0x3dc6();return _0x3c71=function(_0x3c71bb,_0x5cf474){_0x3c71bb=_0x3c71bb-0x11c;let _0x4ba4ef=_0x3dc665[_0x3c71bb];return _0x4ba4ef;},_0x3c71(_0x27683d,_0x2bf17f);}const _0x3fa0c7=_0x3c71;function _0x3dc6(){const _0x3193e5=['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.','_prepareRequestParameters','AI_ERROR_UNSUPPORTED_MODEL','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.','ai.aws.requestHeaders','get','application/json','utf-8','5VMPmLb','bytes','_readStreamableResponse','sendRequest','1448952thDyLW','config','294637OkCebi','completions','text','1039536vcPFzC','ai.aws.requestParameters','3426936ChPIlH','ai21.j2','7756KuWmyi','bedrock-2023-05-31','Human:\x0a','ai.aws.apiUrl','\x0a[/INST]','editor','AWSTextAdapter','length','_prepareRequestHeaders','anthropic.claude-v2','decode','POST','map','meta.llama','define','resolve','utf8','<<SYS>>\x0a','4431120wMbZcU','6793137fncpfH','_bedrockClientConfig','toString','_readStaticResponse','cohere.command','2MKAKfz','_readAsyncIterableResponse','abortController','locale','getReader','from','ai.aws.bedrockClientConfig','generations','json','anthropic.claude','5224GgrApL','send','stringify','preparePrompt','completion','read','\x0a\x0aAssistant:','\x0a<</SYS>>\x0a[INST]\x0a','filter','body','_processAWSRequest','join','\x0aYou\x20must\x20keep\x20the\x20text\x20formatting.\x0a\x0aContent:\x0a','getModelFamily','_apiUrl','_processProxyRequest','chunk','data','pluginName','generation','_requestParameters','test','_requestHeaders','parse','signal','_getGeneratedText','Instruction:\x0a','split'];_0x3dc6=function(){return _0x3193e5;};return _0x3dc6();}(function(_0x38832d,_0x255370){const _0xf3e62c=_0x3c71,_0x13f160=_0x38832d();while(!![]){try{const _0x25994c=parseInt(_0xf3e62c(0x12f))/0x1+parseInt(_0xf3e62c(0x14e))/0x2*(parseInt(_0xf3e62c(0x12d))/0x3)+parseInt(_0xf3e62c(0x134))/0x4*(parseInt(_0xf3e62c(0x129))/0x5)+parseInt(_0xf3e62c(0x132))/0x6+parseInt(_0xf3e62c(0x136))/0x7*(-parseInt(_0xf3e62c(0x158))/0x8)+-parseInt(_0xf3e62c(0x149))/0x9+parseInt(_0xf3e62c(0x148))/0xa;if(_0x25994c===_0x255370)break;else _0x13f160['push'](_0x13f160['shift']());}catch(_0x433032){_0x13f160['push'](_0x13f160['shift']());}}}(_0x3dc6,0xbc936));import{default as _0x1966a9}from'./aitextadapter.js';import{AIRequestError as _0x2308dc}from'./aiadapter.js';import{BedrockRuntimeClient as _0x28f84d,InvokeModelCommand as _0x5a2add,InvokeModelWithResponseStreamCommand as _0x1f3eaa}from'@aws-sdk/client-bedrock-runtime';import{getTranslation as _0x5cd395}from'../utils/common-translations.js';export default class O extends _0x1966a9{static get[_0x3fa0c7(0x16a)](){const _0x2daeb6=_0x3fa0c7;return _0x2daeb6(0x13c);}constructor(_0x50644c){const _0x42a49e=_0x3fa0c7;super(_0x50644c),_0x50644c[_0x42a49e(0x12e)][_0x42a49e(0x126)](_0x42a49e(0x133))||_0x50644c[_0x42a49e(0x12e)][_0x42a49e(0x144)](_0x42a49e(0x133),{'model':_0x42a49e(0x13f),'max_tokens_to_sample':0x7d0,'temperature':0x1,'top_p':0x1,'top_k':0xfa,'anthropic_version':_0x42a49e(0x137),'stream':!0x0}),this[_0x42a49e(0x166)]=_0x50644c[_0x42a49e(0x12e)][_0x42a49e(0x126)](_0x42a49e(0x139)),this[_0x42a49e(0x14a)]=_0x50644c[_0x42a49e(0x12e)][_0x42a49e(0x126)](_0x42a49e(0x154)),this[_0x42a49e(0x16e)]=_0x50644c[_0x42a49e(0x12e)][_0x42a49e(0x126)](_0x42a49e(0x125)),this[_0x42a49e(0x16c)]=_0x50644c[_0x42a49e(0x12e)][_0x42a49e(0x126)](_0x42a49e(0x133));}async[_0x3fa0c7(0x12c)]({query:_0x55c384,context:_0x295645,onData:_0x2876ae,actionId:_0x349af9}){const _0x473d5a=_0x3fa0c7,{model:_0x9b8ebc,stream:_0x32f7b8,..._0x5576dd}=await this[_0x473d5a(0x122)](this[_0x473d5a(0x16c)],_0x349af9),_0x39e616={'prompt':await this[_0x473d5a(0x15b)](_0x55c384,_0x295645,_0x9b8ebc,_0x349af9),..._0x5576dd};this[_0x473d5a(0x166)]?await this[_0x473d5a(0x167)](_0x39e616,_0x9b8ebc,_0x32f7b8,_0x2876ae,_0x349af9):await this[_0x473d5a(0x162)](_0x39e616,_0x9b8ebc,_0x32f7b8,_0x2876ae);}async[_0x3fa0c7(0x15b)](_0x5b5eb0,_0x57fc3d,_0x3caa69,_0x220773){const _0x3bef8d=_0x3fa0c7;let _0x515d29,_0x47d1ab;return _0x57fc3d?(_0x515d29=_0x3bef8d(0x124),_0x47d1ab=_0x3bef8d(0x11f)+_0x5b5eb0+_0x3bef8d(0x164)+_0x57fc3d):(_0x515d29=_0x3bef8d(0x121),_0x47d1ab=_0x5b5eb0),_0x3bef8d(0x143)==this[_0x3bef8d(0x165)](_0x3caa69)?_0x3bef8d(0x147)+_0x515d29+_0x3bef8d(0x15f)+_0x47d1ab+_0x3bef8d(0x13a):_0x3bef8d(0x138)+_0x515d29+'\x0a'+_0x47d1ab+_0x3bef8d(0x15e);}[_0x3fa0c7(0x165)](_0x50cee8){const _0xdf783a=_0x3fa0c7;if(/^anthropic\.claude/[_0xdf783a(0x16d)](_0x50cee8))return _0xdf783a(0x157);if(/^ai21\.j2/[_0xdf783a(0x16d)](_0x50cee8))return _0xdf783a(0x135);if(/^cohere\.command/[_0xdf783a(0x16d)](_0x50cee8))return _0xdf783a(0x14d);if(/^meta\.llama/[_0xdf783a(0x16d)](_0x50cee8))return _0xdf783a(0x143);throw new _0x2308dc(_0x5cd395(this[_0xdf783a(0x13b)][_0xdf783a(0x151)],_0xdf783a(0x123),_0x50cee8));}async[_0x3fa0c7(0x167)](_0xcc9235,_0x97f77f,_0x15de3f,_0xb6a12a,_0x56a0ab){const _0x51df59=_0x3fa0c7,_0x3e1b08={'method':_0x51df59(0x141),'headers':await this[_0x51df59(0x13e)](this[_0x51df59(0x16e)],_0x56a0ab),'body':JSON[_0x51df59(0x15a)]({..._0xcc9235,'model':_0x97f77f,'stream':_0x15de3f}),'signal':this[_0x51df59(0x150)][_0x51df59(0x11d)]},_0xbb4d28=await fetch(this[_0x51df59(0x166)],_0x3e1b08);_0x15de3f?await this[_0x51df59(0x12b)](_0xbb4d28,_0x97f77f,_0xb6a12a):await this[_0x51df59(0x14c)](_0xbb4d28,_0x97f77f,_0xb6a12a);}async[_0x3fa0c7(0x162)](_0x454117,_0x4af196,_0x172b58,_0x1ff2d0){const _0xf55d4e=_0x3fa0c7,_0xcc0f08=new _0x28f84d(this[_0xf55d4e(0x14a)]),_0x4b82ff={'body':JSON[_0xf55d4e(0x15a)](_0x454117),'contentType':_0xf55d4e(0x127),'accept':_0xf55d4e(0x127),'modelId':_0x4af196};let _0x3a195a;if(_0x172b58){const _0x2f2b96=new _0x1f3eaa(_0x4b82ff);_0x3a195a=await _0xcc0f08[_0xf55d4e(0x159)](_0x2f2b96,{'abortSignal':this[_0xf55d4e(0x150)][_0xf55d4e(0x11d)]}),await this[_0xf55d4e(0x14f)](_0x3a195a,_0x4af196,_0x1ff2d0);}else{const _0x2d2827=new _0x5a2add(_0x4b82ff);_0x3a195a=await _0xcc0f08[_0xf55d4e(0x159)](_0x2d2827,{'abortSignal':this[_0xf55d4e(0x150)][_0xf55d4e(0x11d)]}),await this[_0xf55d4e(0x14c)](_0x3a195a,_0x4af196,_0x1ff2d0);}}async[_0x3fa0c7(0x14f)](_0x5bf797,_0x275898,_0x443f47){const _0x16949d=_0x3fa0c7,_0x7f9a0d=_0x5bf797[_0x16949d(0x161)],_0x4639ca=new TextDecoder(_0x16949d(0x128));let _0x372622='';for await(const _0x1d3e82 of _0x7f9a0d)if(_0x1d3e82[_0x16949d(0x168)]){const _0x4b9084=_0x4639ca[_0x16949d(0x140)](_0x1d3e82[_0x16949d(0x168)][_0x16949d(0x12a)]),_0x582823=JSON[_0x16949d(0x11c)](_0x4b9084);_0x372622+=this[_0x16949d(0x11e)](_0x582823,_0x275898),_0x443f47(_0x372622);}return Promise[_0x16949d(0x145)]();}async[_0x3fa0c7(0x12b)](_0x578a52,_0x42fc6a,_0x1bf02f){const _0x2c3323=_0x3fa0c7,_0x5eed45=_0x578a52[_0x2c3323(0x161)],_0x1a581b=new TextDecoder(_0x2c3323(0x128)),_0x2c4130=_0x5eed45[_0x2c3323(0x152)]();let _0x187e53='',_0x3cf61f='',_0x3a9fa1=!0x1;for(;!_0x3a9fa1;){const {done:_0x2ad132,value:_0x3bce96}=await _0x2c4130[_0x2c3323(0x15d)]();if(_0x3a9fa1=_0x2ad132,_0x3a9fa1)break;const _0x4a0347=(_0x187e53+_0x1a581b[_0x2c3323(0x140)](_0x3bce96))[_0x2c3323(0x120)]('\x0a')[_0x2c3323(0x142)](_0x1bf6ad=>{const _0x197dc0=_0x2c3323;try{return _0x187e53='',JSON[_0x197dc0(0x11c)](_0x1bf6ad);}catch(_0x422abf){return _0x187e53=_0x1bf6ad,null;}})[_0x2c3323(0x160)](_0x238674=>null!==_0x238674);_0x4a0347[_0x2c3323(0x13d)]&&(_0x3cf61f+=_0x4a0347[_0x2c3323(0x142)](_0x4d23bd=>this[_0x2c3323(0x11e)](_0x4d23bd,_0x42fc6a))[_0x2c3323(0x163)](''),_0x1bf02f(_0x3cf61f));}return Promise[_0x2c3323(0x145)]();}async[_0x3fa0c7(0x14c)](_0x331868,_0x3926d7,_0x33062){const _0x516a88=_0x3fa0c7;let _0xa30d4f;return _0xa30d4f=_0x331868 instanceof Response?await _0x331868[_0x516a88(0x156)]():JSON[_0x516a88(0x11c)](Buffer[_0x516a88(0x153)](_0x331868[_0x516a88(0x161)])[_0x516a88(0x14b)](_0x516a88(0x146))),(_0x33062(this[_0x516a88(0x11e)](_0xa30d4f,_0x3926d7)),Promise[_0x516a88(0x145)]());}[_0x3fa0c7(0x11e)](_0x12b0d7,_0x5d317c){const _0x3c12ee=_0x3fa0c7;switch(this[_0x3c12ee(0x165)](_0x5d317c)){case _0x3c12ee(0x157):return _0x12b0d7[_0x3c12ee(0x15c)];case _0x3c12ee(0x135):return _0x12b0d7[_0x3c12ee(0x130)][0x0][_0x3c12ee(0x169)][_0x3c12ee(0x131)];case _0x3c12ee(0x14d):return _0x12b0d7[_0x3c12ee(0x155)][0x0][_0x3c12ee(0x131)];case _0x3c12ee(0x143):return _0x12b0d7[_0x3c12ee(0x16b)];}}}
|