@ai-stack/payloadcms 3.0.0-beta.104
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/LICENSE.md +21 -0
- package/README.md +137 -0
- package/dist/ai/analyse.d.ts +2 -0
- package/dist/ai/analyse.d.ts.map +1 -0
- package/dist/ai/analyse.js +3 -0
- package/dist/ai/analyse.js.map +1 -0
- package/dist/ai/models/anthropic/generateRichText.d.ts +2 -0
- package/dist/ai/models/anthropic/generateRichText.d.ts.map +1 -0
- package/dist/ai/models/anthropic/generateRichText.js +38 -0
- package/dist/ai/models/anthropic/generateRichText.js.map +1 -0
- package/dist/ai/models/anthropic/index.d.ts +3 -0
- package/dist/ai/models/anthropic/index.d.ts.map +1 -0
- package/dist/ai/models/anthropic/index.js +112 -0
- package/dist/ai/models/anthropic/index.js.map +1 -0
- package/dist/ai/models/elevenLabs/generateVoice.d.ts +10 -0
- package/dist/ai/models/elevenLabs/generateVoice.d.ts.map +1 -0
- package/dist/ai/models/elevenLabs/generateVoice.js +20 -0
- package/dist/ai/models/elevenLabs/generateVoice.js.map +1 -0
- package/dist/ai/models/elevenLabs/index.d.ts +3 -0
- package/dist/ai/models/elevenLabs/index.d.ts.map +1 -0
- package/dist/ai/models/elevenLabs/index.js +129 -0
- package/dist/ai/models/elevenLabs/index.js.map +1 -0
- package/dist/ai/models/elevenLabs/voices.d.ts +4 -0
- package/dist/ai/models/elevenLabs/voices.d.ts.map +1 -0
- package/dist/ai/models/elevenLabs/voices.js +24 -0
- package/dist/ai/models/elevenLabs/voices.js.map +1 -0
- package/dist/ai/models/example-prompt-rich-text.md +47 -0
- package/dist/ai/models/example.d.ts +73 -0
- package/dist/ai/models/example.d.ts.map +1 -0
- package/dist/ai/models/example.js +126 -0
- package/dist/ai/models/example.js.map +1 -0
- package/dist/ai/models/index.d.ts +3 -0
- package/dist/ai/models/index.d.ts.map +1 -0
- package/dist/ai/models/index.js +11 -0
- package/dist/ai/models/index.js.map +1 -0
- package/dist/ai/models/openai/generateImage.d.ts +10 -0
- package/dist/ai/models/openai/generateImage.d.ts.map +1 -0
- package/dist/ai/models/openai/generateImage.js +20 -0
- package/dist/ai/models/openai/generateImage.js.map +1 -0
- package/dist/ai/models/openai/generateRichText.d.ts +2 -0
- package/dist/ai/models/openai/generateRichText.d.ts.map +1 -0
- package/dist/ai/models/openai/generateRichText.js +38 -0
- package/dist/ai/models/openai/generateRichText.js.map +1 -0
- package/dist/ai/models/openai/generateVoice.d.ts +7 -0
- package/dist/ai/models/openai/generateVoice.d.ts.map +1 -0
- package/dist/ai/models/openai/generateVoice.js +19 -0
- package/dist/ai/models/openai/generateVoice.js.map +1 -0
- package/dist/ai/models/openai/index.d.ts +3 -0
- package/dist/ai/models/openai/index.d.ts.map +1 -0
- package/dist/ai/models/openai/index.js +276 -0
- package/dist/ai/models/openai/index.js.map +1 -0
- package/dist/ai/prompts.d.ts +25 -0
- package/dist/ai/prompts.d.ts.map +1 -0
- package/dist/ai/prompts.js +214 -0
- package/dist/ai/prompts.js.map +1 -0
- package/dist/ai/schemas/lexical.schema.d.ts +31 -0
- package/dist/ai/schemas/lexical.schema.d.ts.map +1 -0
- package/dist/ai/schemas/lexical.schema.js +102 -0
- package/dist/ai/schemas/lexical.schema.js.map +1 -0
- package/dist/ai/utils/generateFileNameByPrompt.d.ts +2 -0
- package/dist/ai/utils/generateFileNameByPrompt.d.ts.map +1 -0
- package/dist/ai/utils/generateFileNameByPrompt.js +21 -0
- package/dist/ai/utils/generateFileNameByPrompt.js.map +1 -0
- package/dist/ai/utils/generateSeedPrompt.d.ts +5 -0
- package/dist/ai/utils/generateSeedPrompt.d.ts.map +1 -0
- package/dist/ai/utils/generateSeedPrompt.js +23 -0
- package/dist/ai/utils/generateSeedPrompt.js.map +1 -0
- package/dist/collections/Instructions.d.ts +3 -0
- package/dist/collections/Instructions.d.ts.map +1 -0
- package/dist/collections/Instructions.js +109 -0
- package/dist/collections/Instructions.js.map +1 -0
- package/dist/defaults.d.ts +10 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +13 -0
- package/dist/defaults.js.map +1 -0
- package/dist/endpoints/index.d.ts +3 -0
- package/dist/endpoints/index.d.ts.map +1 -0
- package/dist/endpoints/index.js +141 -0
- package/dist/endpoints/index.js.map +1 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +4 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/fields.d.ts +4 -0
- package/dist/exports/fields.d.ts.map +1 -0
- package/dist/exports/fields.js +5 -0
- package/dist/exports/fields.js.map +1 -0
- package/dist/exports/types.d.ts +3 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +3 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/fields/ComposeField/ComposeField.d.ts +4 -0
- package/dist/fields/ComposeField/ComposeField.d.ts.map +1 -0
- package/dist/fields/ComposeField/ComposeField.js +18 -0
- package/dist/fields/ComposeField/ComposeField.js.map +1 -0
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts +2 -0
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts.map +1 -0
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.js +15 -0
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.js.map +1 -0
- package/dist/fields/LexicalEditor/feature.client.d.ts +2 -0
- package/dist/fields/LexicalEditor/feature.client.d.ts.map +1 -0
- package/dist/fields/LexicalEditor/feature.client.js +13 -0
- package/dist/fields/LexicalEditor/feature.client.js.map +1 -0
- package/dist/fields/LexicalEditor/feature.server.d.ts +2 -0
- package/dist/fields/LexicalEditor/feature.server.d.ts.map +1 -0
- package/dist/fields/LexicalEditor/feature.server.js +12 -0
- package/dist/fields/LexicalEditor/feature.server.js.map +1 -0
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts +4 -0
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -0
- package/dist/fields/PromptEditorField/PromptEditorField.js +41 -0
- package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -0
- package/dist/fields/SelectField/SelectField.d.ts +10 -0
- package/dist/fields/SelectField/SelectField.d.ts.map +1 -0
- package/dist/fields/SelectField/SelectField.js +41 -0
- package/dist/fields/SelectField/SelectField.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +4 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +81 -0
- package/dist/init.js.map +1 -0
- package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts +8 -0
- package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts.map +1 -0
- package/dist/libraries/autocomplete/AutocompleteTextArea.js +437 -0
- package/dist/libraries/autocomplete/AutocompleteTextArea.js.map +1 -0
- package/dist/libraries/autocomplete/AutocompleteTextArea.module.scss +35 -0
- package/dist/libraries/handlebars/asyncHandlebars.d.ts +2 -0
- package/dist/libraries/handlebars/asyncHandlebars.d.ts.map +1 -0
- package/dist/libraries/handlebars/asyncHandlebars.js +5 -0
- package/dist/libraries/handlebars/asyncHandlebars.js.map +1 -0
- package/dist/libraries/handlebars/helpers.d.ts +2 -0
- package/dist/libraries/handlebars/helpers.d.ts.map +1 -0
- package/dist/libraries/handlebars/helpers.js +22 -0
- package/dist/libraries/handlebars/helpers.js.map +1 -0
- package/dist/libraries/handlebars/helpersMap.d.ts +12 -0
- package/dist/libraries/handlebars/helpersMap.d.ts.map +1 -0
- package/dist/libraries/handlebars/helpersMap.js +13 -0
- package/dist/libraries/handlebars/helpersMap.js.map +1 -0
- package/dist/libraries/handlebars/replacePlaceholders.d.ts +2 -0
- package/dist/libraries/handlebars/replacePlaceholders.d.ts.map +1 -0
- package/dist/libraries/handlebars/replacePlaceholders.js +8 -0
- package/dist/libraries/handlebars/replacePlaceholders.js.map +1 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +121 -0
- package/dist/plugin.js.map +1 -0
- package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts +6 -0
- package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts.map +1 -0
- package/dist/providers/InstructionsProvider/InstructionsProvider.js +31 -0
- package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -0
- package/dist/providers/InstructionsProvider/useInstructions.d.ts +4 -0
- package/dist/providers/InstructionsProvider/useInstructions.d.ts.map +1 -0
- package/dist/providers/InstructionsProvider/useInstructions.js +38 -0
- package/dist/providers/InstructionsProvider/useInstructions.js.map +1 -0
- package/dist/styles.d.js +2 -0
- package/dist/styles.d.js.map +1 -0
- package/dist/translations/en.json +4 -0
- package/dist/translations/es.json +4 -0
- package/dist/translations/fa.json +4 -0
- package/dist/translations/fr.json +4 -0
- package/dist/translations/index.d.ts +38 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +36 -0
- package/dist/translations/index.js.map +1 -0
- package/dist/translations/pl.json +4 -0
- package/dist/translations/ru.json +4 -0
- package/dist/translations/translation-schema.json +16 -0
- package/dist/translations/uk.json +4 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/Compose/Compose.d.ts +9 -0
- package/dist/ui/Compose/Compose.d.ts.map +1 -0
- package/dist/ui/Compose/Compose.js +176 -0
- package/dist/ui/Compose/Compose.js.map +1 -0
- package/dist/ui/Compose/UndoRedoActions.d.ts +4 -0
- package/dist/ui/Compose/UndoRedoActions.d.ts.map +1 -0
- package/dist/ui/Compose/UndoRedoActions.js +56 -0
- package/dist/ui/Compose/UndoRedoActions.js.map +1 -0
- package/dist/ui/Compose/compose.module.scss +19 -0
- package/dist/ui/Compose/hooks/menu/Item.d.ts +5 -0
- package/dist/ui/Compose/hooks/menu/Item.d.ts.map +1 -0
- package/dist/ui/Compose/hooks/menu/Item.js +32 -0
- package/dist/ui/Compose/hooks/menu/Item.js.map +1 -0
- package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts +4 -0
- package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts.map +1 -0
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js +78 -0
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -0
- package/dist/ui/Compose/hooks/menu/items.d.ts +9 -0
- package/dist/ui/Compose/hooks/menu/items.d.ts.map +1 -0
- package/dist/ui/Compose/hooks/menu/items.js +12 -0
- package/dist/ui/Compose/hooks/menu/items.js.map +1 -0
- package/dist/ui/Compose/hooks/menu/itemsMap.d.ts +11 -0
- package/dist/ui/Compose/hooks/menu/itemsMap.d.ts.map +1 -0
- package/dist/ui/Compose/hooks/menu/itemsMap.js +68 -0
- package/dist/ui/Compose/hooks/menu/itemsMap.js.map +1 -0
- package/dist/ui/Compose/hooks/menu/menu.module.scss +109 -0
- package/dist/ui/Compose/hooks/menu/useMenu.d.ts +11 -0
- package/dist/ui/Compose/hooks/menu/useMenu.d.ts.map +1 -0
- package/dist/ui/Compose/hooks/menu/useMenu.js +93 -0
- package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -0
- package/dist/ui/Compose/hooks/useGenerate.d.ts +11 -0
- package/dist/ui/Compose/hooks/useGenerate.d.ts.map +1 -0
- package/dist/ui/Compose/hooks/useGenerate.js +175 -0
- package/dist/ui/Compose/hooks/useGenerate.js.map +1 -0
- package/dist/ui/Compose/hooks/useHistory.d.ts +9 -0
- package/dist/ui/Compose/hooks/useHistory.d.ts.map +1 -0
- package/dist/ui/Compose/hooks/useHistory.js +171 -0
- package/dist/ui/Compose/hooks/useHistory.js.map +1 -0
- package/dist/ui/Icons/Icons.d.ts +45 -0
- package/dist/ui/Icons/Icons.d.ts.map +1 -0
- package/dist/ui/Icons/Icons.js +154 -0
- package/dist/ui/Icons/Icons.js.map +1 -0
- package/dist/ui/Icons/LottieAnimation.d.ts +5 -0
- package/dist/ui/Icons/LottieAnimation.d.ts.map +1 -0
- package/dist/ui/Icons/LottieAnimation.js +100 -0
- package/dist/ui/Icons/LottieAnimation.js.map +1 -0
- package/dist/ui/Icons/icons.module.css +26 -0
- package/dist/utilities/getFieldBySchemaPath.d.ts +3 -0
- package/dist/utilities/getFieldBySchemaPath.d.ts.map +1 -0
- package/dist/utilities/getFieldBySchemaPath.js +37 -0
- package/dist/utilities/getFieldBySchemaPath.js.map +1 -0
- package/dist/utilities/getFieldInfo.d.ts +3 -0
- package/dist/utilities/getFieldInfo.d.ts.map +1 -0
- package/dist/utilities/getFieldInfo.js +14 -0
- package/dist/utilities/getFieldInfo.js.map +1 -0
- package/dist/utilities/isPluginActivated.d.ts +2 -0
- package/dist/utilities/isPluginActivated.d.ts.map +1 -0
- package/dist/utilities/isPluginActivated.js +5 -0
- package/dist/utilities/isPluginActivated.js.map +1 -0
- package/dist/utilities/jsonToZod.d.ts +3 -0
- package/dist/utilities/jsonToZod.d.ts.map +1 -0
- package/dist/utilities/jsonToZod.js +33 -0
- package/dist/utilities/jsonToZod.js.map +1 -0
- package/dist/utilities/lexicalToHTML.d.ts +4 -0
- package/dist/utilities/lexicalToHTML.d.ts.map +1 -0
- package/dist/utilities/lexicalToHTML.js +11 -0
- package/dist/utilities/lexicalToHTML.js.map +1 -0
- package/dist/utilities/setSafeLexicalState.d.ts +5 -0
- package/dist/utilities/setSafeLexicalState.d.ts.map +1 -0
- package/dist/utilities/setSafeLexicalState.js +20 -0
- package/dist/utilities/setSafeLexicalState.js.map +1 -0
- package/dist/utilities/updateFieldsConfig.d.ts +8 -0
- package/dist/utilities/updateFieldsConfig.d.ts.map +1 -0
- package/dist/utilities/updateFieldsConfig.js +89 -0
- package/dist/utilities/updateFieldsConfig.js.map +1 -0
- package/package.json +124 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ashish Mishra
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Payload AI Plugin
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img alt="Payload AI Plugin" src="assets/payloadcms-ai.gif" width="100%" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
## 🌟 Supercharge Your [Payload CMS](https://payloadcms.com) with AI-Powered Content Creation
|
|
8
|
+
|
|
9
|
+
The Payload AI Plugin is an advanced extension that integrates modern AI capabilities into your Payload CMS, streamlining content creation and management.
|
|
10
|
+
|
|
11
|
+
> **⚠️ Important:** This plugin is in active development. We're doing our best to improve its features and functionality. Please be prepared for regular updates; at the moment, the plugin has only been tested with Payload version v3.0.0-beta.104.
|
|
12
|
+
>
|
|
13
|
+
> To give it a try, we recommend using [Payload's website template](https://github.com/payloadcms/payload/tree/v3.0.0-beta.104/templates/website).
|
|
14
|
+
|
|
15
|
+
### 🎥 [Watch the Magic in Action](https://youtu.be/qaYukeGpuu4)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## ✨ Supported Fields and Features
|
|
19
|
+
|
|
20
|
+
### Text and RichText Field
|
|
21
|
+
- 📝 **Text Generation**
|
|
22
|
+
- [x] **Compose** masterpieces effortlessly
|
|
23
|
+
- [x] **Proofread** with precision (Beta)
|
|
24
|
+
- [x] **Translate** across languages
|
|
25
|
+
- [ ] **Expand** your ideas
|
|
26
|
+
- [ ] **Summarize** with clarity
|
|
27
|
+
- [ ] **Simplify** complex concepts
|
|
28
|
+
- [x] **Rephrase** for maximum impact (Beta)
|
|
29
|
+
|
|
30
|
+
### Upload Field
|
|
31
|
+
- 🎙️ **Voice Generation** powered by ElevenLabs, OpenAI
|
|
32
|
+
- 🖼️ **Image Generation** powered by OpenAI
|
|
33
|
+
|
|
34
|
+
### Other Features
|
|
35
|
+
- 🎛️ **Field-level Prompt Customization**
|
|
36
|
+
- 🧠 **Prompt Editor** (Beta)
|
|
37
|
+
- 📊 **Document Analyzer** (Coming Soon)
|
|
38
|
+
- ✅ **Fact Checking** (Coming Soon)
|
|
39
|
+
- 🔄 **Automated Content Workflows** (Coming Soon)
|
|
40
|
+
- 🌍 **Internationalization Support** (Coming Soon)
|
|
41
|
+
- 🌍 **Editor AI suggestions** (Coming Soon)
|
|
42
|
+
- 💬 **AI Chat Support** (Coming Soon)
|
|
43
|
+
|
|
44
|
+
## 📚 Table of Contents
|
|
45
|
+
|
|
46
|
+
- [Installation](#-installation)
|
|
47
|
+
- [Usage](#-usage)
|
|
48
|
+
- [Configuration](#%EF%B8%8F-configuration)
|
|
49
|
+
- [Contributing](#-contributing)
|
|
50
|
+
- [License](#licensing)
|
|
51
|
+
|
|
52
|
+
## 📦 Installation
|
|
53
|
+
|
|
54
|
+
Rock your Payload project with a single command:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pnpm add @ai-stack/payloadcms
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 🛠 Usage
|
|
61
|
+
|
|
62
|
+
Config with ease:
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
|
|
66
|
+
// Add below in payload.config.ts
|
|
67
|
+
import { buildConfig } from 'payload/config';
|
|
68
|
+
import { payloadAiPlugin } from '@ai-stack/payloadcms';
|
|
69
|
+
|
|
70
|
+
export default buildConfig({
|
|
71
|
+
plugins: [
|
|
72
|
+
payloadAiPlugin({
|
|
73
|
+
collections: {
|
|
74
|
+
[Posts.slug]: true,
|
|
75
|
+
},
|
|
76
|
+
debugging: false,
|
|
77
|
+
}),
|
|
78
|
+
],
|
|
79
|
+
// ... your existing Payload configuration
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
// Add below in Lexical Editor field config
|
|
84
|
+
import { PayloadAiPluginLexicalEditorFeature } from '@ai-stack/payloadcms'
|
|
85
|
+
|
|
86
|
+
fields: [
|
|
87
|
+
{
|
|
88
|
+
name: 'content',
|
|
89
|
+
type: 'richText',
|
|
90
|
+
editor: lexicalEditor({
|
|
91
|
+
features: ({ rootFeatures }) => {
|
|
92
|
+
return [
|
|
93
|
+
// ... your existing features
|
|
94
|
+
PayloadAiPluginLexicalEditorFeature()
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## ⚙️ Configuration
|
|
104
|
+
|
|
105
|
+
The plugin uses environment variables for configuration. Create a .env file in your project root and add the following variables:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
OPENAI_API_KEY=your-openai-api-key
|
|
109
|
+
ANTHROPIC_API_KEY=your-anthropic-api-key
|
|
110
|
+
ELEVENLABS_API_KEY=your-elevenlabs-api-key
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Enabling AI for Custom Components
|
|
114
|
+
|
|
115
|
+
> **⚠️ Note:** Custom fields don't fully adhere to the Payload schema, making it difficult to determine which components support injecting ComposeField as a Description.
|
|
116
|
+
> If AI enabled fields don't display Compose settings, please manually add the following component path:
|
|
117
|
+
>
|
|
118
|
+
> `@ai-stack/payloadcms/fields#ComposeField`
|
|
119
|
+
>
|
|
120
|
+
> To view AI enabled fields, enable the `debugging` flag in your plugin config or check your server startup logs.
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
## 👥 Contributing
|
|
124
|
+
|
|
125
|
+
Innovators: welcome! We're always excited to expand our community. Connect with us on [Discord](https://discord.com/channels/967097582721572934/1264949995656843345) to get started.
|
|
126
|
+
|
|
127
|
+
## Licensing
|
|
128
|
+
|
|
129
|
+
This plugin is available under dual licensing:
|
|
130
|
+
|
|
131
|
+
- ### Open-Source License
|
|
132
|
+
|
|
133
|
+
This plugin is available under the [MIT License](LICENSE.md). You can use, modify, and distribute it freely under the terms of this license.
|
|
134
|
+
|
|
135
|
+
- ### Commercial License
|
|
136
|
+
|
|
137
|
+
For companies or individuals who wish to use the plugin in a commercial context, require additional features, or need support, please refer to the [Commercial License Agreement](COMMERCIAL-LICENSE.md) for more details.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyse.d.ts","sourceRoot":"","sources":["../../src/ai/analyse.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ai/analyse.ts"],"sourcesContent":["// Coming soon...\n"],"names":[],"mappings":"AAAA,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,SAAgB,MAAM,WAAW,GAAG,sBAiChE,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { anthropic } from '@ai-sdk/anthropic';
|
|
2
|
+
import { streamObject } from 'ai';
|
|
3
|
+
import { exampleOutput } from '../example.js';
|
|
4
|
+
export const generateRichText = async (text, options)=>{
|
|
5
|
+
const streamResult = await streamObject({
|
|
6
|
+
model: anthropic(options.model),
|
|
7
|
+
prompt: text,
|
|
8
|
+
schema: options.editorSchema,
|
|
9
|
+
system: `${options.system}
|
|
10
|
+
|
|
11
|
+
RULES:
|
|
12
|
+
- Generate original and unique content based on the given topic.
|
|
13
|
+
- Strictly adhere to the specified layout and formatting instructions.
|
|
14
|
+
- Utilize the provided rich text editor tools for appropriate formatting.
|
|
15
|
+
- Ensure the output follows the structure of the sample output object.
|
|
16
|
+
- Produce valid JSON with no undefined or null values.
|
|
17
|
+
|
|
18
|
+
LAYOUT INSTRUCTIONS:
|
|
19
|
+
${options.layout}
|
|
20
|
+
|
|
21
|
+
RICH TEXT EDITOR TOOLS:
|
|
22
|
+
- Use appropriate formatting tools such as bold, italic, or underline for emphasis where needed.
|
|
23
|
+
- Apply correct heading levels (h1, h2, h3) for hierarchical structure.
|
|
24
|
+
- Utilize bullet points or numbered lists as required by the layout.
|
|
25
|
+
|
|
26
|
+
SAMPLE OUTPUT OBJECT:
|
|
27
|
+
${JSON.stringify(exampleOutput)}
|
|
28
|
+
|
|
29
|
+
ADDITIONAL GUIDELINES:
|
|
30
|
+
- Ensure coherence and logical flow between all sections.
|
|
31
|
+
- Maintain a consistent tone and style throughout the content.
|
|
32
|
+
- Use clear and concise language appropriate for the target audience.
|
|
33
|
+
- Double-check that all JSON fields are properly filled and formatted.`
|
|
34
|
+
});
|
|
35
|
+
return streamResult.toTextStreamResponse();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=generateRichText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { streamObject } from 'ai'\nimport { exampleOutput } from '../example.js'\n\nexport const generateRichText = async (text: string, options: any) => {\n const streamResult = await streamObject({\n model: anthropic(options.model),\n prompt: text,\n schema: 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\nSAMPLE OUTPUT OBJECT:\n${JSON.stringify(exampleOutput)}\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","streamObject","exampleOutput","generateRichText","text","options","streamResult","model","prompt","schema","editorSchema","system","layout","JSON","stringify","toTextStreamResponse"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,YAAY,QAAQ,KAAI;AACjC,SAASC,aAAa,QAAQ,gBAAe;AAE7C,OAAO,MAAMC,mBAAmB,OAAOC,MAAcC;IACnD,MAAMC,eAAe,MAAML,aAAa;QACtCM,OAAOP,UAAUK,QAAQE,KAAK;QAC9BC,QAAQJ;QACRK,QAAQJ,QAAQK,YAAY;QAC5BC,QAAQ,CAAC,EAAEN,QAAQM,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEN,QAAQO,MAAM,CAAC;;;;;;;;AAQjB,EAAEC,KAAKC,SAAS,CAACZ,eAAe;;;;;;sEAMsC,CAAC;IACrE;IAEA,OAAOI,aAAaS,oBAAoB;AAC1C,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAKzD,eAAO,MAAM,eAAe,EAAE,gBAyG7B,CAAA"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { anthropic } from '@ai-sdk/anthropic';
|
|
2
|
+
import { streamText } from 'ai';
|
|
3
|
+
import { generateRichText } from './generateRichText.js';
|
|
4
|
+
import { defaultSystemPrompt } from '../../prompts.js';
|
|
5
|
+
export const AnthropicConfig = {
|
|
6
|
+
models: [
|
|
7
|
+
{
|
|
8
|
+
id: 'anthropic-claude-text',
|
|
9
|
+
name: 'Anthropic Claude',
|
|
10
|
+
fields: [
|
|
11
|
+
'text',
|
|
12
|
+
'textarea'
|
|
13
|
+
],
|
|
14
|
+
handler: async (prompt, options)=>{
|
|
15
|
+
console.log('options ', options);
|
|
16
|
+
console.log('prompt ', prompt);
|
|
17
|
+
const streamTextResult = await streamText({
|
|
18
|
+
model: anthropic(options.model),
|
|
19
|
+
prompt,
|
|
20
|
+
system: options.system || defaultSystemPrompt
|
|
21
|
+
});
|
|
22
|
+
return streamTextResult.toDataStreamResponse();
|
|
23
|
+
},
|
|
24
|
+
output: 'text',
|
|
25
|
+
settings: {
|
|
26
|
+
name: 'anthropic-claude-text-settings',
|
|
27
|
+
type: 'group',
|
|
28
|
+
admin: {
|
|
29
|
+
condition (data) {
|
|
30
|
+
return data['model-id'] === 'anthropic-claude-text';
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
fields: [
|
|
34
|
+
{
|
|
35
|
+
name: 'model',
|
|
36
|
+
type: 'select',
|
|
37
|
+
defaultValue: 'claude-3-5-sonnet-20240620',
|
|
38
|
+
label: 'Model',
|
|
39
|
+
options: [
|
|
40
|
+
'claude-3-haiku-20240307',
|
|
41
|
+
'claude-3-sonnet-20240229',
|
|
42
|
+
'claude-3-opus-20240229',
|
|
43
|
+
'claude-3-5-sonnet-20240620'
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
label: 'Anthropic Claude Settings'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'anthropic-claude-object',
|
|
52
|
+
name: 'Anthropic Claude',
|
|
53
|
+
fields: [
|
|
54
|
+
'richText'
|
|
55
|
+
],
|
|
56
|
+
handler: (text, options)=>{
|
|
57
|
+
return generateRichText(text, options);
|
|
58
|
+
},
|
|
59
|
+
output: 'text',
|
|
60
|
+
settings: {
|
|
61
|
+
name: 'anthropic-claude-object-settings',
|
|
62
|
+
type: 'group',
|
|
63
|
+
admin: {
|
|
64
|
+
condition (data) {
|
|
65
|
+
return data['model-id'] === 'anthropic-claude-object';
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
fields: [
|
|
69
|
+
{
|
|
70
|
+
name: 'model',
|
|
71
|
+
type: 'select',
|
|
72
|
+
defaultValue: 'claude-3-5-sonnet-20240620',
|
|
73
|
+
label: 'Model',
|
|
74
|
+
options: [
|
|
75
|
+
'claude-3-haiku-20240307',
|
|
76
|
+
'claude-3-sonnet-20240229',
|
|
77
|
+
'claude-3-opus-20240229',
|
|
78
|
+
'claude-3-5-sonnet-20240620'
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'system',
|
|
83
|
+
type: 'textarea',
|
|
84
|
+
defaultValue: `INSTRUCTIONS:
|
|
85
|
+
You are a highly skilled and professional blog writer,
|
|
86
|
+
renowned for crafting engaging and well-organized articles.
|
|
87
|
+
When given a title, you meticulously create blogs that are not only
|
|
88
|
+
informative and accurate but also captivating and beautifully structured.`,
|
|
89
|
+
label: 'System prompt'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'layout',
|
|
93
|
+
type: 'textarea',
|
|
94
|
+
defaultValue: `[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.
|
|
95
|
+
[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.
|
|
96
|
+
[list] - Create a list with 3-5 items. Each list item should contain:
|
|
97
|
+
a. [heading] - A brief, descriptive heading (up to 5 words)
|
|
98
|
+
b. [paragraph] - A short explanation or elaboration (1-2 sentences)
|
|
99
|
+
[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.
|
|
100
|
+
[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.
|
|
101
|
+
[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: "Quote text." - Author Name`,
|
|
102
|
+
label: 'Layout'
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
label: 'Anthropic Claude Settings'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
provider: 'Anthropic'
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 { generateRichText } from './generateRichText.js'\nimport { defaultSystemPrompt } from '../../prompts.js'\n\nexport const AnthropicConfig: GenerationConfig = {\n models: [\n {\n id: 'anthropic-claude-text',\n name: 'Anthropic Claude',\n fields: ['text', 'textarea'],\n handler: async (\n prompt: string,\n options: { locale: string; model: string; system: string },\n ) => {\n console.log('options ', options)\n console.log('prompt ', prompt)\n\n const streamTextResult = await streamText({\n model: anthropic(options.model),\n prompt,\n system: options.system || defaultSystemPrompt,\n })\n\n return streamTextResult.toDataStreamResponse()\n },\n output: 'text',\n settings: {\n name: 'anthropic-claude-text-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'anthropic-claude-text'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'claude-3-5-sonnet-20240620',\n label: 'Model',\n options: [\n 'claude-3-haiku-20240307',\n 'claude-3-sonnet-20240229',\n 'claude-3-opus-20240229',\n 'claude-3-5-sonnet-20240620',\n ],\n },\n ],\n label: 'Anthropic Claude Settings',\n },\n },\n {\n id: 'anthropic-claude-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: 'anthropic-claude-object-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'anthropic-claude-object'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'claude-3-5-sonnet-20240620',\n label: 'Model',\n options: [\n 'claude-3-haiku-20240307',\n 'claude-3-sonnet-20240229',\n 'claude-3-opus-20240229',\n 'claude-3-5-sonnet-20240620',\n ],\n },\n {\n name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\n You are a highly skilled and professional blog writer,\n renowned for crafting engaging and well-organized articles.\n When given a title, you meticulously create blogs that are not only\n informative and accurate but also captivating and beautifully structured.`,\n label: 'System prompt',\n },\n {\n name: 'layout',\n type: 'textarea',\n defaultValue: `[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.\n[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.\n[list] - Create a list with 3-5 items. Each list item should contain:\n a. [heading] - A brief, descriptive heading (up to 5 words)\n b. [paragraph] - A short explanation or elaboration (1-2 sentences)\n[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.\n[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.\n[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: \"Quote text.\" - Author Name`,\n label: 'Layout',\n },\n ],\n label: 'Anthropic Claude Settings',\n },\n },\n ],\n provider: 'Anthropic',\n}\n"],"names":["anthropic","streamText","generateRichText","defaultSystemPrompt","AnthropicConfig","models","id","name","fields","handler","prompt","options","console","log","streamTextResult","model","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,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,mBAAmB,QAAQ,mBAAkB;AAEtD,OAAO,MAAMC,kBAAoC;IAC/CC,QAAQ;QACN;YACEC,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,SAAS,OACPC,QACAC;gBAEAC,QAAQC,GAAG,CAAC,YAAYF;gBACxBC,QAAQC,GAAG,CAAC,WAAWH;gBAEvB,MAAMI,mBAAmB,MAAMb,WAAW;oBACxCc,OAAOf,UAAUW,QAAQI,KAAK;oBAC9BL;oBACAM,QAAQL,QAAQK,MAAM,IAAIb;gBAC5B;gBAEA,OAAOW,iBAAiBG,oBAAoB;YAC9C;YACAC,QAAQ;YACRC,UAAU;gBACRZ,MAAM;gBACNa,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAf,QAAQ;oBACN;wBACED,MAAM;wBACNa,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPd,SAAS;4BACP;4BACA;4BACA;4BACA;yBACD;oBACH;iBACD;gBACDc,OAAO;YACT;QACF;QACA;YACEnB,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBC,SAAS,CAACiB,MAAcf;gBACtB,OAAOT,iBAAiBwB,MAAMf;YAChC;YACAO,QAAQ;YACRC,UAAU;gBACRZ,MAAM;gBACNa,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAf,QAAQ;oBACN;wBACED,MAAM;wBACNa,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPd,SAAS;4BACP;4BACA;4BACA;4BACA;yBACD;oBACH;oBACA;wBACEJ,MAAM;wBACNa,MAAM;wBACNI,cAAc,CAAC;;;;+EAIoD,CAAC;wBACpEC,OAAO;oBACT;oBACA;wBACElB,MAAM;wBACNa,MAAM;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDE,UAAU;AACZ,EAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as ElevenLabs from 'elevenlabs/api';
|
|
2
|
+
type ElevenLabsTextToSpeechOptions = {
|
|
3
|
+
voice_id: string;
|
|
4
|
+
} & Pick<ElevenLabs.TextToSpeechWithTimstampsRequest, 'model_id' | 'next_text' | 'previous_text' | 'seed' | 'voice_settings'>;
|
|
5
|
+
export declare const generateVoice: (text: string, options: ElevenLabsTextToSpeechOptions) => Promise<{
|
|
6
|
+
alignment: string[];
|
|
7
|
+
buffer: Buffer;
|
|
8
|
+
}>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=generateVoice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateVoice.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/elevenLabs/generateVoice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,UAAU,MAAM,gBAAgB,CAAA;AAIjD,KAAK,6BAA6B,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAA;CACjB,GAAG,IAAI,CACN,UAAU,CAAC,gCAAgC,EAC3C,UAAU,GAAG,WAAW,GAAG,eAAe,GAAG,MAAM,GAAG,gBAAgB,CACvE,CAAA;AAED,eAAO,MAAM,aAAa,SAAgB,MAAM,WAAW,6BAA6B;;;EAoBvF,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ElevenLabsClient } from 'elevenlabs';
|
|
2
|
+
export const generateVoice = async (text, options)=>{
|
|
3
|
+
const elevenLabs = new ElevenLabsClient({
|
|
4
|
+
apiKey: process.env.ELEVENLABS_API_KEY
|
|
5
|
+
});
|
|
6
|
+
const response = await elevenLabs.textToSpeech.convertWithTimstamps(options.voice_id, {
|
|
7
|
+
...options,
|
|
8
|
+
text
|
|
9
|
+
});
|
|
10
|
+
if (response?.audio_base64) {
|
|
11
|
+
const audioBuffer = Buffer.from(response.audio_base64, 'base64');
|
|
12
|
+
// const transcript = convertToTranscript(mp3Audio.alignment)
|
|
13
|
+
return {
|
|
14
|
+
alignment: response.alignment,
|
|
15
|
+
buffer: audioBuffer
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=generateVoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/elevenLabs/generateVoice.ts"],"sourcesContent":["import type * as ElevenLabs from 'elevenlabs/api'\n\nimport { ElevenLabsClient } from 'elevenlabs'\n\ntype ElevenLabsTextToSpeechOptions = {\n voice_id: string\n} & Pick<\n ElevenLabs.TextToSpeechWithTimstampsRequest,\n 'model_id' | 'next_text' | 'previous_text' | 'seed' | 'voice_settings'\n>\n\nexport const generateVoice = async (text: string, options: ElevenLabsTextToSpeechOptions) => {\n const elevenLabs = new ElevenLabsClient({\n apiKey: process.env.ELEVENLABS_API_KEY,\n })\n const response = (await elevenLabs.textToSpeech.convertWithTimstamps(options.voice_id, {\n ...options,\n text,\n })) as {\n alignment: string[]\n audio_base64: string\n }\n if (response?.audio_base64) {\n const audioBuffer = Buffer.from(response.audio_base64, 'base64')\n // const transcript = convertToTranscript(mp3Audio.alignment)\n\n return {\n alignment: response.alignment,\n buffer: audioBuffer,\n }\n }\n}\n"],"names":["ElevenLabsClient","generateVoice","text","options","elevenLabs","apiKey","process","env","ELEVENLABS_API_KEY","response","textToSpeech","convertWithTimstamps","voice_id","audio_base64","audioBuffer","Buffer","from","alignment","buffer"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,aAAY;AAS7C,OAAO,MAAMC,gBAAgB,OAAOC,MAAcC;IAChD,MAAMC,aAAa,IAAIJ,iBAAiB;QACtCK,QAAQC,QAAQC,GAAG,CAACC,kBAAkB;IACxC;IACA,MAAMC,WAAY,MAAML,WAAWM,YAAY,CAACC,oBAAoB,CAACR,QAAQS,QAAQ,EAAE;QACrF,GAAGT,OAAO;QACVD;IACF;IAIA,IAAIO,UAAUI,cAAc;QAC1B,MAAMC,cAAcC,OAAOC,IAAI,CAACP,SAASI,YAAY,EAAE;QACvD,6DAA6D;QAE7D,OAAO;YACLI,WAAWR,SAASQ,SAAS;YAC7BC,QAAQJ;QACV;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/elevenLabs/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAiGzD,eAAO,MAAM,gBAAgB,EAAE,gBAmC9B,CAAA"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js';
|
|
2
|
+
import { generateVoice } from './generateVoice.js';
|
|
3
|
+
import { getAllVoices } from './voices.js';
|
|
4
|
+
const { voices = [] } = await getAllVoices();
|
|
5
|
+
const voiceOptions = voices.map((voice)=>{
|
|
6
|
+
return {
|
|
7
|
+
label: voice.name,
|
|
8
|
+
value: voice.voice_id,
|
|
9
|
+
...voice
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
const fieldVoiceOptions = voiceOptions.map((option)=>{
|
|
13
|
+
return {
|
|
14
|
+
label: option.name,
|
|
15
|
+
value: option.voice_id
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
const fields = [
|
|
19
|
+
{
|
|
20
|
+
type: 'collapsible',
|
|
21
|
+
admin: {
|
|
22
|
+
initCollapsed: false
|
|
23
|
+
},
|
|
24
|
+
fields: [
|
|
25
|
+
{
|
|
26
|
+
name: 'stability',
|
|
27
|
+
type: 'number',
|
|
28
|
+
defaultValue: 0.5,
|
|
29
|
+
label: 'Stability',
|
|
30
|
+
max: 1,
|
|
31
|
+
min: 0,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'similarity_boost',
|
|
36
|
+
type: 'number',
|
|
37
|
+
defaultValue: 0.5,
|
|
38
|
+
label: 'Similarity Boost',
|
|
39
|
+
max: 1,
|
|
40
|
+
min: 0,
|
|
41
|
+
required: true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'style',
|
|
45
|
+
type: 'number',
|
|
46
|
+
defaultValue: 0.5,
|
|
47
|
+
label: 'Style',
|
|
48
|
+
max: 1,
|
|
49
|
+
min: 0
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'use_speaker_boost',
|
|
53
|
+
type: 'checkbox',
|
|
54
|
+
label: 'Use Speaker Boost'
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
label: 'Voice Settings'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'seed',
|
|
61
|
+
type: 'number',
|
|
62
|
+
label: 'Seed'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'row',
|
|
66
|
+
fields: [
|
|
67
|
+
{
|
|
68
|
+
name: 'previous_text',
|
|
69
|
+
type: 'textarea',
|
|
70
|
+
label: 'Previous Text'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'next_text',
|
|
74
|
+
type: 'textarea',
|
|
75
|
+
label: 'Next Text'
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
if (voiceOptions.length) {
|
|
81
|
+
fields.unshift({
|
|
82
|
+
name: 'voice_id',
|
|
83
|
+
type: 'select',
|
|
84
|
+
defaultValue: voiceOptions[0]?.voice_id,
|
|
85
|
+
label: 'Voice',
|
|
86
|
+
options: fieldVoiceOptions,
|
|
87
|
+
required: true
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export const ElevenLabsConfig = {
|
|
91
|
+
models: [
|
|
92
|
+
{
|
|
93
|
+
id: 'elevenlabs/multilingual-v2',
|
|
94
|
+
name: 'ElevenLabs Multilingual v2',
|
|
95
|
+
fields: [
|
|
96
|
+
'upload'
|
|
97
|
+
],
|
|
98
|
+
handler: async (text, options)=>{
|
|
99
|
+
const voiceData = await generateVoice(text, options);
|
|
100
|
+
return {
|
|
101
|
+
data: {
|
|
102
|
+
alt: 'voice over'
|
|
103
|
+
},
|
|
104
|
+
file: {
|
|
105
|
+
name: `voice_${generateFileNameByPrompt(text)}.mp3`,
|
|
106
|
+
data: voiceData.buffer,
|
|
107
|
+
mimetype: 'audio/mp3',
|
|
108
|
+
size: voiceData.buffer.byteLength
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
output: 'audio',
|
|
113
|
+
settings: {
|
|
114
|
+
name: 'elevenlabs-multilingual-v2-settings',
|
|
115
|
+
type: 'group',
|
|
116
|
+
admin: {
|
|
117
|
+
condition: (data)=>{
|
|
118
|
+
return data['model-id'] === 'elevenlabs/multilingual-v2';
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
fields,
|
|
122
|
+
label: 'ElevenLabs Multilingual v2 Settings'
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
provider: 'ElevenLabs'
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/elevenLabs/index.ts"],"sourcesContent":["import type { Field, File } from 'payload'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateVoice } from './generateVoice.js'\nimport { getAllVoices } from './voices.js'\n\nconst { voices = [] } = await getAllVoices()\n\nconst voiceOptions = voices.map((voice) => {\n return {\n label: voice.name,\n value: voice.voice_id,\n ...voice,\n }\n})\n\nconst fieldVoiceOptions = voiceOptions.map((option) => {\n return {\n label: option.name,\n value: option.voice_id,\n }\n})\n\nconst fields: Field[] = [\n {\n type: 'collapsible',\n admin: {\n initCollapsed: false,\n },\n fields: [\n {\n name: 'stability',\n type: 'number',\n defaultValue: 0.5,\n label: 'Stability',\n max: 1,\n min: 0,\n required: true,\n },\n {\n name: 'similarity_boost',\n type: 'number',\n defaultValue: 0.5,\n label: 'Similarity Boost',\n max: 1,\n min: 0,\n required: true,\n },\n {\n name: 'style',\n type: 'number',\n defaultValue: 0.5,\n label: 'Style',\n max: 1,\n min: 0,\n },\n {\n name: 'use_speaker_boost',\n type: 'checkbox',\n label: 'Use Speaker Boost',\n },\n ],\n label: 'Voice Settings',\n },\n {\n name: 'seed',\n type: 'number',\n label: 'Seed',\n },\n {\n type: 'row',\n fields: [\n {\n name: 'previous_text',\n type: 'textarea',\n label: 'Previous Text',\n },\n {\n name: 'next_text',\n type: 'textarea',\n label: 'Next Text',\n },\n ],\n },\n]\n\nif (voiceOptions.length) {\n fields.unshift({\n name: 'voice_id',\n type: 'select',\n defaultValue: voiceOptions[0]?.voice_id,\n label: 'Voice',\n options: fieldVoiceOptions,\n required: true,\n })\n}\n\nexport const ElevenLabsConfig: GenerationConfig = {\n models: [\n {\n id: 'elevenlabs/multilingual-v2',\n name: 'ElevenLabs Multilingual v2',\n fields: ['upload'],\n handler: async (text: string, options) => {\n const voiceData = await generateVoice(text, options)\n return {\n data: {\n alt: 'voice over',\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: 'elevenlabs-multilingual-v2-settings',\n type: 'group',\n admin: {\n condition: (data) => {\n return data['model-id'] === 'elevenlabs/multilingual-v2'\n },\n },\n fields,\n label: 'ElevenLabs Multilingual v2 Settings',\n },\n },\n ],\n provider: 'ElevenLabs',\n}\n"],"names":["generateFileNameByPrompt","generateVoice","getAllVoices","voices","voiceOptions","map","voice","label","name","value","voice_id","fieldVoiceOptions","option","fields","type","admin","initCollapsed","defaultValue","max","min","required","length","unshift","options","ElevenLabsConfig","models","id","handler","text","voiceData","data","alt","file","buffer","mimetype","size","byteLength","output","settings","condition","provider"],"mappings":"AAIA,SAASA,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,YAAY,QAAQ,cAAa;AAE1C,MAAM,EAAEC,SAAS,EAAE,EAAE,GAAG,MAAMD;AAE9B,MAAME,eAAeD,OAAOE,GAAG,CAAC,CAACC;IAC/B,OAAO;QACLC,OAAOD,MAAME,IAAI;QACjBC,OAAOH,MAAMI,QAAQ;QACrB,GAAGJ,KAAK;IACV;AACF;AAEA,MAAMK,oBAAoBP,aAAaC,GAAG,CAAC,CAACO;IAC1C,OAAO;QACLL,OAAOK,OAAOJ,IAAI;QAClBC,OAAOG,OAAOF,QAAQ;IACxB;AACF;AAEA,MAAMG,SAAkB;IACtB;QACEC,MAAM;QACNC,OAAO;YACLC,eAAe;QACjB;QACAH,QAAQ;YACN;gBACEL,MAAM;gBACNM,MAAM;gBACNG,cAAc;gBACdV,OAAO;gBACPW,KAAK;gBACLC,KAAK;gBACLC,UAAU;YACZ;YACA;gBACEZ,MAAM;gBACNM,MAAM;gBACNG,cAAc;gBACdV,OAAO;gBACPW,KAAK;gBACLC,KAAK;gBACLC,UAAU;YACZ;YACA;gBACEZ,MAAM;gBACNM,MAAM;gBACNG,cAAc;gBACdV,OAAO;gBACPW,KAAK;gBACLC,KAAK;YACP;YACA;gBACEX,MAAM;gBACNM,MAAM;gBACNP,OAAO;YACT;SACD;QACDA,OAAO;IACT;IACA;QACEC,MAAM;QACNM,MAAM;QACNP,OAAO;IACT;IACA;QACEO,MAAM;QACND,QAAQ;YACN;gBACEL,MAAM;gBACNM,MAAM;gBACNP,OAAO;YACT;YACA;gBACEC,MAAM;gBACNM,MAAM;gBACNP,OAAO;YACT;SACD;IACH;CACD;AAED,IAAIH,aAAaiB,MAAM,EAAE;IACvBR,OAAOS,OAAO,CAAC;QACbd,MAAM;QACNM,MAAM;QACNG,cAAcb,YAAY,CAAC,EAAE,EAAEM;QAC/BH,OAAO;QACPgB,SAASZ;QACTS,UAAU;IACZ;AACF;AAEA,OAAO,MAAMI,mBAAqC;IAChDC,QAAQ;QACN;YACEC,IAAI;YACJlB,MAAM;YACNK,QAAQ;gBAAC;aAAS;YAClBc,SAAS,OAAOC,MAAcL;gBAC5B,MAAMM,YAAY,MAAM5B,cAAc2B,MAAML;gBAC5C,OAAO;oBACLO,MAAM;wBACJC,KAAK;oBACP;oBACAC,MAAM;wBACJxB,MAAM,CAAC,MAAM,EAAER,yBAAyB4B,MAAM,IAAI,CAAC;wBACnDE,MAAMD,UAAUI,MAAM;wBACtBC,UAAU;wBACVC,MAAMN,UAAUI,MAAM,CAACG,UAAU;oBACnC;gBACF;YACF;YACAC,QAAQ;YACRC,UAAU;gBACR9B,MAAM;gBACNM,MAAM;gBACNC,OAAO;oBACLwB,WAAW,CAACT;wBACV,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAjB;gBACAN,OAAO;YACT;QACF;KACD;IACDiC,UAAU;AACZ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voices.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/elevenLabs/voices.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY;;EAiBxB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ElevenLabsClient } from 'elevenlabs';
|
|
2
|
+
import * as process from 'node:process';
|
|
3
|
+
let voicesState = {
|
|
4
|
+
voices: []
|
|
5
|
+
};
|
|
6
|
+
export const getAllVoices = async ()=>{
|
|
7
|
+
if (!process.env.ELEVENLABS_API_KEY) {
|
|
8
|
+
return voicesState;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const elevenLabs = new ElevenLabsClient();
|
|
12
|
+
if (!voicesState.voices.length) {
|
|
13
|
+
voicesState = await elevenLabs.voices.getAll({
|
|
14
|
+
timeoutInSeconds: 10000
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return voicesState;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('getAllVoices: ', error);
|
|
20
|
+
return voicesState;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=voices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/elevenLabs/voices.ts"],"sourcesContent":["import { ElevenLabsClient } from 'elevenlabs'\nimport * as process from 'node:process'\n\nlet voicesState = { voices: [] }\nexport const getAllVoices = async () => {\n if (!process.env.ELEVENLABS_API_KEY) {\n return voicesState\n }\n\n try {\n const elevenLabs = new ElevenLabsClient()\n if (!voicesState.voices.length) {\n voicesState = await elevenLabs.voices.getAll({\n timeoutInSeconds: 10000,\n })\n }\n return voicesState\n } catch (error) {\n console.error('getAllVoices: ', error)\n return voicesState\n }\n}\n"],"names":["ElevenLabsClient","process","voicesState","voices","getAllVoices","env","ELEVENLABS_API_KEY","elevenLabs","length","getAll","timeoutInSeconds","error","console"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAY;AAC7C,YAAYC,aAAa,eAAc;AAEvC,IAAIC,cAAc;IAAEC,QAAQ,EAAE;AAAC;AAC/B,OAAO,MAAMC,eAAe;IAC1B,IAAI,CAACH,QAAQI,GAAG,CAACC,kBAAkB,EAAE;QACnC,OAAOJ;IACT;IAEA,IAAI;QACF,MAAMK,aAAa,IAAIP;QACvB,IAAI,CAACE,YAAYC,MAAM,CAACK,MAAM,EAAE;YAC9BN,cAAc,MAAMK,WAAWJ,MAAM,CAACM,MAAM,CAAC;gBAC3CC,kBAAkB;YACpB;QACF;QACA,OAAOR;IACT,EAAE,OAAOS,OAAO;QACdC,QAAQD,KAAK,CAAC,kBAAkBA;QAChC,OAAOT;IACT;AACF,EAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Comprehensive Blog Writing Prompt
|
|
2
|
+
|
|
3
|
+
Create an engaging and informative blog post on the topic of **{{ title }}**. Your writing should be well-structured, authoritative, and seamlessly incorporate the provided product information.
|
|
4
|
+
|
|
5
|
+
## Structure and Style:
|
|
6
|
+
|
|
7
|
+
1. Begin with a compelling introduction that hooks the reader and outlines the main points you'll cover.
|
|
8
|
+
2. Divide the main body into 3-5 distinct sections, each exploring a different aspect of the topic.
|
|
9
|
+
3. Conclude with a summary of key takeaways and a call-to-action for readers.
|
|
10
|
+
4. Use appropriate headings (H2, H3) to organize your content.
|
|
11
|
+
5. Employ text styling techniques to enhance readability and emphasize important points:
|
|
12
|
+
- **Bold** for key concepts or product names
|
|
13
|
+
- *Italic* for emphasis or introducing new terms
|
|
14
|
+
- ~~Strikethrough~~ for contrasts or outdated information
|
|
15
|
+
- `Code formatting` for technical terms or product codes
|
|
16
|
+
|
|
17
|
+
## Product Integration:
|
|
18
|
+
|
|
19
|
+
Incorporate the following products naturally throughout your blog post:
|
|
20
|
+
|
|
21
|
+
{{#each resources}}
|
|
22
|
+
- **Product URL**: {{this.url}}
|
|
23
|
+
**Product Details**: {{this.data}}
|
|
24
|
+
|
|
25
|
+
Seamlessly weave this product's features and benefits into your content where relevant. Use it to support your points, provide examples, or offer solutions related to the blog topic.
|
|
26
|
+
|
|
27
|
+
{{/each}}
|
|
28
|
+
|
|
29
|
+
## Linking Products:
|
|
30
|
+
|
|
31
|
+
When mentioning each product in your content, create a hyperlink to its corresponding URL. Use descriptive anchor text that naturally fits within the sentence. For example:
|
|
32
|
+
|
|
33
|
+
- "The [innovative features of Product X](product-x-url) make it an excellent choice for..."
|
|
34
|
+
- "Learn more about [how Product Y can streamline your workflow](product-y-url)."
|
|
35
|
+
|
|
36
|
+
Ensure that each product is linked at least once within the blog post, preferably where it's most relevant to the surrounding content.
|
|
37
|
+
|
|
38
|
+
## Additional Guidelines:
|
|
39
|
+
|
|
40
|
+
1. Maintain a conversational yet professional tone throughout the post.
|
|
41
|
+
2. Include relevant statistics, examples, or case studies to support your points.
|
|
42
|
+
3. Address potential questions or concerns your readers might have about the topic.
|
|
43
|
+
4. Use transition phrases to ensure smooth flow between paragraphs and sections.
|
|
44
|
+
5. Proofread for grammar, spelling, and clarity before submitting.
|
|
45
|
+
6. Double-check that all product links are correctly inserted and functional.
|
|
46
|
+
|
|
47
|
+
Remember to craft your content in a way that provides value to the reader while organically showcasing the listed products. Aim for a blog post length of 800-1200 words, adjusting as necessary to fully explore the topic and incorporate all products effectively.
|