@ai-stack/payloadcms 3.2.21-beta → 3.2.23-beta

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 (37) hide show
  1. package/README.md +186 -160
  2. package/dist/ai/models/anthropic/index.js.map +1 -1
  3. package/dist/ai/models/elevenLabs/index.js.map +1 -1
  4. package/dist/ai/models/google/generateImage.d.ts +9 -0
  5. package/dist/ai/models/google/generateImage.js +27 -0
  6. package/dist/ai/models/google/generateImage.js.map +1 -0
  7. package/dist/ai/models/google/index.d.ts +2 -0
  8. package/dist/ai/models/google/index.js +201 -0
  9. package/dist/ai/models/google/index.js.map +1 -0
  10. package/dist/ai/models/index.js +2 -0
  11. package/dist/ai/models/index.js.map +1 -1
  12. package/dist/ai/models/openai/index.js.map +1 -1
  13. package/dist/ai/schemas/lexicalJsonSchema.js.map +1 -1
  14. package/dist/ai/utils/editImagesWithOpenAI.js.map +1 -1
  15. package/dist/ai/utils/filterEditorSchemaByNodes.js +2 -1
  16. package/dist/ai/utils/filterEditorSchemaByNodes.js.map +1 -1
  17. package/dist/ai/utils/generateFileNameByPrompt.js.map +1 -1
  18. package/dist/defaults.js.map +1 -1
  19. package/dist/endpoints/index.js.map +1 -1
  20. package/dist/fields/ComposeField/ComposeField.js.map +1 -1
  21. package/dist/init.js.map +1 -1
  22. package/dist/libraries/handlebars/helpers.js.map +1 -1
  23. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  24. package/dist/providers/InstructionsProvider/useInstructions.js.map +1 -1
  25. package/dist/ui/Compose/Compose.js.map +1 -1
  26. package/dist/ui/Compose/UndoRedoActions.js.map +1 -1
  27. package/dist/ui/Compose/hooks/menu/TranslateMenu.js +1 -2
  28. package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -1
  29. package/dist/ui/Compose/hooks/menu/TranslateMenu.jsx +1 -1
  30. package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
  31. package/dist/ui/Compose/hooks/useActiveFieldTracking.js +98 -21
  32. package/dist/ui/Compose/hooks/useActiveFieldTracking.js.map +1 -1
  33. package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
  34. package/dist/ui/Compose/hooks/useHistory.js.map +1 -1
  35. package/dist/utilities/fieldToJsonSchema.js.map +1 -1
  36. package/dist/utilities/updateFieldsConfig.js.map +1 -1
  37. package/package.json +74 -38
@@ -0,0 +1,201 @@
1
+ import { google } from '@ai-sdk/google';
2
+ import { defaultSystemPrompt } from '../../prompts.js';
3
+ import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js';
4
+ import { generateObject } from '../generateObject.js';
5
+ import { generateImage } from './generateImage.js';
6
+ const MODEL_KEY = 'GEMINI';
7
+ const MODELS = [
8
+ 'gemini-3-pro-preview',
9
+ 'gemini-2.5-pro',
10
+ 'gemini-2.5-flash',
11
+ 'gemini-2.5-flash-lite',
12
+ 'gemini-2.0-flash',
13
+ 'gemini-2.0-flash-lite',
14
+ 'gemini-flash-latest'
15
+ ];
16
+ const IMAGEN_MODELS = [
17
+ 'imagen-4.0-fast-generate-001',
18
+ 'imagen-4.0-generate-001',
19
+ 'imagen-4.0-ultra-generate-001',
20
+ 'imagen-3.0-generate-002'
21
+ ];
22
+ export const GoogleConfig = {
23
+ models: [
24
+ {
25
+ id: `${MODEL_KEY}-text`,
26
+ name: 'Google Gemini',
27
+ fields: [
28
+ 'text',
29
+ 'textarea'
30
+ ],
31
+ handler: (prompt, options)=>{
32
+ return generateObject(prompt, {
33
+ ...options,
34
+ system: options.system || defaultSystemPrompt
35
+ }, google(options.model));
36
+ },
37
+ output: 'text',
38
+ settings: {
39
+ name: `${MODEL_KEY}-text-settings`,
40
+ type: 'group',
41
+ admin: {
42
+ condition (data) {
43
+ return data['model-id'] === `${MODEL_KEY}-text`;
44
+ }
45
+ },
46
+ fields: [
47
+ {
48
+ name: 'model',
49
+ type: 'select',
50
+ defaultValue: 'gemini-flash-latest',
51
+ label: 'Model',
52
+ options: MODELS
53
+ },
54
+ {
55
+ type: 'row',
56
+ fields: [
57
+ {
58
+ name: 'maxTokens',
59
+ type: 'number',
60
+ defaultValue: 5000
61
+ },
62
+ {
63
+ name: 'temperature',
64
+ type: 'number',
65
+ defaultValue: 0.7,
66
+ max: 1,
67
+ min: 0
68
+ }
69
+ ]
70
+ },
71
+ {
72
+ name: 'extractAttachments',
73
+ type: 'checkbox'
74
+ }
75
+ ],
76
+ label: 'Google Gemini Settings'
77
+ }
78
+ },
79
+ {
80
+ id: `${MODEL_KEY}-object`,
81
+ name: 'Google Gemini',
82
+ fields: [
83
+ 'richText'
84
+ ],
85
+ handler: (text, options)=>{
86
+ return generateObject(text, {
87
+ ...options,
88
+ system: options.system || defaultSystemPrompt
89
+ }, google(options.model));
90
+ },
91
+ output: 'text',
92
+ settings: {
93
+ name: `${MODEL_KEY}-object-settings`,
94
+ type: 'group',
95
+ admin: {
96
+ condition (data) {
97
+ return data['model-id'] === `${MODEL_KEY}-object`;
98
+ }
99
+ },
100
+ fields: [
101
+ {
102
+ name: 'model',
103
+ type: 'select',
104
+ defaultValue: 'gemini-flash-latest',
105
+ label: 'Model',
106
+ options: MODELS
107
+ },
108
+ {
109
+ type: 'row',
110
+ fields: [
111
+ {
112
+ name: 'maxTokens',
113
+ type: 'number',
114
+ defaultValue: 5000
115
+ },
116
+ {
117
+ name: 'temperature',
118
+ type: 'number',
119
+ defaultValue: 0.7,
120
+ max: 1,
121
+ min: 0
122
+ }
123
+ ]
124
+ },
125
+ {
126
+ name: 'extractAttachments',
127
+ type: 'checkbox'
128
+ }
129
+ ],
130
+ label: 'Google Gemini Settings'
131
+ }
132
+ },
133
+ {
134
+ id: 'imagen',
135
+ name: 'Google Imagen',
136
+ fields: [
137
+ 'upload'
138
+ ],
139
+ handler: async (prompt, options)=>{
140
+ const imageData = await generateImage(prompt, options);
141
+ return {
142
+ data: {
143
+ alt: imageData.alt
144
+ },
145
+ file: {
146
+ name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.png`,
147
+ data: imageData.buffer,
148
+ mimetype: 'image/png',
149
+ size: imageData.buffer.byteLength
150
+ }
151
+ };
152
+ },
153
+ output: 'image',
154
+ settings: {
155
+ name: 'imagen-settings',
156
+ type: 'group',
157
+ admin: {
158
+ condition (data) {
159
+ return data['model-id'] === 'imagen';
160
+ }
161
+ },
162
+ fields: [
163
+ {
164
+ name: 'model',
165
+ type: 'select',
166
+ defaultValue: 'imagen-4.0-fast-generate-001',
167
+ label: 'Model',
168
+ options: IMAGEN_MODELS
169
+ },
170
+ {
171
+ name: 'aspectRatio',
172
+ type: 'select',
173
+ defaultValue: '1:1',
174
+ label: 'Aspect Ratio',
175
+ options: [
176
+ '1:1',
177
+ '3:4',
178
+ '4:3',
179
+ '9:16',
180
+ '16:9'
181
+ ]
182
+ },
183
+ {
184
+ name: 'outputMimeType',
185
+ type: 'select',
186
+ defaultValue: 'image/png',
187
+ label: 'Output Format',
188
+ options: [
189
+ 'image/png',
190
+ 'image/jpeg'
191
+ ]
192
+ }
193
+ ],
194
+ label: 'Google Imagen Settings'
195
+ }
196
+ }
197
+ ],
198
+ provider: 'Google'
199
+ };
200
+
201
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/ai/models/google/index.ts"],"sourcesContent":["import type { File } from 'payload'\nimport { google } from '@ai-sdk/google'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { defaultSystemPrompt } from '../../prompts.js'\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateObject } from '../generateObject.js'\nimport { generateImage } from './generateImage.js'\n\nconst MODEL_KEY = 'GEMINI'\nconst MODELS = [\n 'gemini-3-pro-preview',\n 'gemini-2.5-pro',\n 'gemini-2.5-flash',\n 'gemini-2.5-flash-lite',\n 'gemini-2.0-flash',\n 'gemini-2.0-flash-lite',\n 'gemini-flash-latest',\n]\n\nconst IMAGEN_MODELS = [\n 'imagen-4.0-fast-generate-001',\n 'imagen-4.0-generate-001',\n 'imagen-4.0-ultra-generate-001',\n 'imagen-3.0-generate-002',\n]\n\nexport const GoogleConfig: GenerationConfig = {\n models: [\n {\n id: `${MODEL_KEY}-text`,\n name: 'Google Gemini',\n fields: ['text', 'textarea'],\n handler: (\n prompt: string,\n options: {\n extractAttachments?: boolean\n locale?: string\n maxTokens?: number\n model: string\n schema?: Record<string, any>\n system?: string\n temperature?: number\n },\n ) => {\n return generateObject(\n prompt,\n {\n ...options,\n system: options.system || defaultSystemPrompt,\n },\n google(options.model),\n )\n },\n output: 'text',\n settings: {\n name: `${MODEL_KEY}-text-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-text`\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gemini-flash-latest',\n label: 'Model',\n options: MODELS,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'maxTokens',\n type: 'number',\n defaultValue: 5000,\n },\n {\n name: 'temperature',\n type: 'number',\n defaultValue: 0.7,\n max: 1,\n min: 0,\n },\n ],\n },\n {\n name: 'extractAttachments',\n type: 'checkbox',\n },\n ],\n label: 'Google Gemini Settings',\n },\n },\n {\n id: `${MODEL_KEY}-object`,\n name: 'Google Gemini',\n fields: ['richText'],\n handler: (text: string, options) => {\n return generateObject(\n text,\n {\n ...options,\n system: options.system || defaultSystemPrompt,\n },\n google(options.model),\n )\n },\n output: 'text',\n settings: {\n name: `${MODEL_KEY}-object-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-object`\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gemini-flash-latest',\n label: 'Model',\n options: MODELS,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'maxTokens',\n type: 'number',\n defaultValue: 5000,\n },\n {\n name: 'temperature',\n type: 'number',\n defaultValue: 0.7,\n max: 1,\n min: 0,\n },\n ],\n },\n {\n name: 'extractAttachments',\n type: 'checkbox',\n },\n ],\n label: 'Google Gemini Settings',\n },\n },\n {\n id: 'imagen',\n name: 'Google Imagen',\n fields: ['upload'],\n handler: async (prompt: string, options) => {\n const imageData = await generateImage(prompt, options)\n return {\n data: {\n alt: imageData.alt,\n },\n file: {\n name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.png`,\n data: imageData.buffer,\n mimetype: 'image/png',\n size: imageData.buffer.byteLength,\n } as File,\n }\n },\n output: 'image',\n settings: {\n name: 'imagen-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'imagen'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'imagen-4.0-fast-generate-001',\n label: 'Model',\n options: IMAGEN_MODELS,\n },\n {\n name: 'aspectRatio',\n type: 'select',\n defaultValue: '1:1',\n label: 'Aspect Ratio',\n options: ['1:1', '3:4', '4:3', '9:16', '16:9'],\n },\n {\n name: 'outputMimeType',\n type: 'select',\n defaultValue: 'image/png',\n label: 'Output Format',\n options: ['image/png', 'image/jpeg'],\n },\n ],\n label: 'Google Imagen Settings',\n },\n },\n ],\n provider: 'Google',\n}\n"],"names":["google","defaultSystemPrompt","generateFileNameByPrompt","generateObject","generateImage","MODEL_KEY","MODELS","IMAGEN_MODELS","GoogleConfig","models","id","name","fields","handler","prompt","options","system","model","output","settings","type","admin","condition","data","defaultValue","label","max","min","text","imageData","alt","file","buffer","mimetype","size","byteLength","provider"],"mappings":"AACA,SAASA,MAAM,QAAQ,iBAAgB;AAIvC,SAASC,mBAAmB,QAAQ,mBAAkB;AACtD,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,aAAa,QAAQ,qBAAoB;AAElD,MAAMC,YAAY;AAClB,MAAMC,SAAS;IACb;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,gBAAgB;IACpB;IACA;IACA;IACA;CACD;AAED,OAAO,MAAMC,eAAiC;IAC5CC,QAAQ;QACN;YACEC,IAAI,C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1
1
  import * as process from 'node:process';
2
2
  import { AnthropicConfig } from './anthropic/index.js';
3
3
  import { ElevenLabsConfig } from './elevenLabs/index.js';
4
+ import { GoogleConfig } from './google/index.js';
4
5
  import { OpenAIConfig } from './openai/index.js';
5
6
  export const defaultGenerationModels = [
6
7
  ...process.env.OPENAI_API_KEY ? OpenAIConfig.models : [],
7
8
  ...process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : [],
9
+ ...process.env.GOOGLE_GENERATIVE_AI_API_KEY ? GoogleConfig.models : [],
8
10
  ...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []
9
11
  ];
10
12
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/models/index.ts"],"sourcesContent":["import * as process from 'node:process'\n\nimport type { GenerationModel } from '../../types.js'\n\nimport { AnthropicConfig } from './anthropic/index.js'\nimport { ElevenLabsConfig } from './elevenLabs/index.js'\nimport { OpenAIConfig } from './openai/index.js'\n\nexport const defaultGenerationModels: GenerationModel[] = [\n ...(process.env.OPENAI_API_KEY ? OpenAIConfig.models : []),\n ...(process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : []),\n ...(process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []),\n]\n"],"names":["process","AnthropicConfig","ElevenLabsConfig","OpenAIConfig","defaultGenerationModels","env","OPENAI_API_KEY","models","ANTHROPIC_API_KEY","ELEVENLABS_API_KEY"],"mappings":"AAAA,YAAYA,aAAa,eAAc;AAIvC,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,MAAMC,0BAA6C;OACpDJ,QAAQK,GAAG,CAACC,cAAc,GAAGH,aAAaI,MAAM,GAAG,EAAE;OACrDP,QAAQK,GAAG,CAACG,iBAAiB,GAAGP,gBAAgBM,MAAM,GAAG,EAAE;OAC3DP,QAAQK,GAAG,CAACI,kBAAkB,GAAGP,iBAAiBK,MAAM,GAAG,EAAE;CAClE,CAAA"}
1
+ {"version":3,"sources":["../../../src/ai/models/index.ts"],"sourcesContent":["import * as process from 'node:process'\n\nimport type { GenerationModel } from '../../types.js'\n\nimport { AnthropicConfig } from './anthropic/index.js'\nimport { ElevenLabsConfig } from './elevenLabs/index.js'\nimport { GoogleConfig } from './google/index.js'\nimport { OpenAIConfig } from './openai/index.js'\n\nexport const defaultGenerationModels: GenerationModel[] = [\n ...(process.env.OPENAI_API_KEY ? OpenAIConfig.models : []),\n ...(process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : []),\n ...(process.env.GOOGLE_GENERATIVE_AI_API_KEY ? GoogleConfig.models : []),\n ...(process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []),\n]\n"],"names":["process","AnthropicConfig","ElevenLabsConfig","GoogleConfig","OpenAIConfig","defaultGenerationModels","env","OPENAI_API_KEY","models","ANTHROPIC_API_KEY","GOOGLE_GENERATIVE_AI_API_KEY","ELEVENLABS_API_KEY"],"mappings":"AAAA,YAAYA,aAAa,eAAc;AAIvC,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,MAAMC,0BAA6C;OACpDL,QAAQM,GAAG,CAACC,cAAc,GAAGH,aAAaI,MAAM,GAAG,EAAE;OACrDR,QAAQM,GAAG,CAACG,iBAAiB,GAAGR,gBAAgBO,MAAM,GAAG,EAAE;OAC3DR,QAAQM,GAAG,CAACI,4BAA4B,GAAGP,aAAaK,MAAM,GAAG,EAAE;OACnER,QAAQM,GAAG,CAACK,kBAAkB,GAAGT,iBAAiBM,MAAM,GAAG,EAAE;CAClE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ai/models/openai/index.ts"],"sourcesContent":["import type { SpeechCreateParams } from 'openai/resources/audio/speech'\nimport type { File } from 'payload'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { defaultSystemPrompt } from '../../prompts.js'\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateObject } from '../generateObject.js'\nimport { generateImage } from './generateImage.js'\nimport { generateVoice } from './generateVoice.js'\nimport { openai } from './openai.js'\n\nconst MODEL_KEY = 'Oai'\nconst MODELS = [\n 'gpt-5',\n 'gpt-5-mini',\n 'gpt-5-nano',\n 'gpt-4.1',\n 'gpt-4o',\n 'gpt-4-turbo',\n 'gpt-4o-mini',\n 'gpt-3.5-turbo',\n]\n\n//TODO: Simplify this file by moving the handlers to separate files and remove duplicate code\nexport const OpenAIConfig: GenerationConfig = {\n models: [\n {\n id: `${MODEL_KEY}-text`,\n name: 'OpenAI GPT Text',\n fields: ['text', 'textarea'],\n handler: (\n prompt: string,\n options: {\n extractAttachments?: boolean\n locale?: string\n maxTokens?: number\n model: string\n schema?: Record<string, any>\n system?: string\n temperature?: number\n },\n ) => {\n return generateObject(\n prompt,\n {\n ...options,\n providerOptions: {\n openai: {\n strictJsonSchema: true,\n structuredOutputs: true,\n },\n },\n system: options.system || defaultSystemPrompt,\n },\n openai(options.model),\n )\n },\n output: 'text',\n settings: {\n name: `${MODEL_KEY}-text-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-text`\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gpt-4o-mini',\n label: 'Model',\n options: MODELS,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'maxTokens',\n type: 'number',\n defaultValue: 5000,\n },\n {\n name: 'temperature',\n type: 'number',\n defaultValue: 0.7,\n max: 1,\n min: 0,\n },\n ],\n },\n {\n name: 'extractAttachments',\n type: 'checkbox',\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n {\n id: 'dall-e',\n name: 'OpenAI DALL-E',\n fields: ['upload'],\n handler: async (prompt: string, options) => {\n const imageData = await generateImage(prompt, options)\n return {\n data: {\n alt: imageData.alt,\n },\n file: {\n name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.jpeg`,\n data: imageData.buffer,\n mimetype: 'image/jpeg',\n size: imageData.buffer.byteLength,\n } as File,\n }\n },\n output: 'image',\n settings: {\n name: 'dalle-e-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'dall-e'\n },\n },\n fields: [\n {\n name: 'version',\n type: 'select',\n defaultValue: 'dall-e-3',\n label: 'Version',\n options: ['dall-e-3', 'dall-e-2'],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'size',\n type: 'select',\n defaultValue: '1024x1024',\n label: 'Size',\n options: ['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792'],\n },\n {\n name: 'style',\n type: 'select',\n defaultValue: 'natural',\n label: 'Style',\n options: ['vivid', 'natural'],\n },\n ],\n },\n {\n name: 'enable-prompt-optimization',\n type: 'checkbox',\n label: 'Optimize prompt',\n },\n ],\n label: 'OpenAI DALL-E Settings',\n },\n },\n {\n id: 'gpt-image-1',\n name: 'OpenAI GPT Image 1',\n fields: ['upload'],\n handler: async (prompt: string, options) => {\n const imageData = await generateImage(prompt, options)\n return {\n data: {\n alt: imageData.alt,\n },\n file: {\n name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.png`,\n data: imageData.buffer,\n mimetype: 'image/png',\n size: imageData.buffer.byteLength,\n } as File,\n }\n },\n output: 'image',\n settings: {\n name: 'gpt-image-1-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'gpt-image-1'\n },\n },\n fields: [\n {\n name: 'version',\n type: 'select',\n defaultValue: 'gpt-image-1',\n label: 'Version',\n options: ['gpt-image-1'],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'size',\n type: 'select',\n defaultValue: 'auto',\n label: 'Size',\n options: ['1024x1024', '1024x1536', '1536x1024', 'auto'],\n },\n {\n name: 'quality',\n type: 'select',\n defaultValue: 'auto',\n label: 'Quality',\n options: ['low', 'medium', 'high', 'auto'],\n },\n ],\n },\n {\n name: 'output_format',\n type: 'select',\n defaultValue: 'png',\n label: 'Output Format',\n options: ['png', 'jpeg', 'webp'],\n },\n {\n name: 'output_compression',\n type: 'number',\n admin: {\n condition(data) {\n return data.output_format === 'jpeg' || data.output_format === 'webp'\n },\n },\n defaultValue: 100,\n label: 'Output Compression',\n max: 100,\n min: 0,\n },\n {\n name: 'background',\n type: 'select',\n admin: {\n condition(data) {\n return data.output_format === 'png' || data.output_format === 'webp'\n },\n },\n defaultValue: 'white',\n label: 'Background',\n options: ['white', 'transparent'],\n },\n {\n name: 'moderation',\n type: 'select',\n defaultValue: 'auto',\n label: 'Moderation',\n options: ['auto', 'low'],\n },\n ],\n label: 'OpenAI GPT Image 1 Settings',\n },\n },\n {\n id: 'tts',\n name: 'OpenAI Text-to-Speech',\n fields: ['upload'],\n handler: async (text: string, options) => {\n //TODO: change it to open ai text to speech api\n const voiceData = await generateVoice(text, options)\n if (!voiceData || !voiceData.buffer) {\n throw new Error('Voice data missing')\n }\n return {\n data: {\n alt: text,\n },\n file: {\n name: `voice_${generateFileNameByPrompt(text)}.mp3`,\n data: voiceData.buffer,\n mimetype: 'audio/mp3',\n size: voiceData.buffer.byteLength,\n } as File,\n }\n },\n output: 'audio',\n settings: {\n name: `${MODEL_KEY}-tts-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'tts'\n },\n },\n fields: [\n {\n name: 'voice',\n type: 'select',\n defaultValue: 'alloy',\n label: 'Voice',\n options: ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'] as Array<\n SpeechCreateParams['voice']\n >,\n },\n {\n name: 'model',\n type: 'select',\n defaultValue: 'tts-1',\n label: 'Model',\n options: ['tts-1', 'tts-1-hd'] as Array<SpeechCreateParams['model']>,\n },\n {\n name: 'response_format',\n type: 'select',\n defaultValue: 'mp3',\n label: 'Response Format',\n options: ['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'],\n },\n {\n name: 'speed',\n type: 'number',\n defaultValue: 1,\n label: 'Speed',\n max: 4,\n min: 0.25,\n },\n ],\n label: 'OpenAI Text-to-Speech Settings',\n },\n },\n {\n id: `${MODEL_KEY}-object`,\n name: 'OpenAI GPT',\n fields: ['richText'],\n handler: (text: string, options) => {\n return generateObject(\n text,\n {\n ...options,\n providerOptions: {\n openai: {\n strictJsonSchema: true,\n structuredOutputs: true,\n },\n },\n system: options.system || defaultSystemPrompt,\n },\n openai(options.model),\n )\n },\n output: 'text',\n settings: {\n name: `${MODEL_KEY}-object-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-object`\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gpt-4o',\n label: 'Model',\n options: MODELS,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'maxTokens',\n type: 'number',\n defaultValue: 5000,\n },\n {\n name: 'temperature',\n type: 'number',\n defaultValue: 0.7,\n max: 1,\n min: 0,\n },\n ],\n },\n {\n name: 'extractAttachments',\n type: 'checkbox',\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["defaultSystemPrompt","generateFileNameByPrompt","generateObject","generateImage","generateVoice","openai","MODEL_KEY","MODELS","OpenAIConfig","models","id","name","fields","handler","prompt","options","providerOptions","strictJsonSchema","structuredOutputs","system","model","output","settings","type","admin","condition","data","defaultValue","label","max","min","imageData","alt","file","buffer","mimetype","size","byteLength","output_format","text","voiceData","Error","provider"],"mappings":"AAKA,SAASA,mBAAmB,QAAQ,mBAAkB;AACtD,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AAEpC,MAAMC,YAAY;AAClB,MAAMC,SAAS;IACb;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,6FAA6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UAAU;gBACRX,MAAM,GAAGL,UAAU,gBAAgB,CAAC;gBACpCiB,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK,GAAGpB,UAAU,OAAO,CAAC;oBACnD;gBACF;gBACAM,QAAQ;oBACN;wBACED,MAAM;wBACNY,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPb,SAASR;oBACX;oBACA;wBACEgB,MAAM;wBACNX,QAAQ;4BACN;gCACED,MAAM;gCACNY,MAAM;gCACNI,cAAc;4BAChB;4BACA;gCACEhB,MAAM;gCACNY,MAAM;gCACNI,cAAc;gCACdE,KAAK;gCACLC,KAAK;4BACP;yBACD;oBACH;oBACA;wBACEnB,MAAM;wBACNY,MAAM;oBACR;iBACD;gBACDK,OAAO;YACT;QACF;KACD;IACDc,UAAU;AACZ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/ai/models/openai/index.ts"],"sourcesContent":["import type { SpeechCreateParams } from 'openai/resources/audio/speech'\nimport type { File } from 'payload'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { defaultSystemPrompt } from '../../prompts.js'\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateObject } from '../generateObject.js'\nimport { generateImage } from './generateImage.js'\nimport { generateVoice } from './generateVoice.js'\nimport { openai } from './openai.js'\n\nconst MODEL_KEY = 'Oai'\nconst MODELS = [\n 'gpt-5',\n 'gpt-5-mini',\n 'gpt-5-nano',\n 'gpt-4.1',\n 'gpt-4o',\n 'gpt-4-turbo',\n 'gpt-4o-mini',\n 'gpt-3.5-turbo',\n]\n\n//TODO: Simplify this file by moving the handlers to separate files and remove duplicate code\nexport const OpenAIConfig: GenerationConfig = {\n models: [\n {\n id: `${MODEL_KEY}-text`,\n name: 'OpenAI GPT Text',\n fields: ['text', 'textarea'],\n handler: (\n prompt: string,\n options: {\n extractAttachments?: boolean\n locale?: string\n maxTokens?: number\n model: string\n schema?: Record<string, any>\n system?: string\n temperature?: number\n },\n ) => {\n return generateObject(\n prompt,\n {\n ...options,\n providerOptions: {\n openai: {\n strictJsonSchema: true,\n structuredOutputs: true,\n },\n },\n system: options.system || defaultSystemPrompt,\n },\n openai(options.model),\n )\n },\n output: 'text',\n settings: {\n name: `${MODEL_KEY}-text-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-text`\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gpt-4o-mini',\n label: 'Model',\n options: MODELS,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'maxTokens',\n type: 'number',\n defaultValue: 5000,\n },\n {\n name: 'temperature',\n type: 'number',\n defaultValue: 0.7,\n max: 1,\n min: 0,\n },\n ],\n },\n {\n name: 'extractAttachments',\n type: 'checkbox',\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n {\n id: 'dall-e',\n name: 'OpenAI DALL-E',\n fields: ['upload'],\n handler: async (prompt: string, options) => {\n const imageData = await generateImage(prompt, options)\n return {\n data: {\n alt: imageData.alt,\n },\n file: {\n name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.jpeg`,\n data: imageData.buffer,\n mimetype: 'image/jpeg',\n size: imageData.buffer.byteLength,\n } as File,\n }\n },\n output: 'image',\n settings: {\n name: 'dalle-e-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'dall-e'\n },\n },\n fields: [\n {\n name: 'version',\n type: 'select',\n defaultValue: 'dall-e-3',\n label: 'Version',\n options: ['dall-e-3', 'dall-e-2'],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'size',\n type: 'select',\n defaultValue: '1024x1024',\n label: 'Size',\n options: ['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792'],\n },\n {\n name: 'style',\n type: 'select',\n defaultValue: 'natural',\n label: 'Style',\n options: ['vivid', 'natural'],\n },\n ],\n },\n {\n name: 'enable-prompt-optimization',\n type: 'checkbox',\n label: 'Optimize prompt',\n },\n ],\n label: 'OpenAI DALL-E Settings',\n },\n },\n {\n id: 'gpt-image-1',\n name: 'OpenAI GPT Image 1',\n fields: ['upload'],\n handler: async (prompt: string, options) => {\n const imageData = await generateImage(prompt, options)\n return {\n data: {\n alt: imageData.alt,\n },\n file: {\n name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.png`,\n data: imageData.buffer,\n mimetype: 'image/png',\n size: imageData.buffer.byteLength,\n } as File,\n }\n },\n output: 'image',\n settings: {\n name: 'gpt-image-1-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'gpt-image-1'\n },\n },\n fields: [\n {\n name: 'version',\n type: 'select',\n defaultValue: 'gpt-image-1',\n label: 'Version',\n options: ['gpt-image-1'],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'size',\n type: 'select',\n defaultValue: 'auto',\n label: 'Size',\n options: ['1024x1024', '1024x1536', '1536x1024', 'auto'],\n },\n {\n name: 'quality',\n type: 'select',\n defaultValue: 'auto',\n label: 'Quality',\n options: ['low', 'medium', 'high', 'auto'],\n },\n ],\n },\n {\n name: 'output_format',\n type: 'select',\n defaultValue: 'png',\n label: 'Output Format',\n options: ['png', 'jpeg', 'webp'],\n },\n {\n name: 'output_compression',\n type: 'number',\n admin: {\n condition(data) {\n return data.output_format === 'jpeg' || data.output_format === 'webp'\n },\n },\n defaultValue: 100,\n label: 'Output Compression',\n max: 100,\n min: 0,\n },\n {\n name: 'background',\n type: 'select',\n admin: {\n condition(data) {\n return data.output_format === 'png' || data.output_format === 'webp'\n },\n },\n defaultValue: 'white',\n label: 'Background',\n options: ['white', 'transparent'],\n },\n {\n name: 'moderation',\n type: 'select',\n defaultValue: 'auto',\n label: 'Moderation',\n options: ['auto', 'low'],\n },\n ],\n label: 'OpenAI GPT Image 1 Settings',\n },\n },\n {\n id: 'tts',\n name: 'OpenAI Text-to-Speech',\n fields: ['upload'],\n handler: async (text: string, options) => {\n //TODO: change it to open ai text to speech api\n const voiceData = await generateVoice(text, options)\n if (!voiceData || !voiceData.buffer) {\n throw new Error('Voice data missing')\n }\n return {\n data: {\n alt: text,\n },\n file: {\n name: `voice_${generateFileNameByPrompt(text)}.mp3`,\n data: voiceData.buffer,\n mimetype: 'audio/mp3',\n size: voiceData.buffer.byteLength,\n } as File,\n }\n },\n output: 'audio',\n settings: {\n name: `${MODEL_KEY}-tts-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'tts'\n },\n },\n fields: [\n {\n name: 'voice',\n type: 'select',\n defaultValue: 'alloy',\n label: 'Voice',\n options: ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'] as Array<\n SpeechCreateParams['voice']\n >,\n },\n {\n name: 'model',\n type: 'select',\n defaultValue: 'tts-1',\n label: 'Model',\n options: ['tts-1', 'tts-1-hd'] as Array<SpeechCreateParams['model']>,\n },\n {\n name: 'response_format',\n type: 'select',\n defaultValue: 'mp3',\n label: 'Response Format',\n options: ['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'],\n },\n {\n name: 'speed',\n type: 'number',\n defaultValue: 1,\n label: 'Speed',\n max: 4,\n min: 0.25,\n },\n ],\n label: 'OpenAI Text-to-Speech Settings',\n },\n },\n {\n id: `${MODEL_KEY}-object`,\n name: 'OpenAI GPT',\n fields: ['richText'],\n handler: (text: string, options) => {\n return generateObject(\n text,\n {\n ...options,\n providerOptions: {\n openai: {\n strictJsonSchema: true,\n structuredOutputs: true,\n },\n },\n system: options.system || defaultSystemPrompt,\n },\n openai(options.model),\n )\n },\n output: 'text',\n settings: {\n name: `${MODEL_KEY}-object-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-object`\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gpt-4o',\n label: 'Model',\n options: MODELS,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'maxTokens',\n type: 'number',\n defaultValue: 5000,\n },\n {\n name: 'temperature',\n type: 'number',\n defaultValue: 0.7,\n max: 1,\n min: 0,\n },\n ],\n },\n {\n name: 'extractAttachments',\n type: 'checkbox',\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["defaultSystemPrompt","generateFileNameByPrompt","generateObject","generateImage","generateVoice","openai","MODEL_KEY","MODELS","OpenAIConfig","models","id","name","fields","handler","prompt","options","providerOptions","strictJsonSchema","structuredOutputs","system","model","output","settings","type","admin","condition","data","defaultValue","label","max","min","imageData","alt","file","buffer","mimetype","size","byteLength","output_format","text","voiceData","Error","provider"],"mappings":"AAKA,SAASA,mBAAmB,QAAQ,mBAAkB;AACtD,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AAEpC,MAAMC,YAAY;AAClB,MAAMC,SAAS;IACb;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,6FAA6F;AAC7F,OAAO,MAAMC,eAAiC;IAC5CC,QAAQ;QACN;YACEC,IAAI,CAAC,EAAEJ,UAAU,KAAK,CAAC;YACvBK,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,SAAS,CACPC,QACAC;gBAUA,OAAOb,eACLY,QACA;oBACE,GAAGC,OAAO;oBACVC,iBAAiB;wBACfX,QAAQ;4BACNY,kBAAkB;4BAClBC,mBAAmB;wBACrB;oBACF;oBACAC,QAAQJ,QAAQI,MAAM,IAAInB;gBAC5B,GACAK,OAAOU,QAAQK,KAAK;YAExB;YACAC,QAAQ;YACRC,UAAU;gBACRX,MAAM,CAAC,EAAEL,UAAU,cAAc,CAAC;gBAClCiB,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK,CAAC,EAAEpB,UAAU,KAAK,CAAC;oBACjD;gBACF;gBACAM,QAA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C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"sourcesContent":["import type { JSONSchema } from 'openai/lib/jsonschema'\n\nimport { isObjectSchema } from '../utils/isObjectSchema.js'\n\nexport interface LexicalNodeSchema extends JSONSchema {\n $schema?: string\n additionalProperties?: boolean\n definitions?: Record<string, any>\n properties: {\n [key: string]: any\n children?: {\n items: {\n $ref?: string\n anyOf?: { $ref: string }[]\n }\n type: 'array'\n }\n type?: {\n enum: string[]\n type: 'string'\n }\n }\n required?: string[]\n type: 'object'\n}\n\nexport const documentSchema: LexicalNodeSchema = {\n type: 'object',\n $schema: 'http://json-schema.org/draft-07/schema#',\n additionalProperties: false,\n definitions: {\n LineBreakNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['linebreak'] },\n version: { type: 'number' },\n },\n required: ['type', 'version'],\n },\n TabNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tab'] },\n version: { type: 'number' },\n },\n required: ['type', 'version'],\n },\n // Text Node (Leaf Node)\n TextNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['text'] },\n detail: {\n type: 'number',\n description: 'Text detail flags',\n enum: [\n 0, // No details\n 1, // IS_DIRECTIONLESS\n 2, // IS_UNMERGEABLE\n 3, // IS_DIRECTIONLESS + IS_UNMERGEABLE\n ],\n examples: [\n { description: 'No special details', value: 0 },\n { description: 'Directionless', value: 1 },\n { description: 'Unmergeable', value: 2 },\n { description: 'Directionless + Unmergeable', value: 3 },\n ],\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: {\n type: 'number',\n description: `Format flags for text:\n 0 = No format\n 1 = Bold\n 2 = Italic\n 3 = Bold + Italic (1|2)\n 4 = Strikethrough\n 8 = Underline\n 9 = Bold + Underline (1|8)\n 16 = Code\n 32 = Subscript\n 64 = Superscript\n 128 = Highlight\n \n Formats can be combined using binary OR (|).\n Example combinations:\n - Bold + Italic = 1|2 = 3\n - Bold + Underline = 1|8 = 9\n - Italic + Underline = 2|8 = 10\n - Bold + Italic + Underline = 1|2|8 = 11`,\n },\n indent: { type: 'number' },\n mode: {\n type: 'number',\n description: 'Text mode flags',\n enum: [\n 0, // Normal\n 1, // Token\n 2, // Segmented\n ],\n examples: [\n { description: 'Normal text', value: 0 },\n { description: 'Token text', value: 1 },\n { description: 'Segmented text', value: 2 },\n ],\n },\n style: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n text: { type: 'string' },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'text',\n 'format',\n 'style',\n 'mode',\n 'detail',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Cell Node\n TableCellNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablecell'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n colSpan: { type: 'number' },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n headerState: { type: 'number' },\n indent: { type: 'number' },\n version: { type: 'number' },\n width: {\n type: ['null'],\n enum: [null],\n },\n },\n required: [\n 'type',\n 'children',\n 'headerState',\n 'colSpan',\n 'width',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Row Node\n TableRowNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablerow'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableCellNode',\n },\n },\n height: { type: 'number' },\n },\n required: ['type', 'children', 'height'],\n },\n // Styled Table Node\n TableNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['table'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableRowNode',\n },\n },\n },\n required: ['type', 'children'],\n },\n // Heading Node\n HeadingNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['heading'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/LineBreakNode' },\n { $ref: '#/definitions/TabNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n tag: { type: 'string', enum: ['h1', 'h2', 'h3'] },\n version: { type: 'number' },\n },\n required: ['type', 'tag', 'children', 'direction', 'indent', 'version'],\n },\n // Paragraph Node\n ParagraphNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['paragraph'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/CodeNode' },\n { $ref: '#/definitions/LineBreakNode' },\n { $ref: '#/definitions/TabNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: {\n type: 'string',\n description:\n 'Format alignment based on content. Prioritize \"start\", then \"center\", and use \"right\" only when appropriate.',\n enum: ['start', 'center', 'right'],\n },\n indent: { type: 'number' },\n textFormat: { type: 'number' },\n textStyle: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'children',\n 'direction',\n 'format',\n 'indent',\n 'textFormat',\n 'textStyle',\n 'version',\n ],\n },\n // Link Node\n LinkNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['link'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n url: { type: 'string' },\n },\n required: ['type', 'url', 'children'],\n },\n // List Item Node\n ListItemNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n // NOTE: Do not change the position of \"indent\", models like gpt generate properties as they are\n // defined in schema, moving the position of property \"indent\"\n // can cause issue with schema validation while streaming generated json to lexical editor\n indent: { type: 'number', enum: [0, 1] },\n\n type: { type: 'string', enum: ['listitem'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/ListNode' },\n { $ref: '#/definitions/LineBreakNode' },\n ],\n },\n },\n },\n required: ['indent', 'type', 'children'],\n },\n // List Node\n ListNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['list'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/ListItemNode',\n },\n },\n listType: { type: 'string', enum: ['bullet', 'number'] },\n },\n required: ['type', 'listType', 'children'],\n },\n // Quote Node\n QuoteNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['quote'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/LineBreakNode' },\n { $ref: '#/definitions/TabNode' },\n ],\n },\n },\n },\n required: ['type', 'children'],\n },\n // Code Node\n CodeNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['code'] },\n code: { type: 'string' },\n language: { type: 'string' },\n },\n required: ['type', 'code', 'language'],\n },\n // Horizontal Rule Node\n HorizontalRuleNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['horizontalrule'] },\n },\n required: ['type'],\n },\n // Image Node\n ImageNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['image'] },\n alt: { type: 'string' },\n caption: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n src: { type: 'string' },\n },\n required: ['type', 'src', 'alt', 'caption'],\n },\n // Root Node\n RootNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['root'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/HeadingNode' },\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/ListNode' },\n { $ref: '#/definitions/QuoteNode' },\n { $ref: '#/definitions/CodeNode' },\n { $ref: '#/definitions/HorizontalRuleNode' },\n { $ref: '#/definitions/ImageNode' },\n { $ref: '#/definitions/TableNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n version: { type: 'number' },\n },\n required: ['type', 'children', 'direction', 'indent', 'version'],\n },\n },\n properties: {\n root: {\n $ref: '#/definitions/RootNode',\n },\n },\n required: ['root'],\n}\n\nexport const lexicalJsonSchema = (customNodes: JSONSchema[] | undefined) => {\n const schema = structuredClone(documentSchema)\n\n if (Array.isArray(customNodes) && customNodes.length > 0) {\n customNodes.forEach((nodeObj) => {\n for (const [nodeName, nodeDefinition] of Object.entries(nodeObj)) {\n // @ts-ignore\n schema.definitions[nodeName] = nodeDefinition\n\n // @ts-ignore\n const rootNode = schema.definitions['RootNode']\n if (isObjectSchema(rootNode)) {\n const children = rootNode.properties?.children\n const items = children?.items\n const anyOfList = (items as any)?.anyOf\n\n if (Array.isArray(anyOfList)) {\n anyOfList.push({ $ref: `#/definitions/${nodeName}` })\n }\n }\n }\n })\n }\n\n return schema\n}\n"],"names":["isObjectSchema","documentSchema","type","$schema","additionalProperties","definitions","LineBreakNode","properties","enum","version","required","TabNode","TextNode","detail","description","examples","value","direction","format","indent","mode","style","text","TableCellNode","children","items","$ref","colSpan","headerState","width","TableRowNode","height","TableNode","HeadingNode","anyOf","tag","ParagraphNode","textFormat","textStyle","LinkNode","url","ListItemNode","ListNode","listType","QuoteNode","CodeNode","code","language","HorizontalRuleNode","ImageNode","alt","caption","src","RootNode","root","lexicalJsonSchema","customNodes","schema","structuredClone","Array","isArray","length","forEach","nodeObj","nodeName","nodeDefinition","Object","entries","rootNode","anyOfList","push"],"mappings":"AAEA,SAASA,cAAc,QAAQ,6BAA4B;AAwB3D,OAAO,MAAMC,iBAAoC;IAC/CC,MAAM;IACN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,CAACJ,SAAU;gBAChE,aAAa;gBACbN,OAAOpD,WAAW,CAAC2D,SAAS,GAAGC;gBAE/B,aAAa;gBACb,MAAMG,WAAWX,OAAOpD,WAAW,CAAC,WAAW;gBAC/C,IAAIL,eAAeoE,WAAW;oBAC5B,MAAM5C,WAAW4C,SAAS7D,UAAU,EAAEiB;oBACtC,MAAMC,QAAQD,UAAUC;oBACxB,MAAM4C,YAAa5C,OAAeS;oBAElC,IAAIyB,MAAMC,OAAO,CAACS,YAAY;wBAC5BA,UAAUC,IAAI,CAAC;4BAAE5C,MAAM,CAAC,cAAc,EAAEsC,UAAU;wBAAC;oBACrD;gBACF;YACF;QACF;IACF;IAEA,OAAOP;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"sourcesContent":["import type { JSONSchema } from 'openai/lib/jsonschema'\n\nimport { isObjectSchema } from '../utils/isObjectSchema.js'\n\nexport interface LexicalNodeSchema extends JSONSchema {\n $schema?: string\n additionalProperties?: boolean\n definitions?: Record<string, any>\n properties: {\n [key: string]: any\n children?: {\n items: {\n $ref?: string\n anyOf?: { $ref: string }[]\n }\n type: 'array'\n }\n type?: {\n enum: string[]\n type: 'string'\n }\n }\n required?: string[]\n type: 'object'\n}\n\nexport const documentSchema: LexicalNodeSchema = {\n type: 'object',\n $schema: 'http://json-schema.org/draft-07/schema#',\n additionalProperties: false,\n definitions: {\n LineBreakNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['linebreak'] },\n version: { type: 'number' },\n },\n required: ['type', 'version'],\n },\n TabNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tab'] },\n version: { type: 'number' },\n },\n required: ['type', 'version'],\n },\n // Text Node (Leaf Node)\n TextNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['text'] },\n detail: {\n type: 'number',\n description: 'Text detail flags',\n enum: [\n 0, // No details\n 1, // IS_DIRECTIONLESS\n 2, // IS_UNMERGEABLE\n 3, // IS_DIRECTIONLESS + IS_UNMERGEABLE\n ],\n examples: [\n { description: 'No special details', value: 0 },\n { description: 'Directionless', value: 1 },\n { description: 'Unmergeable', value: 2 },\n { description: 'Directionless + Unmergeable', value: 3 },\n ],\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: {\n type: 'number',\n description: `Format flags for text:\n 0 = No format\n 1 = Bold\n 2 = Italic\n 3 = Bold + Italic (1|2)\n 4 = Strikethrough\n 8 = Underline\n 9 = Bold + Underline (1|8)\n 16 = Code\n 32 = Subscript\n 64 = Superscript\n 128 = Highlight\n \n Formats can be combined using binary OR (|).\n Example combinations:\n - Bold + Italic = 1|2 = 3\n - Bold + Underline = 1|8 = 9\n - Italic + Underline = 2|8 = 10\n - Bold + Italic + Underline = 1|2|8 = 11`,\n },\n indent: { type: 'number' },\n mode: {\n type: 'number',\n description: 'Text mode flags',\n enum: [\n 0, // Normal\n 1, // Token\n 2, // Segmented\n ],\n examples: [\n { description: 'Normal text', value: 0 },\n { description: 'Token text', value: 1 },\n { description: 'Segmented text', value: 2 },\n ],\n },\n style: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n text: { type: 'string' },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'text',\n 'format',\n 'style',\n 'mode',\n 'detail',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Cell Node\n TableCellNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablecell'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n colSpan: { type: 'number' },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n headerState: { type: 'number' },\n indent: { type: 'number' },\n version: { type: 'number' },\n width: {\n type: ['null'],\n enum: [null],\n },\n },\n required: [\n 'type',\n 'children',\n 'headerState',\n 'colSpan',\n 'width',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Row Node\n TableRowNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablerow'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableCellNode',\n },\n },\n height: { type: 'number' },\n },\n required: ['type', 'children', 'height'],\n },\n // Styled Table Node\n TableNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['table'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableRowNode',\n },\n },\n },\n required: ['type', 'children'],\n },\n // Heading Node\n HeadingNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['heading'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/LineBreakNode' },\n { $ref: '#/definitions/TabNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n tag: { type: 'string', enum: ['h1', 'h2', 'h3'] },\n version: { type: 'number' },\n },\n required: ['type', 'tag', 'children', 'direction', 'indent', 'version'],\n },\n // Paragraph Node\n ParagraphNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['paragraph'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/CodeNode' },\n { $ref: '#/definitions/LineBreakNode' },\n { $ref: '#/definitions/TabNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: {\n type: 'string',\n description:\n 'Format alignment based on content. Prioritize \"start\", then \"center\", and use \"right\" only when appropriate.',\n enum: ['start', 'center', 'right'],\n },\n indent: { type: 'number' },\n textFormat: { type: 'number' },\n textStyle: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'children',\n 'direction',\n 'format',\n 'indent',\n 'textFormat',\n 'textStyle',\n 'version',\n ],\n },\n // Link Node\n LinkNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['link'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n url: { type: 'string' },\n },\n required: ['type', 'url', 'children'],\n },\n // List Item Node\n ListItemNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n // NOTE: Do not change the position of \"indent\", models like gpt generate properties as they are\n // defined in schema, moving the position of property \"indent\"\n // can cause issue with schema validation while streaming generated json to lexical editor\n indent: { type: 'number', enum: [0, 1] },\n\n type: { type: 'string', enum: ['listitem'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/ListNode' },\n { $ref: '#/definitions/LineBreakNode' },\n ],\n },\n },\n },\n required: ['indent', 'type', 'children'],\n },\n // List Node\n ListNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['list'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/ListItemNode',\n },\n },\n listType: { type: 'string', enum: ['bullet', 'number'] },\n },\n required: ['type', 'listType', 'children'],\n },\n // Quote Node\n QuoteNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['quote'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/LineBreakNode' },\n { $ref: '#/definitions/TabNode' },\n ],\n },\n },\n },\n required: ['type', 'children'],\n },\n // Code Node\n CodeNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['code'] },\n code: { type: 'string' },\n language: { type: 'string' },\n },\n required: ['type', 'code', 'language'],\n },\n // Horizontal Rule Node\n HorizontalRuleNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['horizontalrule'] },\n },\n required: ['type'],\n },\n // Image Node\n ImageNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['image'] },\n alt: { type: 'string' },\n caption: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n src: { type: 'string' },\n },\n required: ['type', 'src', 'alt', 'caption'],\n },\n // Root Node\n RootNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['root'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/HeadingNode' },\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/ListNode' },\n { $ref: '#/definitions/QuoteNode' },\n { $ref: '#/definitions/CodeNode' },\n { $ref: '#/definitions/HorizontalRuleNode' },\n { $ref: '#/definitions/ImageNode' },\n { $ref: '#/definitions/TableNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n version: { type: 'number' },\n },\n required: ['type', 'children', 'direction', 'indent', 'version'],\n },\n },\n properties: {\n root: {\n $ref: '#/definitions/RootNode',\n },\n },\n required: ['root'],\n}\n\nexport const lexicalJsonSchema = (customNodes: JSONSchema[] | undefined) => {\n const schema = structuredClone(documentSchema)\n\n if (Array.isArray(customNodes) && customNodes.length > 0) {\n customNodes.forEach((nodeObj) => {\n for (const [nodeName, nodeDefinition] of Object.entries(nodeObj)) {\n // @ts-ignore\n schema.definitions[nodeName] = nodeDefinition\n\n // @ts-ignore\n const rootNode = schema.definitions['RootNode']\n if (isObjectSchema(rootNode)) {\n const children = rootNode.properties?.children\n const items = children?.items\n const anyOfList = (items as any)?.anyOf\n\n if (Array.isArray(anyOfList)) {\n anyOfList.push({ $ref: `#/definitions/${nodeName}` })\n }\n }\n }\n })\n }\n\n return schema\n}\n"],"names":["isObjectSchema","documentSchema","type","$schema","additionalProperties","definitions","LineBreakNode","properties","enum","version","required","TabNode","TextNode","detail","description","examples","value","direction","format","indent","mode","style","text","TableCellNode","children","items","$ref","colSpan","headerState","width","TableRowNode","height","TableNode","HeadingNode","anyOf","tag","ParagraphNode","textFormat","textStyle","LinkNode","url","ListItemNode","ListNode","listType","QuoteNode","CodeNode","code","language","HorizontalRuleNode","ImageNode","alt","caption","src","RootNode","root","lexicalJsonSchema","customNodes","schema","structuredClone","Array","isArray","length","forEach","nodeObj","nodeName","nodeDefinition","Object","entries","rootNode","anyOfList","push"],"mappings":"AAEA,SAASA,cAAc,QAAQ,6BAA4B;AAwB3D,OAAO,MAAMC,iBAAoC;IAC/CC,MAAM;IACNC,SAAS;IACTC,sBAAsB;IACtBC,aAAa;QACXC,eAAe;YACbJ,MAAM;YACNE,sBAAsB;YACtBG,YAAY;gBACVL,MAAM;oBAAEA,MAAM;oBAAUM,MAAM;wBAAC;qBAAY;gBAAC;gBAC5CC,SAAS;oBAAEP,MAAM;gBAAS;YAC5B;YACAQ,UAAU;gBAAC;gBAAQ;aAAU;QAC/B;QACAC,SAAS;YACPT,MAAM;YACNE,sBAAsB;YACtBG,YAAY;gBACVL,MAAM;oBAAEA,MAAM;oBAAUM,MAAM;wBAAC;qBAAM;gBAAC;gBACtCC,SAAS;oBAAEP,MAAM;gBAAS;YAC5B;YACAQ,UAAU;gBAAC;gBAAQ;aAAU;QAC/B;QACA,wBAAwB;QACxBE,UAAU;YACRV,MAAM;YACNE,sBAAsB;YACtBG,YAAY;gBACVL,MAAM;oBAAEA,MAAM;oBAAUM,MAAM;wBAAC;qBAAO;gBAAC;gBACvCK,QAAQ;oBACNX,MAAM;oBACNY,aAAa;oBACbN,MAAM;wBACJ;wBACA;wBACA;wBACA;qBACD;oBACDO,UAAU;wBACR;4BAAED,aAAa;4BAAsBE,OAAO;wBAAE;wBAC9C;4BAAEF,aAAa;4BAAiBE,OAAO;wBAAE;wBACzC;4BAAEF,aAAa;4BAAeE,OAAO;wBAAE;wBACv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AAS;gBACzBO,SAAS;oBAAEP,MAAM;gBAAS;YAC5B;YACAQ,UAAU;gBAAC;gBAAQ;gBAAY;gBAAa;gBAAU;aAAU;QAClE;IACF;IACAH,YAAY;QACV+C,MAAM;YACJ5B,MAAM;QACR;IACF;IACAhB,UAAU;QAAC;KAAO;AACpB,EAAC;AAED,OAAO,MAAM6C,oBAAoB,CAACC;IAChC,MAAMC,SAASC,gBAAgBzD;IAE/B,IAAI0D,MAAMC,OAAO,CAACJ,gBAAgBA,YAAYK,MAAM,GAAG,GAAG;QACxDL,YAAYM,OAAO,CAAC,CAACC;YACnB,KAAK,MAAM,CAACC,UAAUC,eAAe,IAAIC,OAAOC,OAAO,CAACJ,SAAU;gBAChE,aAAa;gBACbN,OAAOpD,WAAW,CAAC2D,SAAS,GAAGC;gBAE/B,aAAa;gBACb,MAAMG,WAAWX,OAAOpD,WAAW,CAAC,WAAW;gBAC/C,IAAIL,eAAeoE,WAAW;oBAC5B,MAAM5C,WAAW4C,SAAS7D,UAAU,EAAEiB;oBACtC,MAAMC,QAAQD,UAAUC;oBACxB,MAAM4C,YAAa5C,OAAeS;oBAElC,IAAIyB,MAAMC,OAAO,CAACS,YAAY;wBAC5BA,UAAUC,IAAI,CAAC;4BAAE5C,MAAM,CAAC,cAAc,EAAEsC,SAAS,CAAC;wBAAC;oBACrD;gBACF;YACF;QACF;IACF;IAEA,OAAOP;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/utils/editImagesWithOpenAI.ts"],"sourcesContent":["import type { ImageReference } from '../../types.js'\n\n/**\n * Send multiple images as `image[]` to OpenAI's image edit endpoint using gpt-image-1.\n * @param images\n * @param prompt Prompt to guide the image edit\n * @param model\n * @returns base64 string of the edited image\n * @note: Remove this function, once https://github.com/openai/openai-node/issues/1492 is fixed.\n */\nexport async function editImagesWithOpenAI(\n images: ImageReference[],\n prompt: string,\n model: string = 'gpt-image-1',\n) {\n try {\n const formData = new FormData()\n\n for (const [_, img] of images.entries()) {\n const extension = img.data.type.split('/')[1]\n formData.append('image[]', img.data, `${img.name}.${extension}`)\n }\n\n formData.append('prompt', prompt)\n formData.append('model', model)\n\n const baseURL = process.env.OPENAI_BASE_URL ?? 'https://api.openai.com/v1'\n const openaiRes = await fetch(`${baseURL}/images/edits`, {\n body: formData,\n headers: {\n Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,\n 'OpenAI-Organization': process.env.OPENAI_ORG_ID || '',\n },\n method: 'POST',\n })\n\n if (!openaiRes.ok) {\n const errorText = await openaiRes.text()\n throw new Error(`OpenAI edit error: ${openaiRes.status} - ${errorText}`)\n }\n\n return openaiRes.json()\n } catch (e) {\n console.error('Error editing images: ', e)\n throw Error(\n 'Image edit request failed. Please ensure the images are accessible and hosted publicly.',\n )\n }\n}\n"],"names":["editImagesWithOpenAI","images","prompt","model","formData","FormData","_","img","entries","extension","data","type","split","append","name","baseURL","process","env","OPENAI_BASE_URL","openaiRes","fetch","body","headers","Authorization","OPENAI_API_KEY","OPENAI_ORG_ID","method","ok","errorText","text","Error","status","json","e","console","error"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,eAAeA,qBACpBC,MAAwB,EACxBC,MAAc,EACdC,QAAgB,aAAa;IAE7B,IAAI;QACF,MAAMC,WAAW,IAAIC;QAErB,KAAK,MAAM,CAACC,GAAGC,IAAI,IAAIN,OAAOO,OAAO,GAAI;YACvC,MAAMC,YAAYF,IAAIG,IAAI,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;YAC7CR,SAASS,MAAM,CAAC,WAAWN,IAAIG,IAAI,EAAE,GAAGH,IAAIO,IAAI,CAAC,CAAC,EAAEL,WAAW;QACjE;QAEAL,SAASS,MAAM,CAAC,UAAUX;QAC1BE,SAASS,MAAM,CAAC,SAASV;QAEzB,MAAMY,UAAUC,QAAQC,GAAG,CAACC,eAAe,IAAI;QAC/C,MAAMC,YAAY,MAAMC,MAAM,GAAGL,QAAQ,aAAa,CAAC,EAAE;YACvDM,MAAMjB;YACNkB,SAAS;gBACPC,eAAe,CAAC,OAAO,EAAEP,QAAQC,GAAG,CAACO,cAAc,EAAE;gBACrD,uBAAuBR,QAAQC,GAAG,CAACQ,aAAa,IAAI;YACtD;YACAC,QAAQ;QACV;QAEA,IAAI,CAACP,UAAUQ,EAAE,EAAE;YACjB,MAAMC,YAAY,MAAMT,UAAUU,IAAI;YACtC,MAAM,IAAIC,MAAM,CAAC,mBAAmB,EAAEX,UAAUY,MAAM,CAAC,GAAG,EAAEH,WAAW;QACzE;QAEA,OAAOT,UAAUa,IAAI;IACvB,EAAE,OAAOC,GAAG;QACVC,QAAQC,KAAK,CAAC,0BAA0BF;QACxC,MAAMH,MACJ;IAEJ;AACF"}
1
+ {"version":3,"sources":["../../../src/ai/utils/editImagesWithOpenAI.ts"],"sourcesContent":["import type { ImageReference } from '../../types.js'\n\n/**\n * Send multiple images as `image[]` to OpenAI's image edit endpoint using gpt-image-1.\n * @param images\n * @param prompt Prompt to guide the image edit\n * @param model\n * @returns base64 string of the edited image\n * @note: Remove this function, once https://github.com/openai/openai-node/issues/1492 is fixed.\n */\nexport async function editImagesWithOpenAI(\n images: ImageReference[],\n prompt: string,\n model: string = 'gpt-image-1',\n) {\n try {\n const formData = new FormData()\n\n for (const [_, img] of images.entries()) {\n const extension = img.data.type.split('/')[1]\n formData.append('image[]', img.data, `${img.name}.${extension}`)\n }\n\n formData.append('prompt', prompt)\n formData.append('model', model)\n\n const baseURL = process.env.OPENAI_BASE_URL ?? 'https://api.openai.com/v1'\n const openaiRes = await fetch(`${baseURL}/images/edits`, {\n body: formData,\n headers: {\n Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,\n 'OpenAI-Organization': process.env.OPENAI_ORG_ID || '',\n },\n method: 'POST',\n })\n\n if (!openaiRes.ok) {\n const errorText = await openaiRes.text()\n throw new Error(`OpenAI edit error: ${openaiRes.status} - ${errorText}`)\n }\n\n return openaiRes.json()\n } catch (e) {\n console.error('Error editing images: ', e)\n throw Error(\n 'Image edit request failed. Please ensure the images are accessible and hosted publicly.',\n )\n }\n}\n"],"names":["editImagesWithOpenAI","images","prompt","model","formData","FormData","_","img","entries","extension","data","type","split","append","name","baseURL","process","env","OPENAI_BASE_URL","openaiRes","fetch","body","headers","Authorization","OPENAI_API_KEY","OPENAI_ORG_ID","method","ok","errorText","text","Error","status","json","e","console","error"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,eAAeA,qBACpBC,MAAwB,EACxBC,MAAc,EACdC,QAAgB,aAAa;IAE7B,IAAI;QACF,MAAMC,WAAW,IAAIC;QAErB,KAAK,MAAM,CAACC,GAAGC,IAAI,IAAIN,OAAOO,OAAO,GAAI;YACvC,MAAMC,YAAYF,IAAIG,IAAI,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;YAC7CR,SAASS,MAAM,CAAC,WAAWN,IAAIG,IAAI,EAAE,CAAC,EAAEH,IAAIO,IAAI,CAAC,CAAC,EAAEL,UAAU,CAAC;QACjE;QAEAL,SAASS,MAAM,CAAC,UAAUX;QAC1BE,SAASS,MAAM,CAAC,SAASV;QAEzB,MAAMY,UAAUC,QAAQC,GAAG,CAACC,eAAe,IAAI;QAC/C,MAAMC,YAAY,MAAMC,MAAM,CAAC,EAAEL,QAAQ,aAAa,CAAC,EAAE;YACvDM,MAAMjB;YACNkB,SAAS;gBACPC,eAAe,CAAC,OAAO,EAAEP,QAAQC,GAAG,CAACO,cAAc,CAAC,CAAC;gBACrD,uBAAuBR,QAAQC,GAAG,CAACQ,aAAa,IAAI;YACtD;YACAC,QAAQ;QACV;QAEA,IAAI,CAACP,UAAUQ,EAAE,EAAE;YACjB,MAAMC,YAAY,MAAMT,UAAUU,IAAI;YACtC,MAAM,IAAIC,MAAM,CAAC,mBAAmB,EAAEX,UAAUY,MAAM,CAAC,GAAG,EAAEH,UAAU,CAAC;QACzE;QAEA,OAAOT,UAAUa,IAAI;IACvB,EAAE,OAAOC,GAAG;QACVC,QAAQC,KAAK,CAAC,0BAA0BF;QACxC,MAAMH,MACJ;IAEJ;AACF"}
@@ -7,7 +7,8 @@ export function filterEditorSchemaByNodes(schema, allowedNodes) {
7
7
  if (isObjectSchema(def)) {
8
8
  const typeEnum = def.properties?.type?.enum;
9
9
  if (typeEnum && typeEnum.some((t)=>allowedTypes.has(t))) {
10
- filteredDefinitions[key] = JSON.parse(JSON.stringify(def)); // Deep copy to safely mutate
10
+ filteredDefinitions[key] = JSON.parse(JSON.stringify(def)) // Deep copy to safely mutate
11
+ ;
11
12
  }
12
13
  }
13
14
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/utils/filterEditorSchemaByNodes.ts"],"sourcesContent":["import type { LexicalNodeSchema } from '../schemas/lexicalJsonSchema.js'\n\nimport { isObjectSchema } from './isObjectSchema.js'\n\nexport function filterEditorSchemaByNodes(schema: LexicalNodeSchema, allowedNodes: string[]) {\n const allowedTypes = new Set(allowedNodes)\n\n const filteredDefinitions: Record<string, any> = {}\n\n // First pass: collect definitions whose \"type.enum\" includes an allowed type\n for (const [key, def] of Object.entries(schema.definitions ?? {})) {\n if (isObjectSchema(def)) {\n const typeEnum = def.properties?.type?.enum\n if (typeEnum && typeEnum.some((t) => allowedTypes.has(t))) {\n filteredDefinitions[key] = JSON.parse(JSON.stringify(def)) // Deep copy to safely mutate\n }\n }\n }\n\n // Helper to check if a $ref points to an allowed definition\n const isAllowedRef = (ref: string) => {\n if (typeof ref !== 'string') {\n return false\n }\n const defName = ref.replace('#/definitions/', '')\n return defName in filteredDefinitions\n }\n\n // Second pass: update \"children\" in each definition to only include allowed refs\n for (const def of Object.values(filteredDefinitions)) {\n if (isObjectSchema(def) && def.properties?.children?.items) {\n const items = def.properties.children.items\n\n if (Array.isArray(items.anyOf)) {\n // Filter anyOf to only allowed $refs\n items.anyOf = items.anyOf.filter((entry) => isAllowedRef(entry.$ref))\n if (items.anyOf.length === 0) {\n delete def.properties.children\n }\n } else if (items.$ref && !isAllowedRef(items.$ref)) {\n delete def.properties.children\n }\n }\n }\n\n // Return the new schema with pruned definitions\n return {\n ...schema,\n definitions: filteredDefinitions,\n }\n}\n"],"names":["isObjectSchema","filterEditorSchemaByNodes","schema","allowedNodes","allowedTypes","Set","filteredDefinitions","key","def","Object","entries","definitions","typeEnum","properties","type","enum","some","t","has","JSON","parse","stringify","isAllowedRef","ref","defName","replace","values","children","items","Array","isArray","anyOf","filter","entry","$ref","length"],"mappings":"AAEA,SAASA,cAAc,QAAQ,sBAAqB;AAEpD,OAAO,SAASC,0BAA0BC,MAAyB,EAAEC,YAAsB;IACzF,MAAMC,eAAe,IAAIC,IAAIF;IAE7B,MAAMG,sBAA2C,CAAC;IAElD,6EAA6E;IAC7E,KAAK,MAAM,CAACC,KAAKC,IAAI,IAAIC,OAAOC,OAAO,CAACR,OAAOS,WAAW,IAAI,CAAC,GAAI;QACjE,IAAIX,eAAeQ,MAAM;YACvB,MAAMI,WAAWJ,IAAIK,UAAU,EAAEC,MAAMC;YACvC,IAAIH,YAAYA,SAASI,IAAI,CAAC,CAACC,IAAMb,aAAac,GAAG,CAACD,KAAK;gBACzDX,mBAAmB,CAACC,IAAI,GAAGY,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACb,OAAM,6BAA6B;YAC1F;QACF;IACF;IAEA,4DAA4D;IAC5D,MAAMc,eAAe,CAACC;QACpB,IAAI,OAAOA,QAAQ,UAAU;YAC3B,OAAO;QACT;QACA,MAAMC,UAAUD,IAAIE,OAAO,CAAC,kBAAkB;QAC9C,OAAOD,WAAWlB;IACpB;IAEA,iFAAiF;IACjF,KAAK,MAAME,OAAOC,OAAOiB,MAAM,CAACpB,qBAAsB;QACpD,IAAIN,eAAeQ,QAAQA,IAAIK,UAAU,EAAEc,UAAUC,OAAO;YAC1D,MAAMA,QAAQpB,IAAIK,UAAU,CAACc,QAAQ,CAACC,KAAK;YAE3C,IAAIC,MAAMC,OAAO,CAACF,MAAMG,KAAK,GAAG;gBAC9B,qCAAqC;gBACrCH,MAAMG,KAAK,GAAGH,MAAMG,KAAK,CAACC,MAAM,CAAC,CAACC,QAAUX,aAAaW,MAAMC,IAAI;gBACnE,IAAIN,MAAMG,KAAK,CAACI,MAAM,KAAK,GAAG;oBAC5B,OAAO3B,IAAIK,UAAU,CAACc,QAAQ;gBAChC;YACF,OAAO,IAAIC,MAAMM,IAAI,IAAI,CAACZ,aAAaM,MAAMM,IAAI,GAAG;gBAClD,OAAO1B,IAAIK,UAAU,CAACc,QAAQ;YAChC;QACF;IACF;IAEA,gDAAgD;IAChD,OAAO;QACL,GAAGzB,MAAM;QACTS,aAAaL;IACf;AACF"}
1
+ {"version":3,"sources":["../../../src/ai/utils/filterEditorSchemaByNodes.ts"],"sourcesContent":["import type { LexicalNodeSchema } from '../schemas/lexicalJsonSchema.js'\n\nimport { isObjectSchema } from './isObjectSchema.js'\n\nexport function filterEditorSchemaByNodes(schema: LexicalNodeSchema, allowedNodes: string[]) {\n const allowedTypes = new Set(allowedNodes)\n\n const filteredDefinitions: Record<string, any> = {}\n\n // First pass: collect definitions whose \"type.enum\" includes an allowed type\n for (const [key, def] of Object.entries(schema.definitions ?? {})) {\n if (isObjectSchema(def)) {\n const typeEnum = def.properties?.type?.enum\n if (typeEnum && typeEnum.some((t) => allowedTypes.has(t))) {\n filteredDefinitions[key] = JSON.parse(JSON.stringify(def)) // Deep copy to safely mutate\n }\n }\n }\n\n // Helper to check if a $ref points to an allowed definition\n const isAllowedRef = (ref: string) => {\n if (typeof ref !== 'string') {\n return false\n }\n const defName = ref.replace('#/definitions/', '')\n return defName in filteredDefinitions\n }\n\n // Second pass: update \"children\" in each definition to only include allowed refs\n for (const def of Object.values(filteredDefinitions)) {\n if (isObjectSchema(def) && def.properties?.children?.items) {\n const items = def.properties.children.items\n\n if (Array.isArray(items.anyOf)) {\n // Filter anyOf to only allowed $refs\n items.anyOf = items.anyOf.filter((entry) => isAllowedRef(entry.$ref))\n if (items.anyOf.length === 0) {\n delete def.properties.children\n }\n } else if (items.$ref && !isAllowedRef(items.$ref)) {\n delete def.properties.children\n }\n }\n }\n\n // Return the new schema with pruned definitions\n return {\n ...schema,\n definitions: filteredDefinitions,\n }\n}\n"],"names":["isObjectSchema","filterEditorSchemaByNodes","schema","allowedNodes","allowedTypes","Set","filteredDefinitions","key","def","Object","entries","definitions","typeEnum","properties","type","enum","some","t","has","JSON","parse","stringify","isAllowedRef","ref","defName","replace","values","children","items","Array","isArray","anyOf","filter","entry","$ref","length"],"mappings":"AAEA,SAASA,cAAc,QAAQ,sBAAqB;AAEpD,OAAO,SAASC,0BAA0BC,MAAyB,EAAEC,YAAsB;IACzF,MAAMC,eAAe,IAAIC,IAAIF;IAE7B,MAAMG,sBAA2C,CAAC;IAElD,6EAA6E;IAC7E,KAAK,MAAM,CAACC,KAAKC,IAAI,IAAIC,OAAOC,OAAO,CAACR,OAAOS,WAAW,IAAI,CAAC,GAAI;QACjE,IAAIX,eAAeQ,MAAM;YACvB,MAAMI,WAAWJ,IAAIK,UAAU,EAAEC,MAAMC;YACvC,IAAIH,YAAYA,SAASI,IAAI,CAAC,CAACC,IAAMb,aAAac,GAAG,CAACD,KAAK;gBACzDX,mBAAmB,CAACC,IAAI,GAAGY,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACb,MAAM,6BAA6B;;YAC1F;QACF;IACF;IAEA,4DAA4D;IAC5D,MAAMc,eAAe,CAACC;QACpB,IAAI,OAAOA,QAAQ,UAAU;YAC3B,OAAO;QACT;QACA,MAAMC,UAAUD,IAAIE,OAAO,CAAC,kBAAkB;QAC9C,OAAOD,WAAWlB;IACpB;IAEA,iFAAiF;IACjF,KAAK,MAAME,OAAOC,OAAOiB,MAAM,CAACpB,qBAAsB;QACpD,IAAIN,eAAeQ,QAAQA,IAAIK,UAAU,EAAEc,UAAUC,OAAO;YAC1D,MAAMA,QAAQpB,IAAIK,UAAU,CAACc,QAAQ,CAACC,KAAK;YAE3C,IAAIC,MAAMC,OAAO,CAACF,MAAMG,KAAK,GAAG;gBAC9B,qCAAqC;gBACrCH,MAAMG,KAAK,GAAGH,MAAMG,KAAK,CAACC,MAAM,CAAC,CAACC,QAAUX,aAAaW,MAAMC,IAAI;gBACnE,IAAIN,MAAMG,KAAK,CAACI,MAAM,KAAK,GAAG;oBAC5B,OAAO3B,IAAIK,UAAU,CAACc,QAAQ;gBAChC;YACF,OAAO,IAAIC,MAAMM,IAAI,IAAI,CAACZ,aAAaM,MAAMM,IAAI,GAAG;gBAClD,OAAO1B,IAAIK,UAAU,CAACc,QAAQ;YAChC;QACF;IACF;IAEA,gDAAgD;IAChD,OAAO;QACL,GAAGzB,MAAM;QACTS,aAAaL;IACf;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/utils/generateFileNameByPrompt.ts"],"sourcesContent":["export function generateFileNameByPrompt(prompt: string) {\n // Helper function to get a random integer between min and max (inclusive)\n function getRandomInt(min: number, max: number) {\n return Math.floor(Math.random() * (max - min + 1)) + min\n }\n\n // Define the desired length of the filename part from the prompt\n const maxLength = 30\n const promptLength = prompt.length\n\n // Determine the start position for the random substring\n const startPos = getRandomInt(0, Math.max(0, promptLength - maxLength))\n\n // Get the random substring and truncate it if necessary\n let randomSubstring = prompt.substring(startPos, startPos + maxLength)\n\n // Replace invalid filename characters with an underscore\n randomSubstring = randomSubstring.replace(/[^a-z\\d]/gi, '_').toLowerCase()\n\n // Add a timestamp for uniqueness\n const timestamp = new Date().toISOString().replace(/[:.-]/g, '')\n\n // Combine the truncated prompt and timestamp to form the filename\n return `${randomSubstring}_${timestamp}`\n}\n"],"names":["generateFileNameByPrompt","prompt","getRandomInt","min","max","Math","floor","random","maxLength","promptLength","length","startPos","randomSubstring","substring","replace","toLowerCase","timestamp","Date","toISOString"],"mappings":"AAAA,OAAO,SAASA,yBAAyBC,MAAc;IACrD,0EAA0E;IAC1E,SAASC,aAAaC,GAAW,EAAEC,GAAW;QAC5C,OAAOC,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAMH,CAAAA,MAAMD,MAAM,CAAA,KAAMA;IACvD;IAEA,iEAAiE;IACjE,MAAMK,YAAY;IAClB,MAAMC,eAAeR,OAAOS,MAAM;IAElC,wDAAwD;IACxD,MAAMC,WAAWT,aAAa,GAAGG,KAAKD,GAAG,CAAC,GAAGK,eAAeD;IAE5D,wDAAwD;IACxD,IAAII,kBAAkBX,OAAOY,SAAS,CAACF,UAAUA,WAAWH;IAE5D,yDAAyD;IACzDI,kBAAkBA,gBAAgBE,OAAO,CAAC,cAAc,KAAKC,WAAW;IAExE,iCAAiC;IACjC,MAAMC,YAAY,IAAIC,OAAOC,WAAW,GAAGJ,OAAO,CAAC,UAAU;IAE7D,kEAAkE;IAClE,OAAO,GAAGF,gBAAgB,CAAC,EAAEI,WAAW;AAC1C"}
1
+ {"version":3,"sources":["../../../src/ai/utils/generateFileNameByPrompt.ts"],"sourcesContent":["export function generateFileNameByPrompt(prompt: string) {\n // Helper function to get a random integer between min and max (inclusive)\n function getRandomInt(min: number, max: number) {\n return Math.floor(Math.random() * (max - min + 1)) + min\n }\n\n // Define the desired length of the filename part from the prompt\n const maxLength = 30\n const promptLength = prompt.length\n\n // Determine the start position for the random substring\n const startPos = getRandomInt(0, Math.max(0, promptLength - maxLength))\n\n // Get the random substring and truncate it if necessary\n let randomSubstring = prompt.substring(startPos, startPos + maxLength)\n\n // Replace invalid filename characters with an underscore\n randomSubstring = randomSubstring.replace(/[^a-z\\d]/gi, '_').toLowerCase()\n\n // Add a timestamp for uniqueness\n const timestamp = new Date().toISOString().replace(/[:.-]/g, '')\n\n // Combine the truncated prompt and timestamp to form the filename\n return `${randomSubstring}_${timestamp}`\n}\n"],"names":["generateFileNameByPrompt","prompt","getRandomInt","min","max","Math","floor","random","maxLength","promptLength","length","startPos","randomSubstring","substring","replace","toLowerCase","timestamp","Date","toISOString"],"mappings":"AAAA,OAAO,SAASA,yBAAyBC,MAAc;IACrD,0EAA0E;IAC1E,SAASC,aAAaC,GAAW,EAAEC,GAAW;QAC5C,OAAOC,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAMH,CAAAA,MAAMD,MAAM,CAAA,KAAMA;IACvD;IAEA,iEAAiE;IACjE,MAAMK,YAAY;IAClB,MAAMC,eAAeR,OAAOS,MAAM;IAElC,wDAAwD;IACxD,MAAMC,WAAWT,aAAa,GAAGG,KAAKD,GAAG,CAAC,GAAGK,eAAeD;IAE5D,wDAAwD;IACxD,IAAII,kBAAkBX,OAAOY,SAAS,CAACF,UAAUA,WAAWH;IAE5D,yDAAyD;IACzDI,kBAAkBA,gBAAgBE,OAAO,CAAC,cAAc,KAAKC,WAAW;IAExE,iCAAiC;IACjC,MAAMC,YAAY,IAAIC,OAAOC,WAAW,GAAGJ,OAAO,CAAC,UAAU;IAE7D,kEAAkE;IAClE,OAAO,CAAC,EAAEF,gBAAgB,CAAC,EAAEI,UAAU,CAAC;AAC1C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const PLUGIN_NAME = 'plugin-ai'\nexport const PLUGIN_INSTRUCTIONS_TABLE = `${PLUGIN_NAME}-instructions`\nexport const PLUGIN_LEXICAL_EDITOR_FEATURE = `${PLUGIN_NAME}-actions-feature`\n\n// Endpoint defaults\nexport const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`\nexport const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`\nexport const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`\nexport const PLUGIN_FETCH_FIELDS_ENDPOINT = `${PLUGIN_API_ENDPOINT_BASE}/fetch-fields`\n\n// LLM Settings\nexport const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`\nexport const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-5-sonnet-latest`\n"],"names":["PLUGIN_NAME","PLUGIN_INSTRUCTIONS_TABLE","PLUGIN_LEXICAL_EDITOR_FEATURE","PLUGIN_API_ENDPOINT_BASE","PLUGIN_API_ENDPOINT_GENERATE","PLUGIN_API_ENDPOINT_GENERATE_UPLOAD","PLUGIN_FETCH_FIELDS_ENDPOINT","PLUGIN_DEFAULT_OPENAI_MODEL","PLUGIN_DEFAULT_ANTHROPIC_MODEL"],"mappings":"AAAA,OAAO,MAAMA,cAAc,YAAW;AACtC,OAAO,MAAMC,4BAA4B,GAAGD,YAAY,aAAa,CAAC,CAAA;AACtE,OAAO,MAAME,gCAAgC,GAAGF,YAAY,gBAAgB,CAAC,CAAA;AAE7E,oBAAoB;AACpB,OAAO,MAAMG,2BAA2B,CAAC,CAAC,EAAEH,aAAa,CAAA;AACzD,OAAO,MAAMI,+BAA+B,GAAGD,yBAAyB,SAAS,CAAC,CAAA;AAClF,OAAO,MAAME,sCAAsC,GAAGD,6BAA6B,OAAO,CAAC,CAAA;AAC3F,OAAO,MAAME,+BAA+B,GAAGH,yBAAyB,aAAa,CAAC,CAAA;AAEtF,eAAe;AACf,OAAO,MAAMI,8BAA8B,CAAC,WAAW,CAAC,CAAA;AACxD,OAAO,MAAMC,iCAAiC,CAAC,wBAAwB,CAAC,CAAA"}
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const PLUGIN_NAME = 'plugin-ai'\nexport const PLUGIN_INSTRUCTIONS_TABLE = `${PLUGIN_NAME}-instructions`\nexport const PLUGIN_LEXICAL_EDITOR_FEATURE = `${PLUGIN_NAME}-actions-feature`\n\n// Endpoint defaults\nexport const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`\nexport const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`\nexport const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`\nexport const PLUGIN_FETCH_FIELDS_ENDPOINT = `${PLUGIN_API_ENDPOINT_BASE}/fetch-fields`\n\n// LLM Settings\nexport const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`\nexport const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-5-sonnet-latest`\n"],"names":["PLUGIN_NAME","PLUGIN_INSTRUCTIONS_TABLE","PLUGIN_LEXICAL_EDITOR_FEATURE","PLUGIN_API_ENDPOINT_BASE","PLUGIN_API_ENDPOINT_GENERATE","PLUGIN_API_ENDPOINT_GENERATE_UPLOAD","PLUGIN_FETCH_FIELDS_ENDPOINT","PLUGIN_DEFAULT_OPENAI_MODEL","PLUGIN_DEFAULT_ANTHROPIC_MODEL"],"mappings":"AAAA,OAAO,MAAMA,cAAc,YAAW;AACtC,OAAO,MAAMC,4BAA4B,CAAC,EAAED,YAAY,aAAa,CAAC,CAAA;AACtE,OAAO,MAAME,gCAAgC,CAAC,EAAEF,YAAY,gBAAgB,CAAC,CAAA;AAE7E,oBAAoB;AACpB,OAAO,MAAMG,2BAA2B,CAAC,CAAC,EAAEH,YAAY,CAAC,CAAA;AACzD,OAAO,MAAMI,+BAA+B,CAAC,EAAED,yBAAyB,SAAS,CAAC,CAAA;AAClF,OAAO,MAAME,sCAAsC,CAAC,EAAED,6BAA6B,OAAO,CAAC,CAAA;AAC3F,OAAO,MAAME,+BAA+B,CAAC,EAAEH,yBAAyB,aAAa,CAAC,CAAA;AAEtF,eAAe;AACf,OAAO,MAAMI,8BAA8B,CAAC,WAAW,CAAC,CAAA;AACxD,OAAO,MAAMC,iCAAiC,CAAC,wBAAwB,CAAC,CAAA"}