@imgly/plugin-ai-text-generation-web 0.1.10 → 0.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 (34) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +207 -28
  3. package/dist/anthropic/AnthropicProvider.d.ts +7 -3
  4. package/dist/anthropic/index.mjs +10 -197
  5. package/dist/anthropic/index.mjs.map +4 -4
  6. package/dist/anthropic/sendPrompt.d.ts +1 -1
  7. package/dist/constants.d.ts +5 -0
  8. package/dist/index.d.ts +4 -1
  9. package/dist/index.mjs +196 -7
  10. package/dist/index.mjs.map +4 -4
  11. package/dist/open-ai/OpenAIProvider.d.ts +21 -0
  12. package/dist/open-ai/index.d.ts +5 -0
  13. package/dist/open-ai/index.mjs +20 -0
  14. package/dist/open-ai/index.mjs.map +7 -0
  15. package/dist/open-ai/sendPrompt.d.ts +15 -0
  16. package/dist/plugin.d.ts +4 -3
  17. package/dist/quickActions/ChangeTextTo.d.ts +29 -0
  18. package/dist/quickActions/ChangeTone.d.ts +29 -0
  19. package/dist/quickActions/Fix.d.ts +28 -0
  20. package/dist/quickActions/Improve.d.ts +28 -0
  21. package/dist/quickActions/Longer.d.ts +28 -0
  22. package/dist/quickActions/Shorter.d.ts +28 -0
  23. package/dist/quickActions/Translate.d.ts +29 -0
  24. package/dist/quickActions/types.d.ts +6 -0
  25. package/dist/types.d.ts +50 -10
  26. package/package.json +8 -3
  27. /package/dist/{anthropic/prompts → prompts}/changeTextTo.d.ts +0 -0
  28. /package/dist/{anthropic/prompts → prompts}/changeTone.d.ts +0 -0
  29. /package/dist/{anthropic/prompts → prompts}/fix.d.ts +0 -0
  30. /package/dist/{anthropic/prompts → prompts}/generateTextForSpeech.d.ts +0 -0
  31. /package/dist/{anthropic/prompts → prompts}/improve.d.ts +0 -0
  32. /package/dist/{anthropic/prompts → prompts}/longer.d.ts +0 -0
  33. /package/dist/{anthropic/prompts → prompts}/shorter.d.ts +0 -0
  34. /package/dist/{anthropic/prompts → prompts}/translate.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.0] - 2025-07-15
6
+
7
+ ### Breaking Changes
8
+
9
+ - [all] **Provider Initialization**: `initProvider` is replaced with `initializeProviders` and `initializeProvider` with a different signature
10
+ - [all] **Quick Actions Structure**: `provider.input.quickctions.actions` replaced with `provider.input.quickActions.supported`
11
+ - [all] **History Asset Sources**: Combined history asset source is now not added to the default asset libraries anymore. Add the following sources to any library entry (default or not):
12
+ - Image Generation History: `ly.img.ai.image-generation.history`
13
+ - Video Generation History: `ly.img.ai.video-generation.history`
14
+ - Audio Generation History: `ly.img.ai.audio-generation.history`
15
+ - Sticker Generation History: `ly.img.ai.sticker-generation.history`
16
+ - [all] **ID Format Standardization**: All `ly.img.ai/` prefixed IDs changed to use dot notation `ly.img.ai.` for consistency
17
+ - Panel IDs: `ly.img.ai/apps` → `ly.img.ai.apps`, `ly.img.ai/image-generation` → `ly.img.ai.image-generation`
18
+ - Dock IDs: `ly.img.ai/apps.dock` → `ly.img.ai.apps.dock`
19
+
20
+ ### New Features
21
+
22
+ - [all] **Multiple Providers Support**: All plugin packages now support arrays of providers with automatic selection UI
23
+ - [image-generation] **Recraft20b Provider**: Added new Recraft20b (v2) provider via fal.ai with support for icon styles including `broken_line`, `colored_outline`, `colored_shapes`, and more
24
+ - [sticker-generation] **New Sticker Generation Plugin**: Added `@imgly/plugin-ai-sticker-generation-web` plugin for AI-powered sticker generation with support for text-to-sticker generation using Recraft20b provider with icon styles
25
+ - [image-generation] **Flux Pro Kontext Provider**: Added Flux Pro Kontext provider for image editing with style transfer and artist style options
26
+ - [image-generation] **Flux Pro Kontext Max Provider**: Added Flux Pro Kontext Max provider for enhanced image editing capabilities
27
+ - [video-generation] **Veo3 Provider**: Added Veo3 text-to-video provider via fal.ai with support for 16:9, 9:16, and 1:1 aspect ratios and 8-second duration
28
+ - [video-generation] **Kling Video V2.1 Master Providers**: Added Kling Video V2.1 Master providers for both text-to-video and image-to-video generation with configurable duration (5s/10s) and aspect ratios
29
+ - [text-generation] **Model Selection**: OpenAI and Anthropic providers now support configurable model selection through the `model` parameter
30
+
31
+ ### Deprecated Features
32
+
33
+ - [all] **Middleware Configuration**: The `middleware` property in provider configurations is deprecated. Use `middlewares` instead. The old property will continue to work for now.
34
+
5
35
  ## [0.1.10] - 2025-06-20
6
36
 
7
37
  - [all] Fix issue with GPT provider when using text provider
package/README.md CHANGED
@@ -29,7 +29,9 @@ npm install @imgly/plugin-ai-text-generation-web
29
29
 
30
30
  ### Basic Configuration
31
31
 
32
- To use the plugin, import it and configure it with your preferred provider:
32
+ To use the plugin, import it and configure it with your preferred provider(s):
33
+
34
+ #### Single Provider
33
35
 
34
36
  ```typescript
35
37
  import CreativeEditorSDK from '@cesdk/cesdk-js';
@@ -45,7 +47,12 @@ CreativeEditorSDK.create(domElement, {
45
47
  cesdk.addPlugin(
46
48
  TextGeneration({
47
49
  provider: Anthropic.AnthropicProvider({
48
- proxyUrl: 'https://your-anthropic-proxy.example.com'
50
+ proxyUrl: 'http://your-proxy-server.com/api/proxy',
51
+ model: 'claude-3-7-sonnet-20250219', // Optional model selection (this is also the default)
52
+ headers: {
53
+ 'x-custom-header': 'value',
54
+ 'x-client-version': '1.0.0'
55
+ }
49
56
  }),
50
57
 
51
58
  // Optional configuration
@@ -61,9 +68,58 @@ CreativeEditorSDK.create(domElement, {
61
68
  });
62
69
  ```
63
70
 
71
+ #### Multiple Providers
72
+
73
+ You can configure multiple providers, and users will see a selection box to choose between them:
74
+
75
+ ```typescript
76
+ import CreativeEditorSDK from '@cesdk/cesdk-js';
77
+ import TextGeneration from '@imgly/plugin-ai-text-generation-web';
78
+ import Anthropic from '@imgly/plugin-ai-text-generation-web/anthropic';
79
+
80
+ // Initialize CreativeEditor SDK
81
+ CreativeEditorSDK.create(domElement, {
82
+ license: 'your-license-key'
83
+ // Other configuration options...
84
+ }).then(async (cesdk) => {
85
+ // Add the text generation plugin with multiple providers
86
+ cesdk.addPlugin(
87
+ TextGeneration({
88
+ provider: [
89
+ Anthropic.AnthropicProvider({
90
+ proxyUrl: 'http://your-proxy-server.com/api/proxy',
91
+ model: 'claude-3-7-sonnet-20250219', // Optional model selection (this is also the default)
92
+ headers: {
93
+ 'x-custom-header': 'value',
94
+ 'x-client-version': '1.0.0'
95
+ }
96
+ }),
97
+ // Add more providers here as they become available
98
+ // OtherProvider.SomeModel({
99
+ // proxyUrl: 'http://your-proxy-server.com/api/proxy',
100
+ // headers: {
101
+ // 'x-api-key': 'your-key',
102
+ // 'x-source': 'cesdk'
103
+ // }
104
+ // })
105
+ ],
106
+
107
+ // Optional configuration
108
+ debug: false
109
+ })
110
+ );
111
+
112
+ // Set canvas menu order to display AI text actions
113
+ cesdk.ui.setCanvasMenuOrder([
114
+ 'ly.img.ai.text.canvasMenu',
115
+ ...cesdk.ui.getCanvasMenuOrder()
116
+ ]);
117
+ });
118
+ ```
119
+
64
120
  ### Providers
65
121
 
66
- The plugin currently includes the following provider:
122
+ The plugin currently includes the following providers:
67
123
 
68
124
  #### Anthropic Claude
69
125
 
@@ -71,28 +127,79 @@ A versatile text generation model that handles various text transformations:
71
127
 
72
128
  ```typescript
73
129
  provider: Anthropic.AnthropicProvider({
74
- proxyUrl: 'https://your-anthropic-proxy.example.com',
130
+ proxyUrl: 'http://your-proxy-server.com/api/proxy',
131
+
132
+ // Optional model selection (this is also the default)
133
+ model: 'claude-3-7-sonnet-20250219',
134
+
135
+ // Optional custom headers for API requests
136
+ headers: {
137
+ 'x-custom-header': 'value',
138
+ 'x-client-version': '1.0.0',
139
+ 'x-request-source': 'cesdk-plugin'
140
+ },
141
+
75
142
  // Optional debug mode
76
143
  debug: false
77
144
  });
78
145
  ```
79
146
 
147
+ **Default Model**: If no model is specified, the provider uses `'claude-3-7-sonnet-20250219'` by default.
148
+
80
149
  Key features:
81
150
 
82
151
  - High-quality text transformations
83
152
  - Multiple transformation types
84
153
  - Supports various languages
85
154
  - Natural, human-like outputs
155
+ - Custom headers support for API requests
156
+ - Configurable model selection (Claude 3.5 Sonnet, Claude 3.7 Sonnet, etc.)
157
+ - Default model: Claude 3.7 Sonnet (2025-02-19)
158
+
159
+ #### OpenAI GPT
160
+
161
+ A powerful text generation model that handles various text transformations:
162
+
163
+ ```typescript
164
+ provider: OpenAIText.OpenAIProvider({
165
+ proxyUrl: 'http://your-proxy-server.com/api/proxy',
166
+
167
+ // Optional model selection (this is also the default)
168
+ model: 'gpt-4o-mini',
169
+
170
+ // Optional custom headers for API requests
171
+ headers: {
172
+ 'x-custom-header': 'value',
173
+ 'x-client-version': '1.0.0',
174
+ 'x-request-source': 'cesdk-plugin'
175
+ },
176
+
177
+ // Optional debug mode
178
+ debug: false
179
+ });
180
+ ```
181
+
182
+ **Default Model**: If no model is specified, the provider uses `'gpt-4o-mini'` by default.
183
+
184
+ Key features:
185
+
186
+ - High-quality text transformations
187
+ - Multiple transformation types
188
+ - Supports various languages
189
+ - Natural, human-like outputs
190
+ - Custom headers support for API requests
191
+ - Configurable model selection (GPT-4o, GPT-4o-mini, GPT-3.5-turbo, etc.)
192
+ - Default model: GPT-4o-mini
86
193
 
87
194
  ### Configuration Options
88
195
 
89
196
  The plugin accepts the following configuration options:
90
197
 
91
- | Option | Type | Description | Default |
92
- | ------------ | ---------- | ----------------------------------------------- | -------- |
93
- | `provider` | Provider | Provider for text generation and transformation | required |
94
- | `debug` | boolean | Enable debug logging | false |
95
- | `middleware` | Function[] | Array of middleware functions for the generation| undefined|
198
+ | Option | Type | Description | Default |
199
+ | ------------ | -------------------- | ----------------------------------------------- | -------- |
200
+ | `provider` | Provider \| Provider[] | Provider(s) for text generation and transformation. When multiple providers are provided, users can select between them | required |
201
+ | `debug` | boolean | Enable debug logging | false |
202
+ | `middleware` | Function[] | Array of middleware functions for the generation| undefined|
96
203
 
97
204
  ### Middleware Configuration
98
205
 
@@ -101,6 +208,7 @@ The `middleware` option allows you to add pre-processing and post-processing cap
101
208
  ```typescript
102
209
  import TextGeneration from '@imgly/plugin-ai-text-generation-web';
103
210
  import Anthropic from '@imgly/plugin-ai-text-generation-web/anthropic';
211
+ import OpenAIText from '@imgly/plugin-ai-text-generation-web/open-ai';
104
212
  import { loggingMiddleware, rateLimitMiddleware } from '@imgly/plugin-ai-generation-web';
105
213
 
106
214
  // Create middleware functions
@@ -137,7 +245,7 @@ const customMiddleware = async (input, options, next) => {
137
245
  cesdk.addPlugin(
138
246
  TextGeneration({
139
247
  provider: Anthropic.AnthropicProvider({
140
- proxyUrl: 'https://your-anthropic-proxy.example.com'
248
+ proxyUrl: 'http://your-proxy-server.com/api/proxy'
141
249
  }),
142
250
  middleware: [logging, rateLimit, customMiddleware] // Apply middleware in order
143
251
  })
@@ -157,7 +265,11 @@ For security reasons, you must use a proxy server to handle API requests to Anth
157
265
 
158
266
  ```typescript
159
267
  provider: Anthropic.AnthropicProvider({
160
- proxyUrl: 'https://your-anthropic-proxy.example.com'
268
+ proxyUrl: 'http://your-proxy-server.com/api/proxy',
269
+ headers: {
270
+ 'x-custom-header': 'value',
271
+ 'x-client-version': '1.0.0'
272
+ }
161
273
  });
162
274
  ```
163
275
 
@@ -165,10 +277,16 @@ Your proxy server should:
165
277
 
166
278
  1. Receive requests from the client
167
279
  2. Add the necessary authentication (API key) to the requests
168
- 3. Forward requests to the Anthropic API
280
+ 3. Forward requests to the AI provider API (Anthropic, OpenAI, etc.)
169
281
  4. Return responses to the client
170
282
 
171
- Never expose your Anthropic API key in client-side code.
283
+ The `headers` option allows you to include custom HTTP headers in all API requests. This is useful for:
284
+ - Adding custom client identification headers
285
+ - Including version information
286
+ - Passing through metadata required by your API
287
+ - Adding correlation IDs for request tracing
288
+
289
+ Never expose your API keys in client-side code.
172
290
 
173
291
  ## API Reference
174
292
 
@@ -184,10 +302,10 @@ Creates and returns a plugin that can be added to CreativeEditor SDK.
184
302
 
185
303
  ```typescript
186
304
  interface PluginConfiguration {
187
- // Provider for text generation and transformation
305
+ // Provider(s) for text generation and transformation
188
306
  provider: (context: {
189
307
  cesdk: CreativeEditorSDK;
190
- }) => Promise<Provider<'text', any, any>>;
308
+ }) => Promise<Provider<'text', any, any> | Provider<'text', any, any>[]>;
191
309
 
192
310
  // Enable debug logging
193
311
  debug?: boolean;
@@ -199,6 +317,19 @@ interface PluginConfiguration {
199
317
  ```typescript
200
318
  Anthropic.AnthropicProvider(config: {
201
319
  proxyUrl: string;
320
+ model?: string;
321
+ headers?: Record<string, string>;
322
+ debug?: boolean;
323
+ })
324
+ ```
325
+
326
+ ### OpenAI Provider Configuration
327
+
328
+ ```typescript
329
+ OpenAIText.OpenAIProvider(config: {
330
+ proxyUrl: string;
331
+ model?: string;
332
+ headers?: Record<string, string>;
202
333
  debug?: boolean;
203
334
  })
204
335
  ```
@@ -211,16 +342,64 @@ The plugin automatically registers the following UI components:
211
342
 
212
343
  ### Canvas Menu Integration
213
344
 
214
- The plugin adds a "Magic Menu" to the canvas context menu for text blocks with the following transformation options:
345
+ The plugin automatically registers quick actions for text transformation. Here are the available quick actions:
346
+
347
+ #### Available Quick Actions
348
+
349
+ - **`ly.img.improve`**: Improve writing quality
350
+ - Input: `{ prompt: string }`
351
+
352
+ - **`ly.img.fix`**: Fix spelling and grammar
353
+ - Input: `{ prompt: string }`
354
+
355
+ - **`ly.img.shorter`**: Make text shorter
356
+ - Input: `{ prompt: string }`
357
+
358
+ - **`ly.img.longer`**: Make text longer
359
+ - Input: `{ prompt: string }`
215
360
 
216
- - **Improve Writing**: Enhance the quality and clarity of text
217
- - **Fix Spelling & Grammar**: Correct language errors in text
218
- - **Make Shorter**: Create a more concise version of the text
219
- - **Make Longer**: Expand text with additional details
220
- - **Generate Speech Text**: Format text for speech or presentations
221
- - **Change Tone**: Modify the tone of text to professional, casual, friendly, serious, humorous, or optimistic
222
- - **Translate**: Translate text to various languages
223
- - **Change Text to...**: Completely rewrite text based on a custom prompt
361
+ - **`ly.img.changeTone`**: Change the tone of the text
362
+ - Input: `{ prompt: string, type: string }`
363
+
364
+ - **`ly.img.translate`**: Translate text to different languages
365
+ - Input: `{ prompt: string, language: string }`
366
+
367
+ - **`ly.img.changeTextTo`**: Change text to a different format or style
368
+ - Input: `{ prompt: string, customPrompt: string }`
369
+
370
+ #### Provider Quick Action Support
371
+
372
+ Providers declare which quick actions they support through their configuration:
373
+
374
+ ```typescript
375
+ const myTextProvider = {
376
+ // ... other provider config
377
+ input: {
378
+ // ... panel config
379
+ quickActions: {
380
+ supported: {
381
+ 'ly.img.improve': {
382
+ mapInput: (quickActionInput) => ({
383
+ prompt: quickActionInput.prompt
384
+ })
385
+ },
386
+ 'ly.img.fix': {
387
+ mapInput: (quickActionInput) => ({
388
+ prompt: quickActionInput.prompt
389
+ })
390
+ },
391
+ 'ly.img.changeTone': {
392
+ mapInput: (quickActionInput) => ({
393
+ prompt: quickActionInput.prompt,
394
+ tone: quickActionInput.type
395
+ })
396
+ }
397
+ // Add more supported quick actions as needed
398
+ }
399
+ }
400
+ }
401
+ };
402
+ ```
224
403
 
225
404
  To add the AI text menu to your canvas menu, use:
226
405
 
@@ -233,10 +412,10 @@ cesdk.ui.setCanvasMenuOrder([
233
412
 
234
413
  ## Related Packages
235
414
 
236
- - [@imgly/plugin-ai-generation-web](https://github.com/imgly/plugin-ai-generation-web) - Core utilities for AI generation
237
- - [@imgly/plugin-ai-image-generation-web](https://github.com/imgly/plugin-ai-image-generation-web) - AI image generation
238
- - [@imgly/plugin-ai-video-generation-web](https://github.com/imgly/plugin-ai-video-generation-web) - AI video generation
239
- - [@imgly/plugin-ai-audio-generation-web](https://github.com/imgly/plugin-ai-audio-generation-web) - AI audio generation
415
+ - [@imgly/plugin-ai-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-generation-web) - Core utilities for AI generation
416
+ - [@imgly/plugin-ai-image-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-image-generation-web) - AI image generation
417
+ - [@imgly/plugin-ai-video-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-video-generation-web) - AI video generation
418
+ - [@imgly/plugin-ai-audio-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-audio-generation-web) - AI audio generation
240
419
 
241
420
  ## License
242
421
 
@@ -1,5 +1,6 @@
1
1
  import CreativeEditorSDK from '@cesdk/cesdk-js';
2
- import { Provider, type CommonProviderConfiguration } from '@imgly/plugin-ai-generation-web';
2
+ import { type CommonProviderConfiguration } from '@imgly/plugin-ai-generation-web';
3
+ import { TextProvider } from '../types';
3
4
  type AnthropicInput = {
4
5
  prompt: string;
5
6
  temperature?: number;
@@ -11,7 +12,10 @@ type AnthropicOutput = {
11
12
  kind: 'text';
12
13
  text: string;
13
14
  };
14
- export declare function AnthropicProvider(config: CommonProviderConfiguration<AnthropicInput, AnthropicOutput>): (context: {
15
+ export interface AnthropicProviderConfig extends CommonProviderConfiguration<AnthropicInput, AnthropicOutput> {
16
+ model?: string;
17
+ }
18
+ export declare function AnthropicProvider(config: AnthropicProviderConfig): (context: {
15
19
  cesdk: CreativeEditorSDK;
16
- }) => Promise<Provider<'text', AnthropicInput, AnthropicOutput>>;
20
+ }) => Promise<TextProvider<AnthropicInput>>;
17
21
  export {};