@ckeditor/ckeditor5-ai 40.0.0 → 40.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/LICENSE.md +2 -2
  2. package/README.md +1 -1
  3. package/build/ai.js +77 -2
  4. package/build/translations/af.js +1 -1
  5. package/build/translations/ar.js +1 -1
  6. package/build/translations/bg.js +1 -1
  7. package/build/translations/bn.js +1 -1
  8. package/build/translations/bs.js +1 -1
  9. package/build/translations/ca.js +1 -1
  10. package/build/translations/cs.js +1 -1
  11. package/build/translations/da.js +1 -1
  12. package/build/translations/de-ch.js +1 -1
  13. package/build/translations/de.js +1 -1
  14. package/build/translations/el.js +1 -1
  15. package/build/translations/en-au.js +1 -1
  16. package/build/translations/es-co.js +1 -1
  17. package/build/translations/es.js +1 -1
  18. package/build/translations/et.js +1 -1
  19. package/build/translations/fa.js +1 -1
  20. package/build/translations/fi.js +1 -1
  21. package/build/translations/fr.js +1 -1
  22. package/build/translations/gl.js +1 -1
  23. package/build/translations/he.js +1 -1
  24. package/build/translations/hi.js +1 -1
  25. package/build/translations/hr.js +1 -1
  26. package/build/translations/hu.js +1 -1
  27. package/build/translations/id.js +1 -1
  28. package/build/translations/it.js +1 -1
  29. package/build/translations/ja.js +1 -1
  30. package/build/translations/jv.js +1 -1
  31. package/build/translations/ko.js +1 -1
  32. package/build/translations/lt.js +1 -1
  33. package/build/translations/lv.js +1 -1
  34. package/build/translations/ms.js +1 -1
  35. package/build/translations/nl.js +1 -1
  36. package/build/translations/no.js +1 -1
  37. package/build/translations/pl.js +1 -1
  38. package/build/translations/pt-br.js +1 -1
  39. package/build/translations/pt.js +1 -1
  40. package/build/translations/ro.js +1 -1
  41. package/build/translations/ru.js +1 -1
  42. package/build/translations/sk.js +1 -1
  43. package/build/translations/sr-latn.js +1 -1
  44. package/build/translations/sr.js +1 -1
  45. package/build/translations/sv.js +1 -1
  46. package/build/translations/th.js +1 -1
  47. package/build/translations/tk.js +1 -1
  48. package/build/translations/tr.js +1 -1
  49. package/build/translations/ug.js +1 -1
  50. package/build/translations/uk.js +1 -1
  51. package/build/translations/ur.js +1 -1
  52. package/build/translations/uz.js +1 -0
  53. package/build/translations/vi.js +1 -1
  54. package/build/translations/zh-cn.js +1 -1
  55. package/build/translations/zh.js +1 -1
  56. package/ckeditor5-metadata.json +1 -1
  57. package/lang/contexts.json +4 -1
  58. package/lang/translations/af.po +60 -16
  59. package/lang/translations/ar.po +60 -16
  60. package/lang/translations/bg.po +60 -16
  61. package/lang/translations/bn.po +60 -16
  62. package/lang/translations/bs.po +60 -16
  63. package/lang/translations/ca.po +60 -16
  64. package/lang/translations/cs.po +60 -16
  65. package/lang/translations/da.po +60 -16
  66. package/lang/translations/de-ch.po +60 -16
  67. package/lang/translations/de.po +60 -16
  68. package/lang/translations/el.po +60 -16
  69. package/lang/translations/en-au.po +60 -16
  70. package/lang/translations/en.po +60 -16
  71. package/lang/translations/es-co.po +60 -16
  72. package/lang/translations/es.po +60 -16
  73. package/lang/translations/et.po +60 -16
  74. package/lang/translations/fa.po +60 -16
  75. package/lang/translations/fi.po +60 -16
  76. package/lang/translations/fr.po +60 -16
  77. package/lang/translations/gl.po +95 -51
  78. package/lang/translations/he.po +60 -16
  79. package/lang/translations/hi.po +60 -16
  80. package/lang/translations/hr.po +93 -49
  81. package/lang/translations/hu.po +60 -16
  82. package/lang/translations/id.po +60 -16
  83. package/lang/translations/it.po +60 -16
  84. package/lang/translations/ja.po +60 -16
  85. package/lang/translations/jv.po +60 -16
  86. package/lang/translations/ko.po +60 -16
  87. package/lang/translations/lt.po +60 -16
  88. package/lang/translations/lv.po +60 -16
  89. package/lang/translations/ms.po +60 -16
  90. package/lang/translations/nl.po +60 -16
  91. package/lang/translations/no.po +60 -16
  92. package/lang/translations/pl.po +60 -16
  93. package/lang/translations/pt-br.po +60 -16
  94. package/lang/translations/pt.po +60 -16
  95. package/lang/translations/ro.po +60 -16
  96. package/lang/translations/ru.po +60 -16
  97. package/lang/translations/sk.po +60 -16
  98. package/lang/translations/sr-latn.po +95 -51
  99. package/lang/translations/sr.po +60 -16
  100. package/lang/translations/sv.po +60 -16
  101. package/lang/translations/th.po +60 -16
  102. package/lang/translations/tk.po +60 -16
  103. package/lang/translations/tr.po +60 -16
  104. package/lang/translations/ug.po +96 -52
  105. package/lang/translations/uk.po +60 -16
  106. package/lang/translations/ur.po +60 -16
  107. package/lang/translations/uz.po +226 -0
  108. package/lang/translations/vi.po +60 -16
  109. package/lang/translations/zh-cn.po +60 -16
  110. package/lang/translations/zh.po +60 -16
  111. package/package.json +4 -3
  112. package/src/adapters/aiadapter.d.ts +48 -0
  113. package/src/adapters/aiadapter.js +23 -0
  114. package/src/adapters/aitextadapter.d.ts +146 -0
  115. package/src/adapters/aitextadapter.js +23 -0
  116. package/src/adapters/awstextadapter.d.ts +178 -0
  117. package/src/adapters/awstextadapter.js +23 -0
  118. package/src/adapters/openaitextadapter.d.ts +181 -0
  119. package/src/adapters/openaitextadapter.js +23 -0
  120. package/src/aiassistant.d.ts +386 -419
  121. package/src/aiassistant.js +1 -1
  122. package/src/aiassistantediting.d.ts +45 -45
  123. package/src/aiassistantediting.js +1 -1
  124. package/src/aiassistantui.d.ts +52 -46
  125. package/src/aiassistantui.js +1 -1
  126. package/src/aiconfig.d.ts +69 -0
  127. package/src/aiconfig.js +23 -0
  128. package/src/augmentation.d.ts +27 -26
  129. package/src/index.d.ts +13 -9
  130. package/src/index.js +1 -1
  131. package/src/ui/aiassistantcontroller.d.ts +109 -59
  132. package/src/ui/aiassistantcontroller.js +1 -1
  133. package/src/ui/dropdown/aicommandslistview.d.ts +22 -22
  134. package/src/ui/dropdown/aicommandslistview.js +1 -1
  135. package/src/ui/dropdown/buttonlabelwithhighlightview.d.ts +29 -29
  136. package/src/ui/dropdown/buttonlabelwithhighlightview.js +1 -1
  137. package/src/ui/dropdown/labelwithhighlightview.d.ts +25 -0
  138. package/src/ui/dropdown/labelwithhighlightview.js +23 -0
  139. package/src/ui/form/aiformcontentarea.d.ts +48 -48
  140. package/src/ui/form/aiformcontentarea.js +1 -1
  141. package/src/ui/form/aiformerrorview.d.ts +26 -26
  142. package/src/ui/form/aiformerrorview.js +1 -1
  143. package/src/ui/form/aiformpromptview.d.ts +46 -46
  144. package/src/ui/form/aiformpromptview.js +1 -1
  145. package/src/ui/form/aiformtoolbarview.d.ts +54 -41
  146. package/src/ui/form/aiformtoolbarview.js +1 -1
  147. package/src/ui/form/aiformview.d.ts +142 -131
  148. package/src/ui/form/aiformview.js +1 -1
  149. package/src/ui/form/aihistorylistitemview.d.ts +18 -18
  150. package/src/ui/form/aihistorylistitemview.js +1 -1
  151. package/src/ui/form/aihistorylistview.d.ts +35 -35
  152. package/src/ui/form/aihistorylistview.js +1 -1
  153. package/src/ui/form/prompthistory.d.ts +20 -20
  154. package/src/ui/form/prompthistory.js +1 -1
  155. package/src/ui/showaiassistantcommand.d.ts +29 -26
  156. package/src/ui/showaiassistantcommand.js +1 -1
  157. package/src/utils/common-translations.d.ts +9 -9
  158. package/src/utils/common-translations.js +1 -1
  159. package/theme/ai-form.css +58 -11
  160. package/theme/ai.css +20 -15
  161. package/src/aiconnector.d.ts +0 -44
  162. package/src/aiconnector.js +0 -23
@@ -1,419 +1,386 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module ai/aiassistant
7
- * @publicApi
8
- */
9
- import { type Locale } from 'ckeditor5/src/utils';
10
- import { Plugin, type Editor } from 'ckeditor5/src/core';
11
- import AIAssistantUI from './aiassistantui';
12
- import AIAssistantEditing from './aiassistantediting';
13
- import AIConnector from './aiconnector';
14
- /**
15
- * A function that returns the list of default AI commands definitions in the given localization context.
16
- */
17
- export declare const getDefaultCommands: (locale: Locale) => Array<GroupDefinition>;
18
- /**
19
- * AI assistant plugin that allows you to use external AI models to generate content or improve existing content.
20
- */
21
- export default class AIAssistant extends Plugin {
22
- /**
23
- * @inheritDoc
24
- */
25
- static get requires(): readonly [typeof AIAssistantUI, typeof AIAssistantEditing, typeof AIConnector];
26
- /**
27
- * @inheritDoc
28
- */
29
- static get pluginName(): "AIAssistant";
30
- /**
31
- * @inheritDoc
32
- */
33
- constructor(editor: Editor);
34
- /**
35
- * @inheritDoc
36
- */
37
- init(): void;
38
- /**
39
- * @inheritDoc
40
- */
41
- destroy(): void;
42
- }
43
- /**
44
- * The configuration of the AI assistant feature.
45
- *
46
- * ```ts
47
- * ClassicEditor
48
- * .create( editorElement, {
49
- * aiAssistant: ... // AI assistant options.
50
- * } )
51
- * .then( ... )
52
- * .catch( ... );
53
- * ```
54
- *
55
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
56
- */
57
- export interface AIAssistantConfig {
58
- /**
59
- * The URL to which the API request will be sent.
60
- *
61
- * Defaults to `'https://api.openai.com/v1/chat/completions'`.
62
- */
63
- apiUrl?: string;
64
- /**
65
- * A key used to authorize the request to the AI service.
66
- *
67
- * If you are connecting directly to the OpenAI API, use your OpenAI API key as `authKey`.
68
- *
69
- * **Important: use your API key ONLY in a development environment or for testing purposes!**
70
- * In the production environment, {@glink features/ai-assistant#using-proxy-endpoint pass your request through a proxy}.
71
- *
72
- * If you are using a proxy service to send requests to the AI service, `authKey` can be used to implement authorization for your
73
- * requests.
74
- *
75
- * If the key is provided, it is added to the `Authorization` header of the request call, using the bearer scheme:
76
- *
77
- * ```
78
- * Authorization: Bearer <authKey>
79
- * ```
80
- *
81
- * If the provided value is a `string`, it is simply used as provided.
82
- *
83
- * If the provided value is a function, it should be a function that returns a `Promise` which resolves with the authorization token.
84
- * This way, you can perform an authorization request to your application and receive the authorization token (and also implement
85
- * any custom logic that you need). The authorization token is then used to make the actual call to the AI service.
86
- *
87
- * ```js
88
- * {
89
- * aiAssistant: {
90
- * authKey: async () => {
91
- * return await fetch( 'https://example.com/jwt-endpoint' );
92
- * }
93
- * // ...
94
- * }
95
- * }
96
- * ```
97
- *
98
- * If the authorization request fails, the promise should be rejected. In this case, the feature will display an error notification.
99
- */
100
- authKey?: string | (() => Promise<string>);
101
- /**
102
- * A list of all AI commands groups definitions to be displayed in the `'aiCommands'` UI dropdown.
103
- *
104
- * Setting this property will overwrite the default list of predefined commands.
105
- *
106
- * The default configuration is as follows:
107
- *
108
- * ```json
109
- * {
110
- * groupId: 'editOrReview',
111
- * groupLabel: 'Edit or review',
112
- * commands: [
113
- * {
114
- * id: 'improveWriting',
115
- * label: 'Improve writing',
116
- * prompt: 'Rewrite this content with no spelling mistakes, proper grammar, ' +
117
- * 'and with more descriptive language, using best writing practices without losing the original meaning.'
118
- * },
119
- * {
120
- * id: 'makeShorter',
121
- * label: 'Make shorter',
122
- * prompt: 'Remove any repetitive, redundant, or non-essential writing in this content ' +
123
- * 'without changing the meaning or losing any key information.'
124
- * },
125
- * {
126
- * id: 'makeLonger',
127
- * label: 'Make longer',
128
- * prompt: 'Expand upon this content with descriptive language and more detailed explanations, ' +
129
- * 'to make the writing easier to understand and increase the length of the content.'
130
- * },
131
- * {
132
- * id: 'simplifyLanguage',
133
- * label: 'Simplify language',
134
- * prompt: 'Rewrite this content with simplified language ' +
135
- * 'and reduce the complexity of the writing, so that the content is easier to understand.'
136
- * }
137
- * ]
138
- * },
139
- * {
140
- * groupId: 'generate',
141
- * groupLabel: 'Generate from selection',
142
- * commands: [
143
- * {
144
- * id: 'summarize',
145
- * label: 'Summarize',
146
- * prompt: 'Provide the key points and concepts in this content in a succinct summary.'
147
- * },
148
- * {
149
- * id: 'continue',
150
- * label: 'Continue',
151
- * prompt: 'Continue this text.'
152
- * }
153
- * ]
154
- * },
155
- * {
156
- * groupId: 'changeTone',
157
- * groupLabel: 'Change tone',
158
- * commands: [
159
- * {
160
- * id: 'professional',
161
- * label: 'Professional',
162
- * prompt: 'Rewrite this content using polished, formal, and respectful language ' +
163
- * 'to convey professional expertise and competence.'
164
- * },
165
- * {
166
- * id: 'casual',
167
- * label: 'Casual',
168
- * prompt: 'Rewrite this content with casual, informal language to convey a casual conversation with a real person.'
169
- * },
170
- * {
171
- * id: 'direct',
172
- * label: 'Direct',
173
- * prompt: 'Rewrite this content with direct language using only the essential information.'
174
- * },
175
- * {
176
- * id: 'confident',
177
- * label: 'Confident',
178
- * prompt: 'Rewrite this content using compelling, optimistic language to convey confidence in the writing.'
179
- * },
180
- * {
181
- * id: 'friendly',
182
- * label: 'Friendly',
183
- * prompt: 'Rewrite this content using friendly, comforting language, to convey understanding and empathy.'
184
- * }
185
- * ]
186
- * },
187
- * {
188
- * groupId: 'changeStyle',
189
- * groupLabel: 'Change style',
190
- * commands: [
191
- * {
192
- * id: 'business',
193
- * label: 'Business',
194
- * prompt: 'Rewrite this content as a business professional with formal language.'
195
- * },
196
- * {
197
- * id: 'legal',
198
- * label: 'Legal',
199
- * prompt: 'Rewrite this content as a legal professional using valid legal terminology.'
200
- * },
201
- * {
202
- * id: 'journalism',
203
- * label: 'Journalism',
204
- * prompt: 'Rewrite this content as a journalist using engaging language to convey the importance of the information.'
205
- * },
206
- * {
207
- * id: 'poetic',
208
- * label: 'Poetic',
209
- * prompt: 'Rewrite this content as a poem using poetic techniques without losing the original meaning.'
210
- * }
211
- * ]
212
- * },
213
- * {
214
- * groupId: 'translate',
215
- * groupLabel: 'Translate',
216
- * commands: [
217
- * {
218
- * id: 'translateEnglish',
219
- * label: 'Translate to English',
220
- * prompt: 'Translate to English language.'
221
- * },
222
- * {
223
- * id: 'translateSpanish',
224
- * label: 'Translate to Spanish',
225
- * prompt: 'Translate to Spanish language.'
226
- * },
227
- * {
228
- * id: 'translatePortuguese',
229
- * label: 'Translate to Portuguese',
230
- * prompt: 'Translate to Portuguese language.'
231
- * },
232
- * {
233
- * id: 'translateGerman',
234
- * label: 'Translate to German',
235
- * prompt: 'Translate to German language.'
236
- * },
237
- * {
238
- * id: 'translateFrench',
239
- * label: 'Translate to French',
240
- * prompt: 'Translate to French language.'
241
- * },
242
- * {
243
- * id: 'translateChinese',
244
- * label: 'Translate to Simplified Chinese',
245
- * prompt: 'Translate to Simplified Chinese language.'
246
- * },
247
- * {
248
- * id: 'translateHindi',
249
- * label: 'Translate to Hindi',
250
- * prompt: 'Translate to Hindi language.'
251
- * },
252
- * {
253
- * id: 'translateArabic',
254
- * label: 'Translate to Arabic',
255
- * prompt: 'Translate to Arabic language.'
256
- * }
257
- * ]
258
- * }
259
- * ```
260
- */
261
- commands?: Array<GroupDefinition>;
262
- /**
263
- * A list of additional AI commands groups definitions that will extend
264
- * {@link module:ai/aiassistant~AIAssistantConfig#commands default commands}.
265
- *
266
- * You can define new AI commands groups or add new AI commands to existing groups. If you add AI commands to an existing group,
267
- * you do not need to specify `groupLabel` property.
268
- *
269
- * An example configuration:
270
- *
271
- * ```json
272
- * {
273
- * aiAssistant: {
274
- * extraCommandGroups: [
275
- * // Add an AI command to an existing group:
276
- * {
277
- * groupId: 'changeTone',
278
- * commands: [
279
- * {
280
- * id: 'sad',
281
- * label: 'Sad',
282
- * prompt: 'Rewrite this text to make it sound sad and depressing.'
283
- * }
284
- * ]
285
- * },
286
- * // Create a new AI commands group:
287
- * {
288
- * groupId: 'transformations',
289
- * groupLabel: 'Transformations',
290
- * commands: [
291
- * {
292
- * id: 'addEmojis',
293
- * label: 'Add emojis',
294
- * prompt: 'Analyze each sentence of this text. After each sentence add an emoji that summarizes the sentence.'
295
- * },
296
- * // ...
297
- * ]
298
- * },
299
- * ],
300
- * // ...
301
- * }
302
- * ```
303
- */
304
- extraCommandGroups?: Array<GroupDefinition>;
305
- /**
306
- * A list of ids of AI commands to be removed.
307
- *
308
- * Learn more about {@link module:ai/aiassistant~CommandDefinition command definition and its id}.
309
- *
310
- * An example configuration:
311
- *
312
- * ```json
313
- * {
314
- * aiAssistant: {
315
- * removeCommands: [
316
- * 'improveWriting',
317
- * // ...
318
- * ],
319
- * // ...
320
- * }
321
- * ```
322
- */
323
- removeCommands?: Array<string>;
324
- /**
325
- * Defines a CSS class name added to the AI assistant UI that allows for CSS customization.
326
- *
327
- * Setting this property to `false` disables the CSS class.
328
- *
329
- * @default 'ck-ai-assistant-ui'
330
- */
331
- uiCssClass?: string | false;
332
- /**
333
- * An additional CSS class name (or names) added to the AI assistant content area (model response area).
334
- *
335
- * Because the content area is usually detached from the flow of the document, this configuration
336
- * allows for better integration with application's stylesheets and improves the consistency of content
337
- * styles.
338
- */
339
- contentAreaCssClass?: string;
340
- /**
341
- * Additional configuration parameters for the AI request. Use it to customize how the AI service generates responses.
342
- *
343
- * See [OpenAI API reference](https://platform.openai.com/docs/api-reference/chat/create) to learn more.
344
- *
345
- * Defaults to:
346
- *
347
- * ```json
348
- * {
349
- * model: 'gpt-3.5-turbo',
350
- * max_tokens: 2000,
351
- * temperature: 1,
352
- * top_p: 1
353
- * }
354
- * ```
355
- */
356
- requestParameters?: RequestParameters;
357
- /**
358
- * The AI assistant feature will be disabled if the document selection includes any of these elements.
359
- *
360
- * Use this property if AI assistant does not work properly with your custom features.
361
- *
362
- * Currently, by default, AI assistant is disabled for following model elements:
363
- *
364
- * * Media embed (`'media'`) -- does not display in response area,
365
- * * HTML embed (`'rawHtml'`) -- sometimes does not display in response area, security uncertainty,
366
- * * Table of contents (`'tableOfContents'`) -- does not display properly in response area, long processing time.
367
- *
368
- * You can set this list to include more model elements or clear it to enable the above features.
369
- *
370
- * Note, that all or some of these features may become enabled in the future.
371
- *
372
- * @default [ 'media', 'rawHtml', 'tableOfContents' ]
373
- */
374
- disabledElements?: Array<string>;
375
- }
376
- export type GroupDefinition = {
377
- /**
378
- * The unique identifier of the group. It can be referenced while extending existing groups
379
- * using {@link module:ai/aiassistant~AIAssistantConfig#extraCommandGroups}.
380
- */
381
- groupId: string;
382
- /**
383
- * The human-readable label of the group.
384
- */
385
- groupLabel?: string;
386
- /**
387
- * The array of command definitions that belong to the group.
388
- */
389
- commands: Array<CommandDefinition>;
390
- };
391
- export type CommandDefinition = {
392
- /**
393
- * The unique identifier of the command. It can be referenced while removing commands. See
394
- * {@link module:ai/aiassistant~AIAssistantConfig#removeCommands} to learn more.
395
- */
396
- id: string;
397
- /**
398
- * The human-readable label of the command.
399
- */
400
- label: string;
401
- /**
402
- * The instruction that will be passed to the AI model.
403
- *
404
- * It is wrapped in a "full prompt template" for better results.
405
- */
406
- prompt: string;
407
- };
408
- /**
409
- * OpenAI request parameters that will influence how the response is generated.
410
- *
411
- * See OpenAI API reference to learn more.
412
- */
413
- export type RequestParameters = {
414
- model?: string;
415
- max_tokens?: number;
416
- temperature?: number;
417
- top_p?: number;
418
- user?: string;
419
- };
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module ai/aiassistant
7
+ * @publicApi
8
+ */
9
+ import { type Locale } from 'ckeditor5/src/utils';
10
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
11
+ import AIAssistantUI from './aiassistantui';
12
+ import AIAssistantEditing from './aiassistantediting';
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
+ constructor(editor: Editor);
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ init(): void;
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ destroy(): void;
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
+ * The default configuration is as follows. It can be obtained through {@link ~getDefaultCommands}:
76
+ *
77
+ * ```json
78
+ * [ {
79
+ * groupId: 'editOrReview',
80
+ * groupLabel: 'Edit or review',
81
+ * commands: [
82
+ * {
83
+ * id: 'improveWriting',
84
+ * label: 'Improve writing',
85
+ * prompt: 'Fix spelling mistakes, use proper grammar and apply good writing practices. Do not lose the original meaning.'
86
+ * },
87
+ * {
88
+ * id: 'makeShorter',
89
+ * label: 'Make shorter',
90
+ * prompt: 'Remove any repetitive, redundant, or non-essential writing in this content ' +
91
+ * 'without changing the meaning or losing any key information.'
92
+ * },
93
+ * {
94
+ * id: 'makeLonger',
95
+ * label: 'Make longer',
96
+ * prompt: 'Improve this content by using descriptive language and inserting more information and more detailed explanations.'
97
+ * },
98
+ * {
99
+ * id: 'simplifyLanguage',
100
+ * label: 'Simplify language',
101
+ * prompt: 'Simplify the writing style of this content ' +
102
+ * 'and reduce the complexity, so that the content is easy to understand.'
103
+ * }
104
+ * ]
105
+ * },
106
+ * {
107
+ * groupId: 'generate',
108
+ * groupLabel: 'Generate from selection',
109
+ * commands: [
110
+ * {
111
+ * id: 'summarize',
112
+ * label: 'Summarize',
113
+ * prompt: 'Summarize this content into one paragraph of text. Include only the key ideas and conclusions. Keep it short. '
114
+ * },
115
+ * {
116
+ * id: 'continue',
117
+ * label: 'Continue',
118
+ * prompt: 'Start with the provided content and write at the end of it continuing this topic. Keep the added part short.'
119
+ * }
120
+ * ]
121
+ * },
122
+ * {
123
+ * groupId: 'changeTone',
124
+ * groupLabel: 'Change tone',
125
+ * commands: [
126
+ * {
127
+ * id: 'professional',
128
+ * label: 'Professional',
129
+ * prompt: 'Improve using polished, formal, and respectful language ' +
130
+ * 'to convey professional expertise and competence.'
131
+ * },
132
+ * {
133
+ * id: 'casual',
134
+ * label: 'Casual',
135
+ * prompt: 'Improve using casual, informal language to convey a casual conversation with a real person.'
136
+ * },
137
+ * {
138
+ * id: 'direct',
139
+ * label: 'Direct',
140
+ * prompt: 'Improve using direct language using only the essential information.'
141
+ * },
142
+ * {
143
+ * id: 'confident',
144
+ * label: 'Confident',
145
+ * prompt: 'Improve using compelling, optimistic language to convey confidence in the writing.'
146
+ * },
147
+ * {
148
+ * id: 'friendly',
149
+ * label: 'Friendly',
150
+ * prompt: 'Improve using friendly, comforting language, to convey understanding and empathy.'
151
+ * }
152
+ * ]
153
+ * },
154
+ * {
155
+ * groupId: 'changeStyle',
156
+ * groupLabel: 'Change style',
157
+ * commands: [
158
+ * {
159
+ * id: 'business',
160
+ * label: 'Business',
161
+ * prompt: 'Rewrite this content as a business professional with formal language.'
162
+ * },
163
+ * {
164
+ * id: 'legal',
165
+ * label: 'Legal',
166
+ * prompt: 'Rewrite this content as a legal professional using valid legal terminology.'
167
+ * },
168
+ * {
169
+ * id: 'journalism',
170
+ * label: 'Journalism',
171
+ * prompt: 'Rewrite this content as a journalist using engaging language to convey the importance of the information.'
172
+ * },
173
+ * {
174
+ * id: 'poetic',
175
+ * label: 'Poetic',
176
+ * prompt: 'Rewrite this content as a poem using poetic techniques without losing the original meaning.'
177
+ * }
178
+ * ]
179
+ * },
180
+ * {
181
+ * groupId: 'translate',
182
+ * groupLabel: 'Translate',
183
+ * commands: [
184
+ * {
185
+ * id: 'translateEnglish',
186
+ * label: 'Translate to English',
187
+ * prompt: 'Translate the content to English language.'
188
+ * },
189
+ * {
190
+ * id: 'translateSpanish',
191
+ * label: 'Translate to Spanish',
192
+ * prompt: 'Translate the content to Spanish language.'
193
+ * },
194
+ * {
195
+ * id: 'translatePortuguese',
196
+ * label: 'Translate to Portuguese',
197
+ * prompt: 'Translate the content to Portuguese language.'
198
+ * },
199
+ * {
200
+ * id: 'translateGerman',
201
+ * label: 'Translate to German',
202
+ * prompt: 'Translate the content to German language.'
203
+ * },
204
+ * {
205
+ * id: 'translateFrench',
206
+ * label: 'Translate to French',
207
+ * prompt: 'Translate the content to French language.'
208
+ * },
209
+ * {
210
+ * id: 'translateChinese',
211
+ * label: 'Translate to Simplified Chinese',
212
+ * prompt: 'Translate the content to Simplified Chinese language.'
213
+ * },
214
+ * {
215
+ * id: 'translateHindi',
216
+ * label: 'Translate to Hindi',
217
+ * prompt: 'Translate the content to Hindi language.'
218
+ * },
219
+ * {
220
+ * id: 'translateArabic',
221
+ * label: 'Translate to Arabic',
222
+ * prompt: 'Translate the content to Arabic language.'
223
+ * }
224
+ * ]
225
+ * } ]
226
+ * ```
227
+ */
228
+ commands?: Array<GroupDefinition>;
229
+ /**
230
+ * A list of additional AI commands groups definitions that will extend
231
+ * {@link module:ai/aiassistant~AIAssistantConfig#commands default commands}.
232
+ *
233
+ * You can define new AI commands groups or add new AI commands to existing groups. If you add AI commands to an existing group,
234
+ * you do not need to specify `groupLabel` property. Use the (optional) `order` property to control the position of new groups
235
+ * and commands.
236
+ *
237
+ * An example configuration:
238
+ *
239
+ * ```json
240
+ * {
241
+ * aiAssistant: {
242
+ * extraCommandGroups: [
243
+ * // Add an AI command to an existing group:
244
+ * {
245
+ * groupId: 'changeTone',
246
+ * commands: [
247
+ * {
248
+ * id: 'sad',
249
+ * label: 'Sad',
250
+ * prompt: 'Rewrite this text to make it sound sad and depressing.',
251
+ * // You can specify the position of this command among existing ones. Commands use zero-based numbering.
252
+ * order: 2
253
+ * }
254
+ * ]
255
+ * },
256
+ * // Create a new AI commands group:
257
+ * {
258
+ * groupId: 'transformations',
259
+ * groupLabel: 'Transformations',
260
+ * // You can specify the position of this group among existing ones. Groups use zero-based numbering.
261
+ * order: 3,
262
+ * commands: [
263
+ * {
264
+ * id: 'addEmojis',
265
+ * label: 'Add emojis',
266
+ * prompt: 'Analyze each sentence of this text. After each sentence add an emoji that summarizes the sentence.'
267
+ * },
268
+ * // ...
269
+ * ]
270
+ * },
271
+ * ],
272
+ * // ...
273
+ * }
274
+ * }
275
+ * ```
276
+ */
277
+ extraCommandGroups?: Array<GroupDefinition>;
278
+ /**
279
+ * A list of ids of AI commands to be removed.
280
+ *
281
+ * Learn more about {@link module:ai/aiassistant~CommandDefinition command definition and its id}.
282
+ *
283
+ * An example configuration:
284
+ *
285
+ * ```json
286
+ * {
287
+ * aiAssistant: {
288
+ * removeCommands: [
289
+ * 'improveWriting',
290
+ * // ...
291
+ * ],
292
+ * // ...
293
+ * }
294
+ * }
295
+ * ```
296
+ */
297
+ removeCommands?: Array<string>;
298
+ /**
299
+ * An additional CSS class name (or names) added to the AI assistant content area (model response area).
300
+ *
301
+ * Because the content area is usually detached from the flow of the document, this configuration
302
+ * allows for better integration with application's stylesheets and improves the consistency of content
303
+ * styles.
304
+ */
305
+ contentAreaCssClass?: string;
306
+ /**
307
+ * The AI assistant feature will be disabled if the document selection includes any of these elements.
308
+ *
309
+ * Use this property if AI assistant does not work properly with your custom features.
310
+ *
311
+ * Currently, by default, AI assistant is disabled for following model elements:
312
+ *
313
+ * * Media embed (`'media'`) -- does not display in response area,
314
+ * * HTML embed (`'rawHtml'`) -- sometimes does not display in response area, security uncertainty,
315
+ * * Table of contents (`'tableOfContents'`) -- does not display properly in response area, long processing time.
316
+ *
317
+ * You can set this list to include more model elements or clear it to enable the above features.
318
+ *
319
+ * Note, that all or some of these features may become enabled in the future.
320
+ *
321
+ * @default [ 'media', 'rawHtml', 'tableOfContents' ]
322
+ */
323
+ disabledElements?: Array<string>;
324
+ }
325
+ export type GroupDefinition = {
326
+ /**
327
+ * The unique identifier of the group. It can be referenced while extending existing groups
328
+ * using {@link module:ai/aiassistant~AIAssistantConfig#extraCommandGroups}.
329
+ */
330
+ groupId: string;
331
+ /**
332
+ * The human-readable label of the group.
333
+ */
334
+ groupLabel?: string;
335
+ /**
336
+ * The array of command definitions that belong to the group.
337
+ */
338
+ commands: Array<CommandDefinition>;
339
+ /**
340
+ * The order of the group on the list. The lower the number, the higher the group is displayed on the list.
341
+ * If not specified, the position of this group will be determined by the order of
342
+ * {@link module:ai/aiassistant~AIAssistantConfig#commands configuration}.
343
+ *
344
+ * If a new group is added without `order` property, it will be added at the end.
345
+ *
346
+ * The order uses zero-based numbering (the first group's order is `0`).
347
+ */
348
+ order?: number;
349
+ };
350
+ export type CommandDefinition = {
351
+ /**
352
+ * The unique identifier of the command. It can be referenced while removing commands. See
353
+ * {@link module:ai/aiassistant~AIAssistantConfig#removeCommands} to learn more.
354
+ */
355
+ id: string;
356
+ /**
357
+ * The human-readable label of the command.
358
+ */
359
+ label: string;
360
+ /**
361
+ * The instruction that will be passed to the AI model.
362
+ *
363
+ * It is wrapped in a "full prompt template" for better results.
364
+ */
365
+ prompt: string;
366
+ /**
367
+ * By default, all commands require a selection for the assistant to work on. If the selection is collapsed,
368
+ * it automatically expands to the nearest block boundaries to provide the AI context.
369
+ *
370
+ * Setting this to `false` allows the command to work on a collapsed selection and prevent selection expansion.
371
+ * This is helpful, for instance, for commands that generate content from scratch.
372
+ *
373
+ * **Note**: If not specified, the default is `true`.
374
+ */
375
+ requiresContent?: boolean;
376
+ /**
377
+ * The order of the command on the list. The lower the number, the higher the command is displayed on the list.
378
+ * If not specified, the position of this command will be determined by the order of
379
+ * {@link module:ai/aiassistant~AIAssistantConfig#commands configuration}.
380
+ *
381
+ * If a new command is added without `order` property, it will be added at the end of the group.
382
+ *
383
+ * The order uses zero-based numbering (the first command's order is `0`).
384
+ */
385
+ order?: number;
386
+ };