@ai-stack/payloadcms 3.2.9-beta → 3.2.10-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.
- package/README.md +33 -21
- package/dist/ai/models/anthropic/generateRichText.d.ts +1 -1
- package/dist/ai/models/anthropic/generateRichText.d.ts.map +1 -1
- package/dist/ai/models/anthropic/generateRichText.js +5 -6
- package/dist/ai/models/anthropic/generateRichText.js.map +1 -1
- package/dist/ai/models/anthropic/index.js +15 -12
- package/dist/ai/models/anthropic/index.js.map +1 -1
- package/dist/ai/models/openai/generateImage.d.ts +2 -6
- package/dist/ai/models/openai/generateImage.d.ts.map +1 -1
- package/dist/ai/models/openai/generateImage.js +19 -9
- package/dist/ai/models/openai/generateImage.js.map +1 -1
- package/dist/ai/models/openai/generateRichText.d.ts +1 -1
- package/dist/ai/models/openai/generateRichText.d.ts.map +1 -1
- package/dist/ai/models/openai/generateRichText.js +5 -6
- package/dist/ai/models/openai/generateRichText.js.map +1 -1
- package/dist/ai/models/openai/index.d.ts.map +1 -1
- package/dist/ai/models/openai/index.js +133 -4
- package/dist/ai/models/openai/index.js.map +1 -1
- package/dist/ai/prompts.js +6 -6
- package/dist/ai/prompts.js.map +1 -1
- package/dist/ai/schemas/lexicalJsonSchema.d.ts +19 -741
- package/dist/ai/schemas/lexicalJsonSchema.d.ts.map +1 -1
- package/dist/ai/schemas/lexicalJsonSchema.js +72 -4
- package/dist/ai/schemas/lexicalJsonSchema.js.map +1 -1
- package/dist/ai/utils/editImagesWithOpenAI.d.ts +11 -0
- package/dist/ai/utils/editImagesWithOpenAI.d.ts.map +1 -0
- package/dist/ai/utils/editImagesWithOpenAI.js +37 -0
- package/dist/ai/utils/editImagesWithOpenAI.js.map +1 -0
- package/dist/ai/utils/filterEditorSchemaByNodes.d.ts +72 -0
- package/dist/ai/utils/filterEditorSchemaByNodes.d.ts.map +1 -0
- package/dist/ai/utils/filterEditorSchemaByNodes.js +43 -0
- package/dist/ai/utils/filterEditorSchemaByNodes.js.map +1 -0
- package/dist/ai/utils/isObjectSchema.d.ts +3 -0
- package/dist/ai/utils/isObjectSchema.d.ts.map +1 -0
- package/dist/ai/utils/isObjectSchema.js +5 -0
- package/dist/ai/utils/isObjectSchema.js.map +1 -0
- package/dist/collections/Instructions.d.ts.map +1 -1
- package/dist/collections/Instructions.js +26 -1
- package/dist/collections/Instructions.js.map +1 -1
- package/dist/defaults.d.ts +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.js.map +1 -1
- package/dist/endpoints/index.d.ts.map +1 -1
- package/dist/endpoints/index.js +65 -15
- package/dist/endpoints/index.js.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.js +46 -16
- package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
- package/dist/fields/PromptEditorField/defaultStyle.d.ts +50 -0
- package/dist/fields/PromptEditorField/defaultStyle.d.ts.map +1 -0
- package/dist/fields/PromptEditorField/defaultStyle.js +51 -0
- package/dist/fields/PromptEditorField/defaultStyle.js.map +1 -0
- package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts +2 -0
- package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts.map +1 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.js +4 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
- package/dist/providers/InstructionsProvider/useInstructions.d.ts.map +1 -1
- package/dist/providers/InstructionsProvider/useInstructions.js +54 -29
- package/dist/providers/InstructionsProvider/useInstructions.js.map +1 -1
- package/dist/types.d.ts +17 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/Compose/Compose.js +2 -2
- package/dist/ui/Compose/Compose.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.d.ts +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.d.ts.map +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.js +2 -1
- package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/useGenerate.d.ts.map +1 -1
- package/dist/ui/Compose/hooks/useGenerate.js +11 -4
- package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
- package/dist/utilities/extractImageData.d.ts +10 -0
- package/dist/utilities/extractImageData.d.ts.map +1 -0
- package/dist/utilities/extractImageData.js +22 -0
- package/dist/utilities/extractImageData.js.map +1 -0
- package/dist/utilities/setSafeLexicalState.js +5 -2
- package/dist/utilities/setSafeLexicalState.js.map +1 -1
- package/package.json +14 -9
- package/dist/ai/models/example-prompt-rich-text.md +0 -47
- package/dist/ai/models/example.d.ts +0 -73
- package/dist/ai/models/example.d.ts.map +0 -1
- package/dist/ai/models/example.js +0 -126
- package/dist/ai/models/example.js.map +0 -1
- package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts +0 -8
- package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts.map +0 -1
- package/dist/libraries/autocomplete/AutocompleteTextArea.js +0 -437
- package/dist/libraries/autocomplete/AutocompleteTextArea.js.map +0 -1
- package/dist/libraries/autocomplete/AutocompleteTextArea.module.scss +0 -35
package/README.md
CHANGED
|
@@ -15,14 +15,17 @@ The Payload AI Plugin is an advanced extension that integrates modern AI capabil
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
### 🎥 [Watch the Magic in Action](https://youtu.be/qaYukeGpuu4)
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
Want to dive deeper?
|
|
20
|
+
|
|
19
21
|
### 🎥 [Explore More in Our Extended Demo](https://youtu.be/LEsuHbKalNY)
|
|
20
|
-
### ⚙️ [Guide to Personalize](guide.md)
|
|
21
22
|
|
|
23
|
+
### ⚙️ [Guide to Personalize](guide.md)
|
|
22
24
|
|
|
23
25
|
## ✨ Supported Fields and Features
|
|
24
26
|
|
|
25
27
|
### Text and RichText Field
|
|
28
|
+
|
|
26
29
|
- 📝 **Text Generation**
|
|
27
30
|
- [x] **Compose** masterpieces effortlessly
|
|
28
31
|
- [x] **Proofread** with precision (Beta)
|
|
@@ -33,11 +36,14 @@ Want to dive deeper?
|
|
|
33
36
|
- [x] **Rephrase** for maximum impact (Beta)
|
|
34
37
|
|
|
35
38
|
### Upload Field
|
|
39
|
+
|
|
36
40
|
- 🎙️ **Voice Generation** powered by ElevenLabs, OpenAI
|
|
37
41
|
- 🖼️ **Image Generation** powered by OpenAI
|
|
42
|
+
- Now also supports **[GPT-Image-1](https://github.com/ashbuilds/payload-ai/pull/82)** Model
|
|
38
43
|
|
|
39
44
|
### Other Features
|
|
40
|
-
|
|
45
|
+
|
|
46
|
+
- 🔌 **Bring Your Own Model** ([Setup guide](https://github.com/ashbuilds/payload-ai/blob/main/guide.md#5-add-custom-model))
|
|
41
47
|
- 🎛️ **Field-level Prompt Customization**
|
|
42
48
|
- 🔐 **Access Control Support**
|
|
43
49
|
- 🧠 **Prompt Editor** (Beta)
|
|
@@ -66,13 +72,12 @@ pnpm add @ai-stack/payloadcms
|
|
|
66
72
|
|
|
67
73
|
## 🛠 Usage
|
|
68
74
|
|
|
69
|
-
Config with ease:
|
|
75
|
+
Config with ease:
|
|
70
76
|
|
|
71
77
|
```javascript
|
|
72
|
-
|
|
73
78
|
// Add below in payload.config.ts
|
|
74
|
-
import { buildConfig } from 'payload/config'
|
|
75
|
-
import { payloadAiPlugin } from '@ai-stack/payloadcms'
|
|
79
|
+
import { buildConfig } from 'payload/config'
|
|
80
|
+
import { payloadAiPlugin } from '@ai-stack/payloadcms'
|
|
76
81
|
|
|
77
82
|
export default buildConfig({
|
|
78
83
|
plugins: [
|
|
@@ -82,8 +87,10 @@ export default buildConfig({
|
|
|
82
87
|
},
|
|
83
88
|
debugging: false,
|
|
84
89
|
disableSponsorMessage: false,
|
|
90
|
+
|
|
91
|
+
generatePromptOnInit: process.env.NODE_ENV !== 'production',
|
|
85
92
|
|
|
86
|
-
|
|
93
|
+
/* Enable to restrict access to AI plugin settings only to admin users
|
|
87
94
|
access: {
|
|
88
95
|
settings: ({ req }: { req: PayloadRequest }) => {
|
|
89
96
|
return req.user?.role === 'admin';
|
|
@@ -93,12 +100,15 @@ export default buildConfig({
|
|
|
93
100
|
}),
|
|
94
101
|
],
|
|
95
102
|
// ... your existing Payload configuration
|
|
96
|
-
})
|
|
103
|
+
})
|
|
104
|
+
```
|
|
97
105
|
|
|
106
|
+
Configure your richText fields:
|
|
98
107
|
|
|
99
|
-
|
|
108
|
+
```javascript
|
|
100
109
|
import { PayloadAiPluginLexicalEditorFeature } from '@ai-stack/payloadcms'
|
|
101
110
|
|
|
111
|
+
// Add below in Lexical Editor field config
|
|
102
112
|
fields: [
|
|
103
113
|
{
|
|
104
114
|
name: 'content',
|
|
@@ -108,25 +118,26 @@ fields: [
|
|
|
108
118
|
return [
|
|
109
119
|
// ... your existing features
|
|
110
120
|
HeadingFeature({ enabledHeadingSizes: ['h1', 'h2', 'h3', 'h4'] }),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
UnorderedListFeature(),
|
|
115
|
-
BlockquoteFeature(),
|
|
116
|
-
PayloadAiPluginLexicalEditorFeature() // Add this line
|
|
121
|
+
|
|
122
|
+
// Please add below
|
|
123
|
+
PayloadAiPluginLexicalEditorFeature(),
|
|
117
124
|
]
|
|
118
125
|
},
|
|
119
126
|
}),
|
|
120
127
|
},
|
|
121
128
|
]
|
|
122
|
-
|
|
123
129
|
```
|
|
124
130
|
|
|
125
131
|
## ⚙️ Configuration
|
|
126
132
|
|
|
127
133
|
To get started, choose your preferred AI model by setting one or more of the following environment variables. Create a .env file in your project root and add any of the following keys:
|
|
134
|
+
|
|
128
135
|
```
|
|
129
136
|
OPENAI_API_KEY=your-openai-api-key
|
|
137
|
+
|
|
138
|
+
## OPENAI_ORG_ID is required if you use gpt-image-1 model
|
|
139
|
+
OPENAI_ORG_ID=your-org-id
|
|
140
|
+
|
|
130
141
|
ANTHROPIC_API_KEY=your-anthropic-api-key
|
|
131
142
|
ELEVENLABS_API_KEY=your-elevenlabs-api-key
|
|
132
143
|
```
|
|
@@ -136,9 +147,11 @@ ELEVENLABS_API_KEY=your-elevenlabs-api-key
|
|
|
136
147
|
### OpenAI Endpoint
|
|
137
148
|
|
|
138
149
|
If you want to use a custom endpoint for the OpenAI provider, set your base URL like this:
|
|
150
|
+
|
|
139
151
|
```
|
|
140
152
|
OPENAI_BASE_URL=https://api.openai.com/v1
|
|
141
153
|
```
|
|
154
|
+
|
|
142
155
|
If not specified, the [default](src/ai/models/openai/openai.ts) OpenAI endpoint will be used.
|
|
143
156
|
|
|
144
157
|
For detailed guidance on personalizing and configuring the plugin to match your needs, check out the **[Complete Guide](guide.md)**. It walks you through every step, from setting up fields to generating amazing content!
|
|
@@ -152,11 +165,10 @@ For detailed guidance on personalizing and configuring the plugin to match your
|
|
|
152
165
|
>
|
|
153
166
|
> To view AI enabled fields, enable the `debugging` flag in your plugin config or check your server startup logs.
|
|
154
167
|
|
|
155
|
-
|
|
156
168
|
## 👥 Contributing
|
|
157
169
|
|
|
158
|
-
Innovators: welcome! We're always excited to expand our community and hear fresh ideas. Whether you’re here to share feedback, suggest features, or contribute code, we’d love to have you on board.
|
|
170
|
+
Innovators: welcome! We're always excited to expand our community and hear fresh ideas. Whether you’re here to share feedback, suggest features, or contribute code, we’d love to have you on board.
|
|
159
171
|
|
|
160
|
-
Feel free to create a pull request with your ideas, improvements, or bug fixes. No contribution is too small, and every bit helps us grow!
|
|
172
|
+
Feel free to create a pull request with your ideas, improvements, or bug fixes. No contribution is too small, and every bit helps us grow!
|
|
161
173
|
|
|
162
|
-
Join the conversation on Payload's [Discord](https://discord.com/channels/967097582721572934/1264949995656843345) and let’s build something amazing together! 🚀✨
|
|
174
|
+
Join the conversation on Payload's [Discord](https://discord.com/channels/967097582721572934/1264949995656843345) and let’s build something amazing together! 🚀✨
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const generateRichText: (text: string, options: any) =>
|
|
1
|
+
export declare const generateRichText: (text: string, options: any) => Response;
|
|
2
2
|
//# sourceMappingURL=generateRichText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,SAAS,GAAG,aAiC1D,CAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { anthropic } from '@ai-sdk/anthropic';
|
|
2
2
|
import { jsonSchema, streamObject } from 'ai';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const streamResult = await streamObject({
|
|
3
|
+
export const generateRichText = (text, options)=>{
|
|
4
|
+
const streamResult = streamObject({
|
|
6
5
|
model: anthropic(options.model),
|
|
6
|
+
onError: (error)=>{
|
|
7
|
+
console.error(`generateRichText: `, error);
|
|
8
|
+
},
|
|
7
9
|
prompt: text,
|
|
8
10
|
schema: jsonSchema(options.editorSchema),
|
|
9
11
|
system: `${options.system}
|
|
@@ -23,9 +25,6 @@ RICH TEXT EDITOR TOOLS:
|
|
|
23
25
|
- Apply correct heading levels (h1, h2, h3) for hierarchical structure.
|
|
24
26
|
- Utilize bullet points or numbered lists as required by the layout.
|
|
25
27
|
|
|
26
|
-
SAMPLE OUTPUT OBJECT:
|
|
27
|
-
${JSON.stringify(exampleOutput)}
|
|
28
|
-
|
|
29
28
|
ADDITIONAL GUIDELINES:
|
|
30
29
|
- Ensure coherence and logical flow between all sections.
|
|
31
30
|
- Maintain a consistent tone and style throughout the content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { jsonSchema, streamObject } from 'ai'\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { jsonSchema, streamObject } from 'ai'\n\nexport const generateRichText = (text: string, options: any) => {\n const streamResult = streamObject({\n model: anthropic(options.model),\n onError: (error) => {\n console.error(`generateRichText: `, error)\n },\n prompt: text,\n schema: jsonSchema(options.editorSchema),\n system: `${options.system}\n\nRULES:\n- Generate original and unique content based on the given topic.\n- Strictly adhere to the specified layout and formatting instructions.\n- Utilize the provided rich text editor tools for appropriate formatting.\n- Ensure the output follows the structure of the sample output object.\n- Produce valid JSON with no undefined or null values.\n\nLAYOUT INSTRUCTIONS:\n${options.layout}\n\nRICH TEXT EDITOR TOOLS:\n- Use appropriate formatting tools such as bold, italic, or underline for emphasis where needed.\n- Apply correct heading levels (h1, h2, h3) for hierarchical structure.\n- Utilize bullet points or numbered lists as required by the layout.\n\nADDITIONAL GUIDELINES:\n- Ensure coherence and logical flow between all sections.\n- Maintain a consistent tone and style throughout the content.\n- Use clear and concise language appropriate for the target audience.\n- Double-check that all JSON fields are properly filled and formatted.`,\n })\n\n return streamResult.toTextStreamResponse()\n}\n"],"names":["anthropic","jsonSchema","streamObject","generateRichText","text","options","streamResult","model","onError","error","console","prompt","schema","editorSchema","system","layout","toTextStreamResponse"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,UAAU,EAAEC,YAAY,QAAQ,KAAI;AAE7C,OAAO,MAAMC,mBAAmB,CAACC,MAAcC;IAC7C,MAAMC,eAAeJ,aAAa;QAChCK,OAAOP,UAAUK,QAAQE,KAAK;QAC9BC,SAAS,CAACC;YACRC,QAAQD,KAAK,CAAC,CAAC,kBAAkB,CAAC,EAAEA;QACtC;QACAE,QAAQP;QACRQ,QAAQX,WAAWI,QAAQQ,YAAY;QACvCC,QAAQ,GAAGT,QAAQS,MAAM,CAAC;;;;;;;;;;AAU9B,EAAET,QAAQU,MAAM,CAAC;;;;;;;;;;;sEAWqD,CAAC;IACrE;IAEA,OAAOT,aAAaU,oBAAoB;AAC1C,EAAC"}
|
|
@@ -12,9 +12,12 @@ export const AnthropicConfig = {
|
|
|
12
12
|
'text',
|
|
13
13
|
'textarea'
|
|
14
14
|
],
|
|
15
|
-
handler:
|
|
16
|
-
const streamTextResult =
|
|
15
|
+
handler: (prompt, options)=>{
|
|
16
|
+
const streamTextResult = streamText({
|
|
17
17
|
model: anthropic(options.model),
|
|
18
|
+
onError: (error)=>{
|
|
19
|
+
console.error(`${MODEL_KEY}-text: `, error);
|
|
20
|
+
},
|
|
18
21
|
prompt,
|
|
19
22
|
system: options.system || defaultSystemPrompt
|
|
20
23
|
});
|
|
@@ -33,13 +36,13 @@ export const AnthropicConfig = {
|
|
|
33
36
|
{
|
|
34
37
|
name: 'model',
|
|
35
38
|
type: 'select',
|
|
36
|
-
defaultValue: 'claude-3-5-sonnet-
|
|
39
|
+
defaultValue: 'claude-3-5-sonnet-latest',
|
|
37
40
|
label: 'Model',
|
|
38
41
|
options: [
|
|
39
|
-
'claude-3-
|
|
40
|
-
'claude-3-
|
|
41
|
-
'claude-3-
|
|
42
|
-
'claude-3-
|
|
42
|
+
'claude-3-opus-latest',
|
|
43
|
+
'claude-3-5-haiku-latest',
|
|
44
|
+
'claude-3-5-sonnet-latest',
|
|
45
|
+
'claude-3-7-sonnet-latest'
|
|
43
46
|
]
|
|
44
47
|
}
|
|
45
48
|
],
|
|
@@ -68,13 +71,13 @@ export const AnthropicConfig = {
|
|
|
68
71
|
{
|
|
69
72
|
name: 'model',
|
|
70
73
|
type: 'select',
|
|
71
|
-
defaultValue: 'claude-3-5-sonnet-
|
|
74
|
+
defaultValue: 'claude-3-5-sonnet-latest',
|
|
72
75
|
label: 'Model',
|
|
73
76
|
options: [
|
|
74
|
-
'claude-3-
|
|
75
|
-
'claude-3-
|
|
76
|
-
'claude-3-
|
|
77
|
-
'claude-3-
|
|
77
|
+
'claude-3-opus-latest',
|
|
78
|
+
'claude-3-5-haiku-latest',
|
|
79
|
+
'claude-3-5-sonnet-latest',
|
|
80
|
+
'claude-3-7-sonnet-latest'
|
|
78
81
|
]
|
|
79
82
|
}
|
|
80
83
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/anthropic/index.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { defaultSystemPrompt } from '../../prompts.js'\nimport { generateRichText } from './generateRichText.js'\n\nconst MODEL_KEY = 'ANTH-C'\n\nexport const AnthropicConfig: GenerationConfig = {\n models: [\n {\n id: `${MODEL_KEY}-text`,\n name: 'Anthropic Claude',\n fields: ['text', 'textarea'],\n handler:
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/anthropic/index.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { defaultSystemPrompt } from '../../prompts.js'\nimport { generateRichText } from './generateRichText.js'\n\nconst MODEL_KEY = 'ANTH-C'\n\nexport const AnthropicConfig: GenerationConfig = {\n models: [\n {\n id: `${MODEL_KEY}-text`,\n name: 'Anthropic Claude',\n fields: ['text', 'textarea'],\n handler: (prompt: string, options: { locale: string; model: string; system: string }) => {\n const streamTextResult = streamText({\n model: anthropic(options.model),\n onError: (error) => {\n console.error(`${MODEL_KEY}-text: `, error)\n },\n prompt,\n system: options.system || defaultSystemPrompt,\n })\n\n return streamTextResult.toDataStreamResponse()\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: 'claude-3-5-sonnet-latest',\n label: 'Model',\n options: [\n 'claude-3-opus-latest',\n 'claude-3-5-haiku-latest',\n 'claude-3-5-sonnet-latest',\n 'claude-3-7-sonnet-latest',\n ],\n },\n ],\n label: 'Anthropic Claude Settings',\n },\n },\n {\n id: `${MODEL_KEY}-object`,\n name: 'Anthropic Claude',\n fields: ['richText'],\n handler: (text: string, options) => {\n return generateRichText(text, options)\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: 'claude-3-5-sonnet-latest',\n label: 'Model',\n options: [\n 'claude-3-opus-latest',\n 'claude-3-5-haiku-latest',\n 'claude-3-5-sonnet-latest',\n 'claude-3-7-sonnet-latest',\n ],\n },\n ],\n label: 'Anthropic Claude Settings',\n },\n },\n ],\n provider: 'Anthropic',\n}\n"],"names":["anthropic","streamText","defaultSystemPrompt","generateRichText","MODEL_KEY","AnthropicConfig","models","id","name","fields","handler","prompt","options","streamTextResult","model","onError","error","console","system","toDataStreamResponse","output","settings","type","admin","condition","data","defaultValue","label","text","provider"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,UAAU,QAAQ,KAAI;AAI/B,SAASC,mBAAmB,QAAQ,mBAAkB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,MAAMC,YAAY;AAElB,OAAO,MAAMC,kBAAoC;IAC/CC,QAAQ;QACN;YACEC,IAAI,GAAGH,UAAU,KAAK,CAAC;YACvBI,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,SAAS,CAACC,QAAgBC;gBACxB,MAAMC,mBAAmBZ,WAAW;oBAClCa,OAAOd,UAAUY,QAAQE,KAAK;oBAC9BC,SAAS,CAACC;wBACRC,QAAQD,KAAK,CAAC,GAAGZ,UAAU,OAAO,CAAC,EAAEY;oBACvC;oBACAL;oBACAO,QAAQN,QAAQM,MAAM,IAAIhB;gBAC5B;gBAEA,OAAOW,iBAAiBM,oBAAoB;YAC9C;YACAC,QAAQ;YACRC,UAAU;gBACRb,MAAM,GAAGJ,UAAU,cAAc,CAAC;gBAClCkB,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK,GAAGrB,UAAU,KAAK,CAAC;oBACjD;gBACF;gBACAK,QAAQ;oBACN;wBACED,MAAM;wBACNc,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPf,SAAS;4BACP;4BACA;4BACA;4BACA;yBACD;oBACH;iBACD;gBACDe,OAAO;YACT;QACF;QACA;YACEpB,IAAI,GAAGH,UAAU,OAAO,CAAC;YACzBI,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBC,SAAS,CAACkB,MAAchB;gBACtB,OAAOT,iBAAiByB,MAAMhB;YAChC;YACAQ,QAAQ;YACRC,UAAU;gBACRb,MAAM,GAAGJ,UAAU,gBAAgB,CAAC;gBACpCkB,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK,GAAGrB,UAAU,OAAO,CAAC;oBACnD;gBACF;gBACAK,QAAQ;oBACN;wBACED,MAAM;wBACNc,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPf,SAAS;4BACP;4BACA;4BACA;4BACA;yBACD;oBACH;iBACD;gBACDe,OAAO;YACT;QACF;KACD;IACDE,UAAU;AACZ,EAAC"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const generateImage: (prompt: string, { size, style, version, }?: {
|
|
3
|
-
size?: ImageGenerateParams["size"];
|
|
4
|
-
style?: ImageGenerateParams["style"];
|
|
5
|
-
version?: ImageGenerateParams["model"];
|
|
6
|
-
}) => Promise<{
|
|
1
|
+
import type { GenerateImageParams } from '../../../types.js';
|
|
2
|
+
export declare const generateImage: (prompt: string, { images, size, style, version, }?: GenerateImageParams) => Promise<{
|
|
7
3
|
alt: string;
|
|
8
4
|
buffer: Buffer<ArrayBuffer>;
|
|
9
5
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateImage.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateImage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateImage.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateImage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAI5D,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EACd,oCAKG,mBAAwB;;;EA4B5B,CAAA"}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
-
|
|
2
|
+
import { editImagesWithOpenAI } from '../../utils/editImagesWithOpenAI.js';
|
|
3
|
+
export const generateImage = async (prompt, { images = [], size = '1024x1024', style = 'natural', version = 'dall-e-3' } = {})=>{
|
|
3
4
|
const openaiAPI = new OpenAI();
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const options = {};
|
|
6
|
+
if (version?.startsWith('dall')) {
|
|
7
|
+
options['response_format'] = 'b64_json';
|
|
8
|
+
options['style'] = style;
|
|
9
|
+
}
|
|
10
|
+
let response;
|
|
11
|
+
if (images?.length) {
|
|
12
|
+
response = await editImagesWithOpenAI(images, prompt, version);
|
|
13
|
+
} else {
|
|
14
|
+
response = await openaiAPI.images.generate({
|
|
15
|
+
model: version,
|
|
16
|
+
n: 1,
|
|
17
|
+
prompt,
|
|
18
|
+
size,
|
|
19
|
+
...options
|
|
20
|
+
});
|
|
21
|
+
}
|
|
12
22
|
const { b64_json, revised_prompt } = response.data[0] || {};
|
|
13
23
|
return {
|
|
14
24
|
alt: revised_prompt,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/openai/generateImage.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/openai/generateImage.ts"],"sourcesContent":["import type { ImagesResponse } from 'openai/resources/images'\n\nimport OpenAI from 'openai'\n\nimport type { GenerateImageParams} from '../../../types.js';\n\nimport { editImagesWithOpenAI } from '../../utils/editImagesWithOpenAI.js'\n\nexport const generateImage = async (\n prompt: string,\n {\n images = [],\n size = '1024x1024',\n style = 'natural',\n version = 'dall-e-3',\n }: GenerateImageParams = {},\n) => {\n const openaiAPI = new OpenAI()\n\n const options = {}\n if (version?.startsWith('dall')) {\n options['response_format'] = 'b64_json'\n options['style'] = style\n }\n\n let response: ImagesResponse\n if (images?.length) {\n response = await editImagesWithOpenAI(images, prompt, version)\n } else {\n response = await openaiAPI.images.generate({\n model: version,\n n: 1,\n prompt,\n size,\n ...options,\n })\n }\n\n const { b64_json, revised_prompt } = response.data[0] || {}\n return {\n alt: revised_prompt,\n buffer: Buffer.from(b64_json, 'base64'),\n }\n}\n"],"names":["OpenAI","editImagesWithOpenAI","generateImage","prompt","images","size","style","version","openaiAPI","options","startsWith","response","length","generate","model","n","b64_json","revised_prompt","data","alt","buffer","Buffer","from"],"mappings":"AAEA,OAAOA,YAAY,SAAQ;AAI3B,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E,OAAO,MAAMC,gBAAgB,OAC3BC,QACA,EACEC,SAAS,EAAE,EACXC,OAAO,WAAW,EAClBC,QAAQ,SAAS,EACjBC,UAAU,UAAU,EACA,GAAG,CAAC,CAAC;IAE3B,MAAMC,YAAY,IAAIR;IAEtB,MAAMS,UAAU,CAAC;IACjB,IAAIF,SAASG,WAAW,SAAS;QAC/BD,OAAO,CAAC,kBAAkB,GAAG;QAC7BA,OAAO,CAAC,QAAQ,GAAGH;IACrB;IAEA,IAAIK;IACJ,IAAIP,QAAQQ,QAAQ;QAClBD,WAAW,MAAMV,qBAAqBG,QAAQD,QAAQI;IACxD,OAAO;QACLI,WAAW,MAAMH,UAAUJ,MAAM,CAACS,QAAQ,CAAC;YACzCC,OAAOP;YACPQ,GAAG;YACHZ;YACAE;YACA,GAAGI,OAAO;QACZ;IACF;IAEA,MAAM,EAAEO,QAAQ,EAAEC,cAAc,EAAE,GAAGN,SAASO,IAAI,CAAC,EAAE,IAAI,CAAC;IAC1D,OAAO;QACLC,KAAKF;QACLG,QAAQC,OAAOC,IAAI,CAACN,UAAU;IAChC;AACF,EAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const generateRichText: (text: string, options?: any) =>
|
|
1
|
+
export declare const generateRichText: (text: string, options?: any) => Response;
|
|
2
2
|
//# sourceMappingURL=generateRichText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateRichText.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateRichText.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,UAAS,GAAQ,aAmC/D,CAAA"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { jsonSchema, streamObject } from 'ai';
|
|
2
2
|
import { openai } from './openai.js';
|
|
3
|
-
export const generateRichText =
|
|
4
|
-
|
|
5
|
-
const streamResult = await streamObject({
|
|
3
|
+
export const generateRichText = (text, options = {})=>{
|
|
4
|
+
const streamResult = streamObject({
|
|
6
5
|
maxTokens: options.maxTokens || 5000,
|
|
7
6
|
model: openai(options.model, {
|
|
8
7
|
structuredOutputs: true
|
|
9
8
|
}),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
onError: (error)=>{
|
|
10
|
+
console.error(`generateRichText: `, error);
|
|
11
|
+
},
|
|
13
12
|
prompt: text,
|
|
14
13
|
schema: jsonSchema(options.editorSchema),
|
|
15
14
|
system: `${options.system}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import { jsonSchema, streamObject } from 'ai'\n\nimport { openai } from './openai.js'\n\nexport const generateRichText =
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import { jsonSchema, streamObject } from 'ai'\n\nimport { openai } from './openai.js'\n\nexport const generateRichText = (text: string, options: any = {}) => {\n const streamResult = streamObject({\n maxTokens: options.maxTokens || 5000,\n model: openai(options.model, {\n structuredOutputs: true,\n }),\n onError: (error) => {\n console.error(`generateRichText: `, error)\n },\n prompt: text,\n schema: jsonSchema(options.editorSchema),\n system: `${options.system}\n\nRULES:\n- Generate original and unique content based on the given topic.\n- Strictly adhere to the specified layout and formatting instructions.\n- Utilize the provided rich text editor tools for appropriate formatting.\n- Ensure the output follows the structure of the sample output object.\n- Produce valid JSON with no undefined or null values.\n\nLAYOUT INSTRUCTIONS:\n${options.layout}\n\nRICH TEXT EDITOR TOOLS:\n- Use appropriate formatting tools such as bold, italic, or underline for emphasis where needed.\n- Apply correct heading levels (h1, h2, h3) for hierarchical structure.\n- Utilize bullet points or numbered lists as required by the layout.\n\nADDITIONAL GUIDELINES:\n- Ensure coherence and logical flow between all sections.\n- Maintain a consistent tone and style throughout the content.\n- Use clear and concise language appropriate for the target audience.\n`,\n })\n return streamResult.toTextStreamResponse()\n}\n"],"names":["jsonSchema","streamObject","openai","generateRichText","text","options","streamResult","maxTokens","model","structuredOutputs","onError","error","console","prompt","schema","editorSchema","system","layout","toTextStreamResponse"],"mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,QAAQ,KAAI;AAE7C,SAASC,MAAM,QAAQ,cAAa;AAEpC,OAAO,MAAMC,mBAAmB,CAACC,MAAcC,UAAe,CAAC,CAAC;IAC9D,MAAMC,eAAeL,aAAa;QAChCM,WAAWF,QAAQE,SAAS,IAAI;QAChCC,OAAON,OAAOG,QAAQG,KAAK,EAAE;YAC3BC,mBAAmB;QACrB;QACAC,SAAS,CAACC;YACRC,QAAQD,KAAK,CAAC,CAAC,kBAAkB,CAAC,EAAEA;QACtC;QACAE,QAAQT;QACRU,QAAQd,WAAWK,QAAQU,YAAY;QACvCC,QAAQ,GAAGX,QAAQW,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEX,QAAQY,MAAM,CAAC;;;;;;;;;;;AAWjB,CAAC;IACC;IACA,OAAOX,aAAaY,oBAAoB;AAC1C,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAYzD,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAYzD,eAAO,MAAM,YAAY,EAAE,gBA4S1B,CAAA"}
|
|
@@ -16,9 +16,16 @@ export const OpenAIConfig = {
|
|
|
16
16
|
'text',
|
|
17
17
|
'textarea'
|
|
18
18
|
],
|
|
19
|
-
handler:
|
|
20
|
-
const streamTextResult =
|
|
19
|
+
handler: (prompt, options)=>{
|
|
20
|
+
const streamTextResult = streamText({
|
|
21
21
|
model: openai(options.model),
|
|
22
|
+
onError: (error)=>{
|
|
23
|
+
console.error(`${MODEL_KEY}-text: `, error);
|
|
24
|
+
},
|
|
25
|
+
// TODO: Implement billing/token consumption
|
|
26
|
+
// onFinish: (stepResult) => {
|
|
27
|
+
// console.log('streamText : finish : ', stepResult)
|
|
28
|
+
// },
|
|
22
29
|
prompt,
|
|
23
30
|
system: options.system || defaultSystemPrompt
|
|
24
31
|
});
|
|
@@ -127,6 +134,127 @@ export const OpenAIConfig = {
|
|
|
127
134
|
label: 'OpenAI DALL-E Settings'
|
|
128
135
|
}
|
|
129
136
|
},
|
|
137
|
+
{
|
|
138
|
+
id: 'gpt-image-1',
|
|
139
|
+
name: 'OpenAI GPT Image 1',
|
|
140
|
+
fields: [
|
|
141
|
+
'upload'
|
|
142
|
+
],
|
|
143
|
+
handler: async (prompt, options)=>{
|
|
144
|
+
const imageData = await generateImage(prompt, options);
|
|
145
|
+
return {
|
|
146
|
+
data: {
|
|
147
|
+
alt: imageData.alt
|
|
148
|
+
},
|
|
149
|
+
file: {
|
|
150
|
+
name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.png`,
|
|
151
|
+
data: imageData.buffer,
|
|
152
|
+
mimetype: 'image/png',
|
|
153
|
+
size: imageData.buffer.byteLength
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
output: 'image',
|
|
158
|
+
settings: {
|
|
159
|
+
name: 'gpt-image-1-settings',
|
|
160
|
+
type: 'group',
|
|
161
|
+
admin: {
|
|
162
|
+
condition (data) {
|
|
163
|
+
return data['model-id'] === 'gpt-image-1';
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
fields: [
|
|
167
|
+
{
|
|
168
|
+
name: 'version',
|
|
169
|
+
type: 'select',
|
|
170
|
+
defaultValue: 'gpt-image-1',
|
|
171
|
+
label: 'Version',
|
|
172
|
+
options: [
|
|
173
|
+
'gpt-image-1'
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
type: 'row',
|
|
178
|
+
fields: [
|
|
179
|
+
{
|
|
180
|
+
name: 'size',
|
|
181
|
+
type: 'select',
|
|
182
|
+
defaultValue: 'auto',
|
|
183
|
+
label: 'Size',
|
|
184
|
+
options: [
|
|
185
|
+
'1024x1024',
|
|
186
|
+
'1024x1536',
|
|
187
|
+
'1536x1024',
|
|
188
|
+
'auto'
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'quality',
|
|
193
|
+
type: 'select',
|
|
194
|
+
defaultValue: 'auto',
|
|
195
|
+
label: 'Quality',
|
|
196
|
+
options: [
|
|
197
|
+
'low',
|
|
198
|
+
'medium',
|
|
199
|
+
'high',
|
|
200
|
+
'auto'
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'output_format',
|
|
207
|
+
type: 'select',
|
|
208
|
+
defaultValue: 'png',
|
|
209
|
+
label: 'Output Format',
|
|
210
|
+
options: [
|
|
211
|
+
'png',
|
|
212
|
+
'jpeg',
|
|
213
|
+
'webp'
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: 'output_compression',
|
|
218
|
+
type: 'number',
|
|
219
|
+
admin: {
|
|
220
|
+
condition (data) {
|
|
221
|
+
return data.output_format === 'jpeg' || data.output_format === 'webp';
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
defaultValue: 100,
|
|
225
|
+
label: 'Output Compression',
|
|
226
|
+
max: 100,
|
|
227
|
+
min: 0
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'background',
|
|
231
|
+
type: 'select',
|
|
232
|
+
admin: {
|
|
233
|
+
condition (data) {
|
|
234
|
+
return data.output_format === 'png' || data.output_format === 'webp';
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
defaultValue: 'white',
|
|
238
|
+
label: 'Background',
|
|
239
|
+
options: [
|
|
240
|
+
'white',
|
|
241
|
+
'transparent'
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'moderation',
|
|
246
|
+
type: 'select',
|
|
247
|
+
defaultValue: 'auto',
|
|
248
|
+
label: 'Moderation',
|
|
249
|
+
options: [
|
|
250
|
+
'auto',
|
|
251
|
+
'low'
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
label: 'OpenAI GPT Image 1 Settings'
|
|
256
|
+
}
|
|
257
|
+
},
|
|
130
258
|
{
|
|
131
259
|
id: 'tts',
|
|
132
260
|
name: 'OpenAI Text-to-Speech',
|
|
@@ -230,13 +358,14 @@ export const OpenAIConfig = {
|
|
|
230
358
|
{
|
|
231
359
|
name: 'model',
|
|
232
360
|
type: 'select',
|
|
233
|
-
defaultValue: 'gpt-4o
|
|
361
|
+
defaultValue: 'gpt-4o',
|
|
234
362
|
label: 'Model',
|
|
235
363
|
options: [
|
|
236
364
|
'gpt-4o',
|
|
237
365
|
'gpt-4-turbo',
|
|
238
366
|
'gpt-4o-mini',
|
|
239
|
-
'gpt-
|
|
367
|
+
'gpt-4.1',
|
|
368
|
+
'o4-mini'
|
|
240
369
|
]
|
|
241
370
|
}
|
|
242
371
|
],
|
|
@@ -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 { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { defaultSystemPrompt } from '../../prompts.js'\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\nimport { openai } from './openai.js'\n\nconst MODEL_KEY = 'Oai'\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: async (\n prompt: string,\n options: { locale: string; model: string; system: string },\n ) => {\n const streamTextResult = await streamText({\n model: openai(options.model),\n prompt,\n system: options.system || defaultSystemPrompt,\n })\n\n return streamTextResult.toDataStreamResponse()\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: ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-3.5-turbo'],\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: '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 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'] as Array<\n SpeechCreateParams['response_format']\n >,\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 generateRichText(text, options)\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-2024-08-06',\n label: 'Model',\n options: ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-4o-2024-08-06'],\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["streamText","defaultSystemPrompt","generateFileNameByPrompt","generateImage","generateRichText","generateVoice","openai","MODEL_KEY","OpenAIConfig","models","id","name","fields","handler","prompt","options","streamTextResult","model","system","toDataStreamResponse","output","settings","type","admin","condition","data","defaultValue","label","imageData","alt","file","buffer","mimetype","size","byteLength","text","voiceData","max","min","provider"],"mappings":"AAGA,SAASA,UAAU,QAAQ,KAAI;AAI/B,SAASC,mBAAmB,QAAQ,mBAAkB;AACtD,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,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Q;4BAAQ;yBAAU;oBAGhE;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAS;yBAAW;oBAChC;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAO;4BAAQ;4BAAO;4BAAQ;4BAAO;yBAAM;oBAGvD;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPU,KAAK;wBACLC,KAAK;oBACP;iBACD;gBACDX,OAAO;YACT;QACF;QACA;YACEjB,IAAI,GAAGH,UAAU,OAAO,CAAC;YACzBI,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBC,SAAS,CAACsB,MAAcpB;gBACtB,OAAOX,iBAAiB+B,MAAMpB;YAChC;YACAK,QAAQ;YACRC,UAAU;gBACRV,MAAM,GAAGJ,UAAU,gBAAgB,CAAC;gBACpCe,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK,GAAGlB,UAAU,OAAO,CAAC;oBACnD;gBACF;gBACAK,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAoB;oBACxE;iBACD;gBACDY,OAAO;YACT;QACF;KACD;IACDY,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 { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { defaultSystemPrompt } from '../../prompts.js'\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\nimport { openai } from './openai.js'\n\nconst MODEL_KEY = 'Oai'\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: (prompt: string, options: { locale: string; model: string; system: string }) => {\n const streamTextResult = streamText({\n model: openai(options.model),\n onError: (error) => {\n console.error(`${MODEL_KEY}-text: `, error)\n },\n\n // TODO: Implement billing/token consumption\n // onFinish: (stepResult) => {\n // console.log('streamText : finish : ', stepResult)\n // },\n prompt,\n system: options.system || defaultSystemPrompt,\n })\n\n return streamTextResult.toDataStreamResponse()\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: ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-3.5-turbo'],\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 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'] as Array<\n SpeechCreateParams['response_format']\n >,\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 generateRichText(text, options)\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: ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-4.1', 'o4-mini'],\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["streamText","defaultSystemPrompt","generateFileNameByPrompt","generateImage","generateRichText","generateVoice","openai","MODEL_KEY","OpenAIConfig","models","id","name","fields","handler","prompt","options","streamTextResult","model","onError","error","console","system","toDataStreamResponse","output","settings","type","admin","condition","data","defaultValue","label","imageData","alt","file","buffer","mimetype","size","byteLength","output_format","max","min","text","voiceData","provider"],"mappings":"AAGA,SAASA,UAAU,QAAQ,KAAI;AAI/B,SAASC,mBAAmB,QAAQ,mBAAkB;AACtD,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AAEpC,MAAMC,YAAY;AAElB,6FAA6F;AAC7F,OAAO,MAAMC,eAAiC;IAC5CC,QAAQ;QACN;YACEC,IAAI,GAAGH,UAAU,KAAK,CAAC;YACvBI,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,SAAS,CAACC,QAAgBC;gBACxB,MAAMC,mBAAmBhB,WAAW;oBAClCiB,OAAOX,OAAOS,QAAQE,KAAK;oBAC3BC,SAAS,CAACC;wBACRC,QAAQD,KAAK,CAAC,GAAGZ,UAAU,OAAO,CAAC,EAAEY;oBACvC;oBAEA,4CAA4C;oBAC5C,8BAA8B;oBAC9B,sDAAsD;oBACtD,KAAK;oBACLL;oBACAO,QAAQN,QAAQM,MAAM,IAAIpB;gBAC5B;gBAEA,OAAOe,iBAAiBM,oBAAoB;YAC9C;YACAC,QAAQ;YACRC,UAAU;gBACRb,MAAM,GAAGJ,UAAU,cAAc,CAAC;gBAClCkB,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK,GAAGrB,UAAU,KAAK,CAAC;oBACjD;gBACF;gBACAK,QAAQ;oBAC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