@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.
Files changed (361) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +26 -0
  3. package/README.md +38 -0
  4. package/build/ai.js +5 -0
  5. package/build/translations/af.js +1 -0
  6. package/build/translations/ar.js +1 -0
  7. package/build/translations/bg.js +1 -0
  8. package/build/translations/bn.js +1 -0
  9. package/build/translations/bs.js +1 -0
  10. package/build/translations/ca.js +1 -0
  11. package/build/translations/cs.js +1 -0
  12. package/build/translations/da.js +1 -0
  13. package/build/translations/de-ch.js +1 -0
  14. package/build/translations/de.js +1 -0
  15. package/build/translations/el.js +1 -0
  16. package/build/translations/en-au.js +1 -0
  17. package/build/translations/es-co.js +1 -0
  18. package/build/translations/es.js +1 -0
  19. package/build/translations/et.js +1 -0
  20. package/build/translations/fa.js +1 -0
  21. package/build/translations/fi.js +1 -0
  22. package/build/translations/fr.js +1 -0
  23. package/build/translations/gl.js +1 -0
  24. package/build/translations/he.js +1 -0
  25. package/build/translations/hi.js +1 -0
  26. package/build/translations/hr.js +1 -0
  27. package/build/translations/hu.js +1 -0
  28. package/build/translations/id.js +1 -0
  29. package/build/translations/it.js +1 -0
  30. package/build/translations/ja.js +1 -0
  31. package/build/translations/jv.js +1 -0
  32. package/build/translations/ko.js +1 -0
  33. package/build/translations/lt.js +1 -0
  34. package/build/translations/lv.js +1 -0
  35. package/build/translations/ms.js +1 -0
  36. package/build/translations/nl.js +1 -0
  37. package/build/translations/no.js +1 -0
  38. package/build/translations/pl.js +1 -0
  39. package/build/translations/pt-br.js +1 -0
  40. package/build/translations/pt.js +1 -0
  41. package/build/translations/ro.js +1 -0
  42. package/build/translations/ru.js +1 -0
  43. package/build/translations/sk.js +1 -0
  44. package/build/translations/sr-latn.js +1 -0
  45. package/build/translations/sr.js +1 -0
  46. package/build/translations/sv.js +1 -0
  47. package/build/translations/th.js +1 -0
  48. package/build/translations/ti.js +1 -0
  49. package/build/translations/tk.js +1 -0
  50. package/build/translations/tr.js +1 -0
  51. package/build/translations/tt.js +1 -0
  52. package/build/translations/ug.js +1 -0
  53. package/build/translations/uk.js +1 -0
  54. package/build/translations/ur.js +1 -0
  55. package/build/translations/uz.js +1 -0
  56. package/build/translations/vi.js +1 -0
  57. package/build/translations/zh-cn.js +1 -0
  58. package/build/translations/zh.js +1 -0
  59. package/ckeditor5-metadata.json +23 -0
  60. package/dist/adapters/aiadapter.d.ts +60 -0
  61. package/dist/adapters/aitextadapter.d.ts +150 -0
  62. package/dist/adapters/awstextadapter.d.ts +183 -0
  63. package/dist/adapters/openaitextadapter.d.ts +187 -0
  64. package/dist/aiassistant.d.ts +393 -0
  65. package/dist/aiassistantediting.d.ts +59 -0
  66. package/dist/aiassistantui.d.ts +62 -0
  67. package/dist/aiconfig.d.ts +73 -0
  68. package/dist/augmentation.d.ts +31 -0
  69. package/dist/index-content.css +6 -0
  70. package/dist/index-editor.css +297 -0
  71. package/dist/index.css +392 -0
  72. package/dist/index.d.ts +17 -0
  73. package/dist/index.js +24 -0
  74. package/dist/legacyerrors.d.ts +24 -0
  75. package/dist/translations/af.d.ts +8 -0
  76. package/dist/translations/af.js +23 -0
  77. package/dist/translations/af.umd.js +23 -0
  78. package/dist/translations/ar.d.ts +8 -0
  79. package/dist/translations/ar.js +23 -0
  80. package/dist/translations/ar.umd.js +23 -0
  81. package/dist/translations/bg.d.ts +8 -0
  82. package/dist/translations/bg.js +23 -0
  83. package/dist/translations/bg.umd.js +23 -0
  84. package/dist/translations/bn.d.ts +8 -0
  85. package/dist/translations/bn.js +23 -0
  86. package/dist/translations/bn.umd.js +23 -0
  87. package/dist/translations/bs.d.ts +8 -0
  88. package/dist/translations/bs.js +23 -0
  89. package/dist/translations/bs.umd.js +23 -0
  90. package/dist/translations/ca.d.ts +8 -0
  91. package/dist/translations/ca.js +23 -0
  92. package/dist/translations/ca.umd.js +23 -0
  93. package/dist/translations/cs.d.ts +8 -0
  94. package/dist/translations/cs.js +23 -0
  95. package/dist/translations/cs.umd.js +23 -0
  96. package/dist/translations/da.d.ts +8 -0
  97. package/dist/translations/da.js +23 -0
  98. package/dist/translations/da.umd.js +23 -0
  99. package/dist/translations/de-ch.d.ts +8 -0
  100. package/dist/translations/de-ch.js +23 -0
  101. package/dist/translations/de-ch.umd.js +23 -0
  102. package/dist/translations/de.d.ts +8 -0
  103. package/dist/translations/de.js +23 -0
  104. package/dist/translations/de.umd.js +23 -0
  105. package/dist/translations/el.d.ts +8 -0
  106. package/dist/translations/el.js +23 -0
  107. package/dist/translations/el.umd.js +23 -0
  108. package/dist/translations/en-au.d.ts +8 -0
  109. package/dist/translations/en-au.js +23 -0
  110. package/dist/translations/en-au.umd.js +23 -0
  111. package/dist/translations/en.d.ts +8 -0
  112. package/dist/translations/en.js +23 -0
  113. package/dist/translations/en.umd.js +23 -0
  114. package/dist/translations/es-co.d.ts +8 -0
  115. package/dist/translations/es-co.js +23 -0
  116. package/dist/translations/es-co.umd.js +23 -0
  117. package/dist/translations/es.d.ts +8 -0
  118. package/dist/translations/es.js +23 -0
  119. package/dist/translations/es.umd.js +23 -0
  120. package/dist/translations/et.d.ts +8 -0
  121. package/dist/translations/et.js +23 -0
  122. package/dist/translations/et.umd.js +23 -0
  123. package/dist/translations/fa.d.ts +8 -0
  124. package/dist/translations/fa.js +23 -0
  125. package/dist/translations/fa.umd.js +23 -0
  126. package/dist/translations/fi.d.ts +8 -0
  127. package/dist/translations/fi.js +23 -0
  128. package/dist/translations/fi.umd.js +23 -0
  129. package/dist/translations/fr.d.ts +8 -0
  130. package/dist/translations/fr.js +23 -0
  131. package/dist/translations/fr.umd.js +23 -0
  132. package/dist/translations/gl.d.ts +8 -0
  133. package/dist/translations/gl.js +23 -0
  134. package/dist/translations/gl.umd.js +23 -0
  135. package/dist/translations/he.d.ts +8 -0
  136. package/dist/translations/he.js +23 -0
  137. package/dist/translations/he.umd.js +23 -0
  138. package/dist/translations/hi.d.ts +8 -0
  139. package/dist/translations/hi.js +23 -0
  140. package/dist/translations/hi.umd.js +23 -0
  141. package/dist/translations/hr.d.ts +8 -0
  142. package/dist/translations/hr.js +23 -0
  143. package/dist/translations/hr.umd.js +23 -0
  144. package/dist/translations/hu.d.ts +8 -0
  145. package/dist/translations/hu.js +23 -0
  146. package/dist/translations/hu.umd.js +23 -0
  147. package/dist/translations/id.d.ts +8 -0
  148. package/dist/translations/id.js +23 -0
  149. package/dist/translations/id.umd.js +23 -0
  150. package/dist/translations/it.d.ts +8 -0
  151. package/dist/translations/it.js +23 -0
  152. package/dist/translations/it.umd.js +23 -0
  153. package/dist/translations/ja.d.ts +8 -0
  154. package/dist/translations/ja.js +23 -0
  155. package/dist/translations/ja.umd.js +23 -0
  156. package/dist/translations/jv.d.ts +8 -0
  157. package/dist/translations/jv.js +23 -0
  158. package/dist/translations/jv.umd.js +23 -0
  159. package/dist/translations/ko.d.ts +8 -0
  160. package/dist/translations/ko.js +23 -0
  161. package/dist/translations/ko.umd.js +23 -0
  162. package/dist/translations/lt.d.ts +8 -0
  163. package/dist/translations/lt.js +23 -0
  164. package/dist/translations/lt.umd.js +23 -0
  165. package/dist/translations/lv.d.ts +8 -0
  166. package/dist/translations/lv.js +23 -0
  167. package/dist/translations/lv.umd.js +23 -0
  168. package/dist/translations/ms.d.ts +8 -0
  169. package/dist/translations/ms.js +23 -0
  170. package/dist/translations/ms.umd.js +23 -0
  171. package/dist/translations/nl.d.ts +8 -0
  172. package/dist/translations/nl.js +23 -0
  173. package/dist/translations/nl.umd.js +23 -0
  174. package/dist/translations/no.d.ts +8 -0
  175. package/dist/translations/no.js +23 -0
  176. package/dist/translations/no.umd.js +23 -0
  177. package/dist/translations/pl.d.ts +8 -0
  178. package/dist/translations/pl.js +23 -0
  179. package/dist/translations/pl.umd.js +23 -0
  180. package/dist/translations/pt-br.d.ts +8 -0
  181. package/dist/translations/pt-br.js +23 -0
  182. package/dist/translations/pt-br.umd.js +23 -0
  183. package/dist/translations/pt.d.ts +8 -0
  184. package/dist/translations/pt.js +23 -0
  185. package/dist/translations/pt.umd.js +23 -0
  186. package/dist/translations/ro.d.ts +8 -0
  187. package/dist/translations/ro.js +23 -0
  188. package/dist/translations/ro.umd.js +23 -0
  189. package/dist/translations/ru.d.ts +8 -0
  190. package/dist/translations/ru.js +23 -0
  191. package/dist/translations/ru.umd.js +23 -0
  192. package/dist/translations/sk.d.ts +8 -0
  193. package/dist/translations/sk.js +23 -0
  194. package/dist/translations/sk.umd.js +23 -0
  195. package/dist/translations/sr-latn.d.ts +8 -0
  196. package/dist/translations/sr-latn.js +23 -0
  197. package/dist/translations/sr-latn.umd.js +23 -0
  198. package/dist/translations/sr.d.ts +8 -0
  199. package/dist/translations/sr.js +23 -0
  200. package/dist/translations/sr.umd.js +23 -0
  201. package/dist/translations/sv.d.ts +8 -0
  202. package/dist/translations/sv.js +23 -0
  203. package/dist/translations/sv.umd.js +23 -0
  204. package/dist/translations/th.d.ts +8 -0
  205. package/dist/translations/th.js +23 -0
  206. package/dist/translations/th.umd.js +23 -0
  207. package/dist/translations/ti.d.ts +8 -0
  208. package/dist/translations/ti.js +23 -0
  209. package/dist/translations/ti.umd.js +23 -0
  210. package/dist/translations/tk.d.ts +8 -0
  211. package/dist/translations/tk.js +23 -0
  212. package/dist/translations/tk.umd.js +23 -0
  213. package/dist/translations/tr.d.ts +8 -0
  214. package/dist/translations/tr.js +23 -0
  215. package/dist/translations/tr.umd.js +23 -0
  216. package/dist/translations/tt.d.ts +8 -0
  217. package/dist/translations/tt.js +23 -0
  218. package/dist/translations/tt.umd.js +23 -0
  219. package/dist/translations/ug.d.ts +8 -0
  220. package/dist/translations/ug.js +23 -0
  221. package/dist/translations/ug.umd.js +23 -0
  222. package/dist/translations/uk.d.ts +8 -0
  223. package/dist/translations/uk.js +23 -0
  224. package/dist/translations/uk.umd.js +23 -0
  225. package/dist/translations/ur.d.ts +8 -0
  226. package/dist/translations/ur.js +23 -0
  227. package/dist/translations/ur.umd.js +23 -0
  228. package/dist/translations/uz.d.ts +8 -0
  229. package/dist/translations/uz.js +23 -0
  230. package/dist/translations/uz.umd.js +23 -0
  231. package/dist/translations/vi.d.ts +8 -0
  232. package/dist/translations/vi.js +23 -0
  233. package/dist/translations/vi.umd.js +23 -0
  234. package/dist/translations/zh-cn.d.ts +8 -0
  235. package/dist/translations/zh-cn.js +23 -0
  236. package/dist/translations/zh-cn.umd.js +23 -0
  237. package/dist/translations/zh.d.ts +8 -0
  238. package/dist/translations/zh.js +23 -0
  239. package/dist/translations/zh.umd.js +23 -0
  240. package/dist/ui/aiassistantcontroller.d.ts +113 -0
  241. package/dist/ui/form/aiformcontentarea.d.ts +52 -0
  242. package/dist/ui/form/aiformerrorview.d.ts +30 -0
  243. package/dist/ui/form/aiformpromptview.d.ts +50 -0
  244. package/dist/ui/form/aiformtoolbarview.d.ts +62 -0
  245. package/dist/ui/form/aiformview.d.ts +145 -0
  246. package/dist/ui/form/aihistorylistitemview.d.ts +22 -0
  247. package/dist/ui/form/aihistorylistview.d.ts +39 -0
  248. package/dist/ui/form/prompthistory.d.ts +24 -0
  249. package/dist/ui/showaiassistantcommand.d.ts +44 -0
  250. package/dist/utils/common-translations.d.ts +13 -0
  251. package/dist/utils/normalizecommandsconfig.d.ts +18 -0
  252. package/lang/contexts.json +56 -0
  253. package/lang/translations/af.po +230 -0
  254. package/lang/translations/ar.po +230 -0
  255. package/lang/translations/bg.po +230 -0
  256. package/lang/translations/bn.po +230 -0
  257. package/lang/translations/bs.po +230 -0
  258. package/lang/translations/ca.po +230 -0
  259. package/lang/translations/cs.po +230 -0
  260. package/lang/translations/da.po +230 -0
  261. package/lang/translations/de-ch.po +230 -0
  262. package/lang/translations/de.po +230 -0
  263. package/lang/translations/el.po +230 -0
  264. package/lang/translations/en-au.po +230 -0
  265. package/lang/translations/en.po +230 -0
  266. package/lang/translations/es-co.po +230 -0
  267. package/lang/translations/es.po +230 -0
  268. package/lang/translations/et.po +230 -0
  269. package/lang/translations/fa.po +230 -0
  270. package/lang/translations/fi.po +230 -0
  271. package/lang/translations/fr.po +230 -0
  272. package/lang/translations/gl.po +230 -0
  273. package/lang/translations/he.po +230 -0
  274. package/lang/translations/hi.po +230 -0
  275. package/lang/translations/hr.po +230 -0
  276. package/lang/translations/hu.po +230 -0
  277. package/lang/translations/id.po +230 -0
  278. package/lang/translations/it.po +230 -0
  279. package/lang/translations/ja.po +230 -0
  280. package/lang/translations/jv.po +230 -0
  281. package/lang/translations/ko.po +230 -0
  282. package/lang/translations/lt.po +230 -0
  283. package/lang/translations/lv.po +230 -0
  284. package/lang/translations/ms.po +230 -0
  285. package/lang/translations/nl.po +230 -0
  286. package/lang/translations/no.po +230 -0
  287. package/lang/translations/pl.po +230 -0
  288. package/lang/translations/pt-br.po +230 -0
  289. package/lang/translations/pt.po +230 -0
  290. package/lang/translations/ro.po +230 -0
  291. package/lang/translations/ru.po +230 -0
  292. package/lang/translations/sk.po +230 -0
  293. package/lang/translations/sr-latn.po +230 -0
  294. package/lang/translations/sr.po +230 -0
  295. package/lang/translations/sv.po +230 -0
  296. package/lang/translations/th.po +230 -0
  297. package/lang/translations/ti.po +230 -0
  298. package/lang/translations/tk.po +230 -0
  299. package/lang/translations/tr.po +230 -0
  300. package/lang/translations/tt.po +230 -0
  301. package/lang/translations/ug.po +230 -0
  302. package/lang/translations/uk.po +230 -0
  303. package/lang/translations/ur.po +230 -0
  304. package/lang/translations/uz.po +230 -0
  305. package/lang/translations/vi.po +230 -0
  306. package/lang/translations/zh-cn.po +230 -0
  307. package/lang/translations/zh.po +230 -0
  308. package/package.json +53 -0
  309. package/src/adapters/aiadapter.d.ts +56 -0
  310. package/src/adapters/aiadapter.js +23 -0
  311. package/src/adapters/aitextadapter.d.ts +146 -0
  312. package/src/adapters/aitextadapter.js +23 -0
  313. package/src/adapters/awstextadapter.d.ts +179 -0
  314. package/src/adapters/awstextadapter.js +23 -0
  315. package/src/adapters/openaitextadapter.d.ts +183 -0
  316. package/src/adapters/openaitextadapter.js +23 -0
  317. package/src/aiassistant.d.ts +389 -0
  318. package/src/aiassistant.js +23 -0
  319. package/src/aiassistantediting.d.ts +55 -0
  320. package/src/aiassistantediting.js +23 -0
  321. package/src/aiassistantui.d.ts +58 -0
  322. package/src/aiassistantui.js +23 -0
  323. package/src/aiconfig.d.ts +69 -0
  324. package/src/aiconfig.js +23 -0
  325. package/src/augmentation.d.ts +27 -0
  326. package/src/augmentation.js +23 -0
  327. package/src/index.d.ts +13 -0
  328. package/src/index.js +23 -0
  329. package/src/legacyerrors.d.ts +20 -0
  330. package/src/legacyerrors.js +23 -0
  331. package/src/ui/aiassistantcontroller.d.ts +109 -0
  332. package/src/ui/aiassistantcontroller.js +24 -0
  333. package/src/ui/form/aiformcontentarea.d.ts +48 -0
  334. package/src/ui/form/aiformcontentarea.js +23 -0
  335. package/src/ui/form/aiformerrorview.d.ts +26 -0
  336. package/src/ui/form/aiformerrorview.js +23 -0
  337. package/src/ui/form/aiformpromptview.d.ts +46 -0
  338. package/src/ui/form/aiformpromptview.js +23 -0
  339. package/src/ui/form/aiformtoolbarview.d.ts +58 -0
  340. package/src/ui/form/aiformtoolbarview.js +23 -0
  341. package/src/ui/form/aiformview.d.ts +141 -0
  342. package/src/ui/form/aiformview.js +23 -0
  343. package/src/ui/form/aihistorylistitemview.d.ts +18 -0
  344. package/src/ui/form/aihistorylistitemview.js +23 -0
  345. package/src/ui/form/aihistorylistview.d.ts +35 -0
  346. package/src/ui/form/aihistorylistview.js +23 -0
  347. package/src/ui/form/prompthistory.d.ts +20 -0
  348. package/src/ui/form/prompthistory.js +23 -0
  349. package/src/ui/showaiassistantcommand.d.ts +40 -0
  350. package/src/ui/showaiassistantcommand.js +23 -0
  351. package/src/utils/common-translations.d.ts +9 -0
  352. package/src/utils/common-translations.js +23 -0
  353. package/src/utils/normalizecommandsconfig.d.ts +14 -0
  354. package/src/utils/normalizecommandsconfig.js +23 -0
  355. package/theme/ai-dropdown.css +37 -0
  356. package/theme/ai-form.css +262 -0
  357. package/theme/ai.css +120 -0
  358. package/theme/icons/copy.svg +1 -0
  359. package/theme/icons/error.svg +1 -0
  360. package/theme/icons/magic-wand.svg +1 -0
  361. package/theme/icons/submit.svg +1 -0
@@ -0,0 +1,183 @@
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/openaitextadapter
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
+ /**
12
+ * Adapter for AI text-related requests that supports OpenAI and Azure OpenAI services.
13
+ *
14
+ * See also {@link module:ai/adapters/aitextadapter~AITextAdapter}.
15
+ */
16
+ export default class OpenAITextAdapter extends AITextAdapter {
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ static get pluginName(): "OpenAITextAdapter";
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ constructor(editor: Editor);
25
+ /**
26
+ * Performs the request to the OpenAI service, Azure OpenAI service, or to the endpoint provided in the editor configuration.
27
+ *
28
+ * If you want to extend this adapter, you can overload this method to do some additional processing or make an external call.
29
+ */
30
+ sendRequest({ query, context, onData, actionId }: AITextAdapterRequestData): Promise<void>;
31
+ /**
32
+ * Prepares the actual request messages to be sent as a part of the request to the AI service.
33
+ *
34
+ * See [OpenAI API reference](https://platform.openai.com/docs/api-reference/chat/create) to learn more.
35
+ *
36
+ * This method returns two messages, one "system message" with general instructions for the model and one "user message"
37
+ * with the actual instruction to perform.
38
+ *
39
+ * The messages are different, based on whether there is any `context` provided. If no `context` is provided, it is assumed that
40
+ * the user wants to generate new content. If `context` is provided, it is assumed that the user wants to process this `context`
41
+ * (e.g. translate) or generate something based on `context` (e.g. summary).
42
+ *
43
+ * You can overload this method to customize the messages that are sent to the AI service.
44
+ *
45
+ * @param query The user's query. The instruction which the model should perform.
46
+ * @param context The context for the instruction. Usually this will be a part of the editor content. Can be empty.
47
+ * @param actionId ID of the performed action. See {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId}.
48
+ */
49
+ prepareMessages(query: string, context: string, actionId: string): Promise<Array<RequestMessageItem>>;
50
+ }
51
+ /**
52
+ * The configuration for the OpenAI adapter.
53
+ *
54
+ * The properties defined in this config are set in the `config.ai.openAI` namespace.
55
+ *
56
+ * ```ts
57
+ * ClassicEditor
58
+ * .create( editorElement, {
59
+ * ai: {
60
+ * openAI: {
61
+ * requestHeaders: {
62
+ * Authorization: 'Bearer OPENAI_API_KEY'
63
+ * }
64
+ * }
65
+ * }
66
+ * } )
67
+ * .then( ... )
68
+ * .catch( ... );
69
+ * ```
70
+ *
71
+ * See {@link module:ai/aiconfig~AIConfig the full AI configuration}.
72
+ *
73
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
74
+ */
75
+ export interface OpenAITextAdapterConfig {
76
+ /**
77
+ * The URL to which the AI service request will be sent.
78
+ *
79
+ * By default, requests are sent to the OpenAI API service. Change this value to make requests to Azure OpenAI API or use proxy endpoint
80
+ * in your application instead.
81
+ *
82
+ * Defaults to `'https://api.openai.com/v1/chat/completions'`.
83
+ */
84
+ apiUrl?: string;
85
+ /**
86
+ * Object with headers to set in the request to the AI service API.
87
+ *
88
+ * If the provided value is an `object`, it is simply used as provided.
89
+ *
90
+ * If you are connecting directly to the OpenAI API, use your OpenAI API key in the following way:
91
+ *
92
+ * ```js
93
+ * {
94
+ * ai: {
95
+ * openAI: {
96
+ * requestHeaders: {
97
+ * 'Authorization': 'Bearer YOUR_API_KEY'
98
+ * }
99
+ * // ...
100
+ * }
101
+ * // ..
102
+ * }
103
+ * }
104
+ * ```
105
+ *
106
+ * **Important: use your API key ONLY in a development environment or for testing purposes!**
107
+ * In the production environment, pass your request through a proxy endpoint.
108
+ *
109
+ * If you are using a proxy service to send requests to the OpenAI API, `requestHeaders` can be used to implement authorization for your
110
+ * requests.
111
+ *
112
+ * If the provided value is a function, it should be a function that returns a `Promise` which resolves with the headers object.
113
+ * This way, you can perform an authorization request to your application and receive the authorization token (and also implement
114
+ * any custom logic on the back-end side). The headers object is then used to make the actual call to the AI service.
115
+ *
116
+ * The function is passed {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
117
+ * possible to further customize the headers.
118
+ *
119
+ * ```js
120
+ * {
121
+ * ai: {
122
+ * openAI: {
123
+ * requestHeaders: async () => {
124
+ * const jwt = await fetch( 'https://example.com/jwt-endpoint' );
125
+ *
126
+ * return {
127
+ * 'Authorization': 'Bearer ' + jwt
128
+ * };
129
+ * }
130
+ * // ...
131
+ * }
132
+ * }
133
+ * }
134
+ * ```
135
+ *
136
+ * If the function fails for any reason, the promise should be rejected. In this case, a feature that made the request should display
137
+ * an error notification.
138
+ */
139
+ requestHeaders?: RequestHeaders;
140
+ /**
141
+ * Additional configuration parameters for the AI service request. Use it to customize how the AI service generates responses.
142
+ * Note that the value you will set here will fully overwrite the default value.
143
+ *
144
+ * See [OpenAI API reference](https://platform.openai.com/docs/api-reference/chat/create) to learn more about available parameters.
145
+ *
146
+ * If the provided value is an `object`, it is passed to the request as provided.
147
+ *
148
+ * If the provided value is a function, it should be a function that returns a `Promise` which resolves with the request parameters
149
+ * object. This gives you more flexibility to provide parameters for the AI model.
150
+ *
151
+ * The function is passed {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} parameter to make it
152
+ * possible to further customize the parameters.
153
+ *
154
+ * If the function fails for any reason, the promise should be rejected. In this case, the feature that made the request should display
155
+ * an error notification.
156
+ *
157
+ * Defaults to:
158
+ *
159
+ * ```json
160
+ * {
161
+ * model: 'gpt-3.5-turbo',
162
+ * max_tokens: 2000,
163
+ * temperature: 1,
164
+ * top_p: 1,
165
+ * stream: true
166
+ * }
167
+ * ```
168
+ */
169
+ requestParameters?: RequestParameters;
170
+ }
171
+ /**
172
+ * Single message item, in the format required for the OpenAI request.
173
+ *
174
+ * Example:
175
+ *
176
+ * ```json
177
+ * { role: 'system', content: 'You are a helpful assistant.' }
178
+ * ```
179
+ *
180
+ * See [OpenAI API reference](https://platform.openai.com/docs/api-reference/chat/create) to learn more.
181
+ */
182
+ type RequestMessageItem = Record<string, string>;
183
+ export {};
@@ -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 _0xa3b6f0=_0x5582;function _0x5582(_0x150af7,_0x94df40){const _0x4e6c14=_0x4e6c();return _0x5582=function(_0x55828d,_0x580414){_0x55828d=_0x55828d-0xa4;let _0x1683e4=_0x4e6c14[_0x55828d];return _0x1683e4;},_0x5582(_0x150af7,_0x94df40);}(function(_0x4cd81e,_0x32b6c3){const _0x4f0324=_0x5582,_0x4af99c=_0x4cd81e();while(!![]){try{const _0x306912=-parseInt(_0x4f0324(0xe1))/0x1*(-parseInt(_0x4f0324(0xb0))/0x2)+parseInt(_0x4f0324(0xca))/0x3*(-parseInt(_0x4f0324(0xe6))/0x4)+-parseInt(_0x4f0324(0xa5))/0x5+-parseInt(_0x4f0324(0xaa))/0x6*(parseInt(_0x4f0324(0xae))/0x7)+parseInt(_0x4f0324(0xbf))/0x8*(-parseInt(_0x4f0324(0xdd))/0x9)+-parseInt(_0x4f0324(0xc7))/0xa*(-parseInt(_0x4f0324(0xb6))/0xb)+parseInt(_0x4f0324(0xb5))/0xc*(parseInt(_0x4f0324(0xc2))/0xd);if(_0x306912===_0x32b6c3)break;else _0x4af99c['push'](_0x4af99c['shift']());}catch(_0x2bb65a){_0x4af99c['push'](_0x4af99c['shift']());}}}(_0x4e6c,0x3fab7));import{default as _0x32582c}from'./aitextadapter.js';function _0x4e6c(){const _0x48a001=['Instruction:\x0a','split','stream','prepareMessages','sendRequest','delta','text','1234845WbAibc','reject','includes','length','[DONE]','153462ZnYtse','json','_readStaticResponse','stringify','77UQUjOp','config','2474RfKUEb','user','Moderation','_prepareRequestHeaders','message','24fveJjJ','24871YvnNzn','parse','pluginName','choices','getReader','AI_ERROR_MODERATION','AI_ERROR_CONTEXT_LENGTH','editor','_requestHeaders','3302168zxhamB','_apiUrl','map','5592353kIGYvX','https://api.openai.com/v1/chat/completions','\x0aYou\x20must\x20keep\x20the\x20text\x20formatting.\x0a\x0aContent:\x0a','filter','context_length_exceeded','1270sIehAD','replace','locale','1243362BQLqVU','POST','_isBufferIncomplete','decode','system','resolve','define','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.','data:\x20','_requestParameters','signal','abortController','read','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.openAI.requestParameters','_cleanUpData','_readStreamableResponse','gpt-3.5-turbo','9TbekFy','body','content','OpenAITextAdapter','379tMqWwQ','ai.openAI.apiUrl','ai.openAI.requestHeaders','join','get','4NfLaXJ'];_0x4e6c=function(){return _0x48a001;};return _0x4e6c();}import{AIRequestError as _0x15c88d}from'./aiadapter.js';import{getTranslation as _0x463493}from'../utils/common-translations.js';export default class H extends _0x32582c{static get[_0xa3b6f0(0xb8)](){const _0x1da55c=_0xa3b6f0;return _0x1da55c(0xe0);}constructor(_0x52effb){const _0x345e73=_0xa3b6f0;super(_0x52effb),_0x52effb[_0x345e73(0xaf)][_0x345e73(0xd0)](_0x345e73(0xe2),_0x345e73(0xc3)),_0x52effb[_0x345e73(0xaf)][_0x345e73(0xe5)](_0x345e73(0xd9))||_0x52effb[_0x345e73(0xaf)][_0x345e73(0xd0)](_0x345e73(0xd9),{'model':_0x345e73(0xdc),'max_tokens':0x7d0,'temperature':0x1,'top_p':0x1,'stream':!0x0}),this[_0x345e73(0xc0)]=_0x52effb[_0x345e73(0xaf)][_0x345e73(0xe5)](_0x345e73(0xe2)),this[_0x345e73(0xbe)]=_0x52effb[_0x345e73(0xaf)][_0x345e73(0xe5)](_0x345e73(0xe3))||{},this[_0x345e73(0xd3)]=_0x52effb[_0x345e73(0xaf)][_0x345e73(0xe5)](_0x345e73(0xd9));}async[_0xa3b6f0(0xeb)]({query:_0x131ac4,context:_0x16f043,onData:_0x4f7c47,actionId:_0xd04736}){const _0x5f01c9=_0xa3b6f0,_0x47179d=this[_0x5f01c9(0xbd)][_0x5f01c9(0xc9)],_0x16870c=await this[_0x5f01c9(0xea)](_0x131ac4,_0x16f043,_0xd04736),_0x20c3e6=await this[_0x5f01c9(0xb3)](this[_0x5f01c9(0xbe)],_0xd04736),_0x23a1be=await this[_0x5f01c9(0xd8)](this[_0x5f01c9(0xd3)],_0xd04736),_0x44adee={'messages':_0x16870c,..._0x23a1be},_0x1d9bfa={'method':_0x5f01c9(0xcb),'headers':_0x20c3e6,'body':JSON[_0x5f01c9(0xad)](_0x44adee),'signal':this[_0x5f01c9(0xd5)][_0x5f01c9(0xd4)]},_0x2786ff=await fetch(this[_0x5f01c9(0xc0)],_0x1d9bfa);if(_0x2786ff['ok'])return _0x23a1be[_0x5f01c9(0xe9)]?await this[_0x5f01c9(0xdb)](_0x2786ff,_0x4f7c47):await this[_0x5f01c9(0xac)](_0x2786ff,_0x4f7c47),Promise[_0x5f01c9(0xcf)]();{const _0x3e7e4b=await _0x2786ff[_0x5f01c9(0xa4)]();return _0x3e7e4b[_0x5f01c9(0xa7)](_0x5f01c9(0xc6))?Promise[_0x5f01c9(0xa6)](new _0x15c88d(_0x463493(_0x47179d,_0x5f01c9(0xbc)))):_0x3e7e4b[_0x5f01c9(0xa7)](_0x5f01c9(0xb2))?Promise[_0x5f01c9(0xa6)](new _0x15c88d(_0x463493(_0x47179d,_0x5f01c9(0xbb)))):Promise[_0x5f01c9(0xa6)](new Error(_0x3e7e4b));}}async[_0xa3b6f0(0xea)](_0x78ad28,_0x3bb3f1,_0xeb74ce){const _0x23f0cf=_0xa3b6f0;let _0x514fae,_0x2bcbc5;return _0x3bb3f1?(_0x514fae=_0x23f0cf(0xd1),_0x2bcbc5=_0x23f0cf(0xe7)+_0x78ad28+_0x23f0cf(0xc4)+_0x3bb3f1):(_0x514fae=_0x23f0cf(0xd7),_0x2bcbc5=_0x78ad28),[{'role':_0x23f0cf(0xce),'content':_0x514fae},{'role':_0x23f0cf(0xb1),'content':_0x2bcbc5}];}async[_0xa3b6f0(0xdb)](_0x393c06,_0x99ded6){const _0x416c2c=_0xa3b6f0,_0x2c74f2=_0x393c06[_0x416c2c(0xde)][_0x416c2c(0xba)](),_0x336600=new TextDecoder();let _0x583b6d='',_0x4c5a26='',_0x2a55f3='',_0x24f958=!0x1;for(;!_0x24f958;){const {done:_0x304c4a,value:_0xcc150}=await _0x2c74f2[_0x416c2c(0xd6)](),_0x2cab2c=_0x583b6d+_0x336600[_0x416c2c(0xcd)](_0xcc150);let _0x48a07f='';_0x24f958=_0x304c4a;try{_0x48a07f=this[_0x416c2c(0xda)](_0x2cab2c),_0x583b6d='';}catch(_0x4faebd){_0x583b6d=_0x2cab2c;continue;}_0x4c5a26+=_0x48a07f,!_0x24f958&&this[_0x416c2c(0xcc)](_0x4c5a26)||_0x4c5a26&&(_0x2a55f3+=_0x4c5a26,_0x4c5a26='',_0x99ded6(_0x2a55f3));}return Promise[_0x416c2c(0xcf)]();}async[_0xa3b6f0(0xac)](_0x37155,_0x3c8616){const _0x599a3c=_0xa3b6f0;return _0x3c8616((await _0x37155[_0x599a3c(0xab)]())[_0x599a3c(0xb9)][0x0][_0x599a3c(0xb4)][_0x599a3c(0xdf)]),Promise[_0x599a3c(0xcf)]();}[_0xa3b6f0(0xcc)](_0x5c93ae){const _0x4c0d83=_0xa3b6f0,_0xaa40af=_0x5c93ae[_0x4c0d83(0xe8)]('<')[_0x4c0d83(0xa8)]!==_0x5c93ae[_0x4c0d83(0xe8)]('>')[_0x4c0d83(0xa8)],_0x532a41=_0x5c93ae[_0x4c0d83(0xa8)]<0x1e;return _0xaa40af&&_0x532a41;}[_0xa3b6f0(0xda)](_0x30ac38){const _0x48fc7e=_0xa3b6f0;return _0x30ac38[_0x48fc7e(0xe8)](/\n(?![^{]*\})/g)[_0x48fc7e(0xc1)](_0x34d74f=>_0x34d74f[_0x48fc7e(0xc8)](_0x48fc7e(0xd2),''))[_0x48fc7e(0xc5)](_0xb3d5de=>_0xb3d5de&&_0xb3d5de[_0x48fc7e(0xa8)]>0x0&&_0x48fc7e(0xa9)!==_0xb3d5de)[_0x48fc7e(0xc1)](_0x2d9a16=>{const _0x2376b4=_0x48fc7e,{choices:_0x34ce81}=JSON[_0x2376b4(0xb7)](_0x2d9a16);if(_0x34ce81[0x0]&&_0x34ce81[0x0][_0x2376b4(0xec)]&&_0x34ce81[0x0][_0x2376b4(0xec)][_0x2376b4(0xdf)])return _0x34ce81[0x0][_0x2376b4(0xec)][_0x2376b4(0xdf)];})[_0x48fc7e(0xc5)](_0xe7f028=>_0xe7f028)[_0x48fc7e(0xe4)]('');}}
@@ -0,0 +1,389 @@
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/aiassistant
7
+ * @publicApi
8
+ */
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
+ /**
14
+ * AI assistant plugin that allows you to use external AI models to generate content or improve existing content.
15
+ *
16
+ * The feature uses following {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} values:
17
+ *
18
+ * * `aiAssistant:command:<commandId>` for the predefined commands, where `<commandId>` is the ID of the predefined command,
19
+ * * `aiAssistant:custom` for custom queries provided by the user.
20
+ */
21
+ export default class AIAssistant extends Plugin {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires(): readonly [typeof AIAssistantUI, typeof AIAssistantEditing];
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get pluginName(): "AIAssistant";
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get isOfficialPlugin(): true;
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get isPremiumPlugin(): true;
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ constructor(editor: Editor);
42
+ }
43
+ /**
44
+ * A function that returns the list of the default AI commands definitions in the given localization context.
45
+ */
46
+ export declare function getDefaultCommands(locale: Locale): Array<GroupDefinition>;
47
+ /**
48
+ * The configuration of the AI Assistant feature.
49
+ *
50
+ * The properties defined in this config are set in the `config.ai.aiAssistant` namespace.
51
+ *
52
+ * ```ts
53
+ * ClassicEditor
54
+ * .create( editorElement, {
55
+ * ai: {
56
+ * aiAssistant: {
57
+ * // AI Assistant configuration.
58
+ * }
59
+ * }
60
+ * } )
61
+ * .then( ... )
62
+ * .catch( ... );
63
+ * ```
64
+ *
65
+ * See {@link module:ai/aiconfig~AIConfig the full AI configuration}.
66
+ *
67
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
68
+ */
69
+ export interface AIAssistantConfig {
70
+ /**
71
+ * A list of all AI commands groups definitions to be displayed in the `'aiCommands'` UI dropdown.
72
+ *
73
+ * Setting this property will overwrite the default list of predefined commands.
74
+ *
75
+ * You can avoid creating any groups by providing a list of command definitions directly. In this case,
76
+ * commands will render as a flat list in the user interface.
77
+ *
78
+ * The default configuration is as follows. It can be obtained through {@link ~getDefaultCommands}:
79
+ *
80
+ * ```json
81
+ * [ {
82
+ * groupId: 'editOrReview',
83
+ * groupLabel: 'Edit or review',
84
+ * commands: [
85
+ * {
86
+ * id: 'improveWriting',
87
+ * label: 'Improve writing',
88
+ * prompt: 'Fix spelling mistakes, use proper grammar and apply good writing practices. Do not lose the original meaning.'
89
+ * },
90
+ * {
91
+ * id: 'makeShorter',
92
+ * label: 'Make shorter',
93
+ * prompt: 'Remove any repetitive, redundant, or non-essential writing in this content ' +
94
+ * 'without changing the meaning or losing any key information.'
95
+ * },
96
+ * {
97
+ * id: 'makeLonger',
98
+ * label: 'Make longer',
99
+ * prompt: 'Improve this content by using descriptive language and inserting more information and more detailed explanations.'
100
+ * },
101
+ * {
102
+ * id: 'simplifyLanguage',
103
+ * label: 'Simplify language',
104
+ * prompt: 'Simplify the writing style of this content ' +
105
+ * 'and reduce the complexity, so that the content is easy to understand.'
106
+ * }
107
+ * ]
108
+ * },
109
+ * {
110
+ * groupId: 'generate',
111
+ * groupLabel: 'Generate from selection',
112
+ * commands: [
113
+ * {
114
+ * id: 'summarize',
115
+ * label: 'Summarize',
116
+ * prompt: 'Summarize this content into one paragraph of text. Include only the key ideas and conclusions. Keep it short. '
117
+ * },
118
+ * {
119
+ * id: 'continue',
120
+ * label: 'Continue',
121
+ * prompt: 'Start with the provided content and write at the end of it continuing this topic. Keep the added part short.'
122
+ * }
123
+ * ]
124
+ * },
125
+ * {
126
+ * groupId: 'changeTone',
127
+ * groupLabel: 'Change tone',
128
+ * commands: [
129
+ * {
130
+ * id: 'professional',
131
+ * label: 'Professional',
132
+ * prompt: 'Improve using polished, formal, and respectful language ' +
133
+ * 'to convey professional expertise and competence.'
134
+ * },
135
+ * {
136
+ * id: 'casual',
137
+ * label: 'Casual',
138
+ * prompt: 'Improve using casual, informal language to convey a casual conversation with a real person.'
139
+ * },
140
+ * {
141
+ * id: 'direct',
142
+ * label: 'Direct',
143
+ * prompt: 'Improve using direct language using only the essential information.'
144
+ * },
145
+ * {
146
+ * id: 'confident',
147
+ * label: 'Confident',
148
+ * prompt: 'Improve using compelling, optimistic language to convey confidence in the writing.'
149
+ * },
150
+ * {
151
+ * id: 'friendly',
152
+ * label: 'Friendly',
153
+ * prompt: 'Improve using friendly, comforting language, to convey understanding and empathy.'
154
+ * }
155
+ * ]
156
+ * },
157
+ * {
158
+ * groupId: 'changeStyle',
159
+ * groupLabel: 'Change style',
160
+ * commands: [
161
+ * {
162
+ * id: 'business',
163
+ * label: 'Business',
164
+ * prompt: 'Rewrite this content as a business professional with formal language.'
165
+ * },
166
+ * {
167
+ * id: 'legal',
168
+ * label: 'Legal',
169
+ * prompt: 'Rewrite this content as a legal professional using valid legal terminology.'
170
+ * },
171
+ * {
172
+ * id: 'journalism',
173
+ * label: 'Journalism',
174
+ * prompt: 'Rewrite this content as a journalist using engaging language to convey the importance of the information.'
175
+ * },
176
+ * {
177
+ * id: 'poetic',
178
+ * label: 'Poetic',
179
+ * prompt: 'Rewrite this content as a poem using poetic techniques without losing the original meaning.'
180
+ * }
181
+ * ]
182
+ * },
183
+ * {
184
+ * groupId: 'translate',
185
+ * groupLabel: 'Translate',
186
+ * commands: [
187
+ * {
188
+ * id: 'translateEnglish',
189
+ * label: 'English',
190
+ * prompt: 'Translate the content to English language.'
191
+ * },
192
+ * {
193
+ * id: 'translateSpanish',
194
+ * label: 'Spanish',
195
+ * prompt: 'Translate the content to Spanish language.'
196
+ * },
197
+ * {
198
+ * id: 'translatePortuguese',
199
+ * label: 'Portuguese',
200
+ * prompt: 'Translate the content to Portuguese language.'
201
+ * },
202
+ * {
203
+ * id: 'translateGerman',
204
+ * label: 'German',
205
+ * prompt: 'Translate the content to German language.'
206
+ * },
207
+ * {
208
+ * id: 'translateFrench',
209
+ * label: 'French',
210
+ * prompt: 'Translate the content to French language.'
211
+ * },
212
+ * {
213
+ * id: 'translateChinese',
214
+ * label: 'Simplified Chinese',
215
+ * prompt: 'Translate the content to Simplified Chinese language.'
216
+ * },
217
+ * {
218
+ * id: 'translateHindi',
219
+ * label: 'Hindi',
220
+ * prompt: 'Translate the content to Hindi language.'
221
+ * },
222
+ * {
223
+ * id: 'translateArabic',
224
+ * label: 'Arabic',
225
+ * prompt: 'Translate the content to Arabic language.'
226
+ * }
227
+ * ]
228
+ * } ]
229
+ * ```
230
+ */
231
+ commands?: Array<GroupDefinition> | Array<CommandDefinition>;
232
+ /**
233
+ * A list of additional AI commands groups definitions that will extend
234
+ * {@link module:ai/aiassistant~AIAssistantConfig#commands default commands}.
235
+ *
236
+ * You can define new AI commands groups or add new AI commands to existing groups. If you add AI commands to an existing group,
237
+ * you do not need to specify `groupLabel` property. Use the (optional) `order` property to control the position of new groups
238
+ * and commands.
239
+ *
240
+ * An example configuration:
241
+ *
242
+ * ```json
243
+ * {
244
+ * aiAssistant: {
245
+ * extraCommandGroups: [
246
+ * // Add an AI command to an existing group:
247
+ * {
248
+ * groupId: 'changeTone',
249
+ * commands: [
250
+ * {
251
+ * id: 'sad',
252
+ * label: 'Sad',
253
+ * prompt: 'Rewrite this text to make it sound sad and depressing.',
254
+ * // You can specify the position of this command among existing ones. Commands use zero-based numbering.
255
+ * order: 2
256
+ * }
257
+ * ]
258
+ * },
259
+ * // Create a new AI commands group:
260
+ * {
261
+ * groupId: 'transformations',
262
+ * groupLabel: 'Transformations',
263
+ * // You can specify the position of this group among existing ones. Groups use zero-based numbering.
264
+ * order: 3,
265
+ * commands: [
266
+ * {
267
+ * id: 'addEmojis',
268
+ * label: 'Add emojis',
269
+ * prompt: 'Analyze each sentence of this text. After each sentence add an emoji that summarizes the sentence.'
270
+ * },
271
+ * // ...
272
+ * ]
273
+ * },
274
+ * ],
275
+ * // ...
276
+ * }
277
+ * }
278
+ * ```
279
+ */
280
+ extraCommandGroups?: Array<GroupDefinition>;
281
+ /**
282
+ * A list of ids of AI commands to be removed.
283
+ *
284
+ * Learn more about {@link module:ai/aiassistant~CommandDefinition command definition and its id}.
285
+ *
286
+ * An example configuration:
287
+ *
288
+ * ```json
289
+ * {
290
+ * aiAssistant: {
291
+ * removeCommands: [
292
+ * 'improveWriting',
293
+ * // ...
294
+ * ],
295
+ * // ...
296
+ * }
297
+ * }
298
+ * ```
299
+ */
300
+ removeCommands?: Array<string>;
301
+ /**
302
+ * An additional CSS class name (or names) added to the AI assistant content area (model response area).
303
+ *
304
+ * Because the content area is usually detached from the flow of the document, this configuration
305
+ * allows for better integration with application's stylesheets and improves the consistency of content
306
+ * styles.
307
+ */
308
+ contentAreaCssClass?: string;
309
+ /**
310
+ * The AI assistant feature will be disabled if the document selection includes any of these elements.
311
+ *
312
+ * Use this property if AI assistant does not work properly with your custom features.
313
+ *
314
+ * Currently, by default, AI assistant is disabled for following model elements:
315
+ *
316
+ * * Media embed (`'media'`) -- does not display in response area,
317
+ * * HTML embed (`'rawHtml'`) -- sometimes does not display in response area, security uncertainty,
318
+ * * Table of contents (`'tableOfContents'`) -- does not display properly in response area, long processing time.
319
+ *
320
+ * You can set this list to include more model elements or clear it to enable the above features.
321
+ *
322
+ * Note, that all or some of these features may become enabled in the future.
323
+ *
324
+ * @default [ 'media', 'rawHtml', 'tableOfContents' ]
325
+ */
326
+ disabledElements?: Array<string>;
327
+ }
328
+ export type GroupDefinition = {
329
+ /**
330
+ * The unique identifier of the group. It can be referenced while extending existing groups
331
+ * using {@link module:ai/aiassistant~AIAssistantConfig#extraCommandGroups}.
332
+ */
333
+ groupId: string;
334
+ /**
335
+ * The human-readable label of the group.
336
+ */
337
+ groupLabel?: string;
338
+ /**
339
+ * The array of command definitions that belong to the group.
340
+ */
341
+ commands: Array<CommandDefinition>;
342
+ /**
343
+ * The order of the group on the list. The lower the number, the higher the group is displayed on the list.
344
+ * If not specified, the position of this group will be determined by the order of
345
+ * {@link module:ai/aiassistant~AIAssistantConfig#commands configuration}.
346
+ *
347
+ * If a new group is added without `order` property, it will be added at the end.
348
+ *
349
+ * The order uses zero-based numbering (the first group's order is `0`).
350
+ */
351
+ order?: number;
352
+ };
353
+ export type CommandDefinition = {
354
+ /**
355
+ * The unique identifier of the command. It can be referenced while removing commands. See
356
+ * {@link module:ai/aiassistant~AIAssistantConfig#removeCommands} to learn more.
357
+ */
358
+ id: string;
359
+ /**
360
+ * The human-readable label of the command.
361
+ */
362
+ label: string;
363
+ /**
364
+ * The instruction that will be passed to the AI model.
365
+ *
366
+ * It is wrapped in a "full prompt template" for better results.
367
+ */
368
+ prompt: string;
369
+ /**
370
+ * By default, all commands require a selection for the assistant to work on. If the selection is collapsed,
371
+ * it automatically expands to the nearest block boundaries to provide the AI context.
372
+ *
373
+ * Setting this to `false` allows the command to work on a collapsed selection and prevent selection expansion.
374
+ * This is helpful, for instance, for commands that generate content from scratch.
375
+ *
376
+ * **Note**: If not specified, the default is `true`.
377
+ */
378
+ requiresContent?: boolean;
379
+ /**
380
+ * The order of the command on the list. The lower the number, the higher the command is displayed on the list.
381
+ * If not specified, the position of this command will be determined by the order of
382
+ * {@link module:ai/aiassistant~AIAssistantConfig#commands configuration}.
383
+ *
384
+ * If a new command is added without `order` property, it will be added at the end of the group.
385
+ *
386
+ * The order uses zero-based numbering (the first command's order is `0`).
387
+ */
388
+ order?: number;
389
+ };
@@ -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 _0x121b5e=_0x4130;(function(_0x59f3f2,_0x14a3a8){const _0x4845e8=_0x4130,_0x2bd1de=_0x59f3f2();while(!![]){try{const _0xaed4c2=parseInt(_0x4845e8(0xc1))/0x1*(-parseInt(_0x4845e8(0x92))/0x2)+parseInt(_0x4845e8(0x87))/0x3*(parseInt(_0x4845e8(0xae))/0x4)+parseInt(_0x4845e8(0xa5))/0x5+parseInt(_0x4845e8(0x8a))/0x6+parseInt(_0x4845e8(0x7d))/0x7*(-parseInt(_0x4845e8(0xb3))/0x8)+parseInt(_0x4845e8(0xc4))/0x9*(parseInt(_0x4845e8(0xad))/0xa)+parseInt(_0x4845e8(0xb8))/0xb*(-parseInt(_0x4845e8(0x8e))/0xc);if(_0xaed4c2===_0x14a3a8)break;else _0x2bd1de['push'](_0x2bd1de['shift']());}catch(_0x243118){_0x2bd1de['push'](_0x2bd1de['shift']());}}}(_0x3db3,0x8e895));import{Plugin as _0x59f292}from'ckeditor5/src/core.js';import _0x576020 from'./aiassistantui.js';import _0x130b29 from'./aiassistantediting.js';import{getTranslation as _0x1145cc}from'./utils/common-translations.js';function _0x4130(_0x1e1a60,_0x4bdfcc){const _0x3db39f=_0x3db3();return _0x4130=function(_0x4130d5,_0x37ce6c){_0x4130d5=_0x4130d5-0x6a;let _0x20155b=_0x3db39f[_0x4130d5];return _0x20155b;},_0x4130(_0x1e1a60,_0x4bdfcc);}import{normalizeCommandsConfig as _0x3c19a6}from'./utils/normalizecommandsconfig.js';export default class r extends _0x59f292{static get[_0x121b5e(0xd2)](){return[_0x576020,_0x130b29];}static get[_0x121b5e(0x6c)](){const _0x4cf3b5=_0x121b5e;return _0x4cf3b5(0xca);}static get[_0x121b5e(0xbb)](){return!0x0;}static get[_0x121b5e(0x82)](){return!0x0;}constructor(_0x876dfc){const _0x390d63=_0x121b5e;super(_0x876dfc);const _0x3fe712=_0x876dfc[_0x390d63(0x6b)],_0x5a7383=_0x876dfc[_0x390d63(0xd6)];_0x3fe712[_0x390d63(0xab)](_0x390d63(0x73),getDefaultCommands(_0x5a7383)),_0x3fe712[_0x390d63(0xab)](_0x390d63(0xc6),[]),_0x3fe712[_0x390d63(0xab)](_0x390d63(0x9c),[]);const _0x49a7b2=_0x3c19a6(_0x3fe712[_0x390d63(0xaf)](_0x390d63(0x73)),_0x5a7383),_0xb2771b=_0x3fe712[_0x390d63(0xaf)](_0x390d63(0xc6)),_0x3c741d=_0x3fe712[_0x390d63(0xaf)](_0x390d63(0x9c));_0xb2771b[_0x390d63(0xbc)](_0x46c5fd=>{const _0x43dd19=_0x390d63,_0x564492=_0x49a7b2[_0x43dd19(0xd1)](_0xdcb1d9=>_0xdcb1d9[_0x43dd19(0x6f)]===_0x46c5fd[_0x43dd19(0x6f)]);_0x564492?_0x564492[_0x43dd19(0xd9)]=_0x564492[_0x43dd19(0xd9)][_0x43dd19(0xb7)](_0x46c5fd[_0x43dd19(0xd9)]):_0x49a7b2[_0x43dd19(0xb9)](_0x46c5fd);}),_0x49a7b2[_0x390d63(0xbc)](_0x4444cc=>{const _0x207a36=_0x390d63;_0x4444cc[_0x207a36(0xd9)]=_0x4444cc[_0x207a36(0xd9)][_0x207a36(0xa8)](_0xd5c3f5=>!_0x3c741d[_0x207a36(0x86)](_0xd5c3f5['id']));}),_0x3fe712[_0x390d63(0xb6)](_0x390d63(0x73),_0x49a7b2);}}export function getDefaultCommands(_0x2f1229){const _0x22b7b1=_0x121b5e;return[{'groupId':_0x22b7b1(0x72),'groupLabel':_0x1145cc(_0x2f1229,_0x22b7b1(0x90)),'commands':[{'id':_0x22b7b1(0x97),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x93)),'prompt':_0x22b7b1(0xcb)},{'id':_0x22b7b1(0x83),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xcf)),'prompt':_0x22b7b1(0xba)},{'id':_0x22b7b1(0xc3),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xa2)),'prompt':_0x22b7b1(0xb2)},{'id':_0x22b7b1(0x9f),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x6e)),'prompt':_0x22b7b1(0x91)}]},{'groupId':_0x22b7b1(0x80),'groupLabel':_0x1145cc(_0x2f1229,_0x22b7b1(0x9d)),'commands':[{'id':_0x22b7b1(0xb1),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x98)),'prompt':_0x22b7b1(0x76)},{'id':_0x22b7b1(0xd8),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xb0)),'prompt':_0x22b7b1(0x71)}]},{'groupId':_0x22b7b1(0xaa),'groupLabel':_0x1145cc(_0x2f1229,_0x22b7b1(0x94)),'commands':[{'id':_0x22b7b1(0xd0),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xa0)),'prompt':_0x22b7b1(0xc9)},{'id':_0x22b7b1(0x79),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x84)),'prompt':_0x22b7b1(0x99)},{'id':_0x22b7b1(0x70),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x95)),'prompt':_0x22b7b1(0xc8)},{'id':_0x22b7b1(0x75),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xc7)),'prompt':_0x22b7b1(0x7e)},{'id':_0x22b7b1(0x8b),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x7f)),'prompt':_0x22b7b1(0xa6)}]},{'groupId':_0x22b7b1(0xce),'groupLabel':_0x1145cc(_0x2f1229,_0x22b7b1(0x7b)),'commands':[{'id':_0x22b7b1(0xd5),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x96)),'prompt':_0x22b7b1(0x81)},{'id':_0x22b7b1(0xa4),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x85)),'prompt':_0x22b7b1(0xa9)},{'id':_0x22b7b1(0x8c),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xa7)),'prompt':_0x22b7b1(0x8f)},{'id':_0x22b7b1(0x6a),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xbe)),'prompt':_0x22b7b1(0x74)}]},{'groupId':_0x22b7b1(0xd7),'groupLabel':_0x1145cc(_0x2f1229,_0x22b7b1(0xa1)),'commands':[{'id':_0x22b7b1(0xd3),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x9b)),'prompt':_0x22b7b1(0x9a)},{'id':_0x22b7b1(0xcc),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xcd)),'prompt':_0x22b7b1(0xc2)},{'id':_0x22b7b1(0xb4),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xb5)),'prompt':_0x22b7b1(0xac)},{'id':_0x22b7b1(0x78),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x9e)),'prompt':_0x22b7b1(0x7c)},{'id':_0x22b7b1(0x7a),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x8d)),'prompt':_0x22b7b1(0xbd)},{'id':_0x22b7b1(0x88),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xd4)),'prompt':_0x22b7b1(0xc0)},{'id':_0x22b7b1(0xbf),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0xc5)),'prompt':_0x22b7b1(0xa3)},{'id':_0x22b7b1(0x77),'label':_0x1145cc(_0x2f1229,_0x22b7b1(0x89)),'prompt':_0x22b7b1(0x6d)}]}];}function _0x3db3(){const _0xe6d204=['Portuguese','set','concat','22213609oCkyep','push','Remove\x20any\x20repetitive,\x20redundant,\x20or\x20non-essential\x20writing\x20in\x20this\x20content\x20without\x20changing\x20the\x20meaning\x20or\x20losing\x20any\x20key\x20information.','isOfficialPlugin','forEach','Translate\x20the\x20content\x20to\x20French\x20language.','Poetic','translateHindi','Translate\x20the\x20content\x20to\x20Simplified\x20Chinese\x20language.','218ucOJmG','Translate\x20the\x20content\x20to\x20Spanish\x20language.','makeLonger','513APlsNM','Hindi','ai.aiAssistant.extraCommandGroups','Confident','Improve\x20using\x20direct\x20language,\x20using\x20only\x20the\x20essential\x20information.','Improve\x20using\x20polished,\x20formal,\x20and\x20respectful\x20language\x20to\x20convey\x20professional\x20expertise\x20and\x20competence.','AIAssistant','Fix\x20spelling\x20mistakes,\x20use\x20proper\x20grammar\x20and\x20apply\x20good\x20writing\x20practices.\x20Do\x20not\x20lose\x20the\x20original\x20meaning.','translateSpanish','Spanish','changeStyle','Make\x20shorter','professional','find','requires','translateEnglish','Simplified\x20Chinese','business','locale','translate','continue','commands','poetic','config','pluginName','Translate\x20the\x20content\x20to\x20Arabic\x20language.','Simplify\x20language','groupId','direct','Start\x20with\x20the\x20provided\x20content\x20and\x20write\x20at\x20the\x20end\x20of\x20it\x20continuing\x20this\x20topic.\x20Keep\x20the\x20added\x20part\x20short.','editOrReview','ai.aiAssistant.commands','Rewrite\x20this\x20content\x20as\x20a\x20poem\x20using\x20poetic\x20techniques\x20without\x20losing\x20the\x20original\x20meaning.','confident','Summarize\x20this\x20content\x20into\x20one\x20paragraph\x20of\x20text.\x20Include\x20only\x20the\x20key\x20ideas\x20and\x20conclusions.\x20Keep\x20it\x20short.\x20Do\x20not\x20keep\x20original\x20text\x20formatting.','translateArabic','translateGerman','casual','translateFrench','Change\x20style','Translate\x20the\x20content\x20to\x20German\x20language.','7FpbaLD','Improve\x20using\x20compelling,\x20optimistic\x20language\x20to\x20convey\x20confidence\x20in\x20the\x20writing.','Friendly','generate','Rewrite\x20this\x20content\x20as\x20a\x20business\x20professional\x20with\x20formal\x20language.','isPremiumPlugin','makeShorter','Casual','Legal','includes','10581GdxWJk','translateChinese','Arabic','6621480ciTrvV','friendly','journalism','French','12VtmVKd','Rewrite\x20this\x20content\x20as\x20a\x20journalist\x20using\x20engaging\x20language\x20to\x20convey\x20the\x20importance\x20of\x20the\x20information.','Edit\x20or\x20review','Simplify\x20the\x20writing\x20style\x20of\x20this\x20content\x20and\x20reduce\x20the\x20complexity,\x20so\x20that\x20the\x20content\x20is\x20easy\x20to\x20understand.','1492LIrtOV','Improve\x20writing','Change\x20tone','Direct','Business','improveWriting','Summarize','Improve\x20using\x20casual,\x20informal\x20language\x20to\x20convey\x20a\x20casual\x20conversation\x20with\x20a\x20real\x20person.','Translate\x20the\x20content\x20to\x20English\x20language.','English','ai.aiAssistant.removeCommands','Generate\x20from\x20selection','German','simplifyLanguage','Professional','Translate','Make\x20longer','Translate\x20the\x20content\x20to\x20Hindi\x20language.','legal','2801995xSgiCm','Improve\x20using\x20friendly,\x20comforting\x20language,\x20to\x20convey\x20understanding\x20and\x20empathy.','Journalism','filter','Rewrite\x20this\x20content\x20as\x20a\x20legal\x20professional\x20using\x20valid\x20legal\x20terminology.','changeTone','define','Translate\x20the\x20content\x20to\x20Portuguese\x20language.','174170JyJeCg','1164OPvnFU','get','Continue','summarize','Improve\x20this\x20content\x20by\x20using\x20descriptive\x20language\x20and\x20inserting\x20more\x20information\x20and\x20more\x20detailed\x20explanations.','7337832MqnXYm','translatePortuguese'];_0x3db3=function(){return _0xe6d204;};return _0x3db3();}