@ai-stack/payloadcms 3.0.0-beta.104.2 → 3.0.0-beta.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +2 -16
  2. package/dist/ai/{schemas → editor}/lexical.schema.d.ts +2 -2
  3. package/dist/ai/editor/lexical.schema.d.ts.map +1 -0
  4. package/dist/ai/editor/lexical.schema.js.map +1 -0
  5. package/dist/ai/models/anthropic/generateRichText.js.map +1 -1
  6. package/dist/ai/models/anthropic/index.d.ts.map +1 -1
  7. package/dist/ai/models/anthropic/index.js +4 -43
  8. package/dist/ai/models/anthropic/index.js.map +1 -1
  9. package/dist/ai/models/elevenLabs/index.d.ts.map +1 -1
  10. package/dist/ai/models/elevenLabs/index.js +11 -1
  11. package/dist/ai/models/elevenLabs/index.js.map +1 -1
  12. package/dist/ai/models/index.d.ts.map +1 -1
  13. package/dist/ai/models/index.js +3 -3
  14. package/dist/ai/models/index.js.map +1 -1
  15. package/dist/ai/models/openai/generateRichText.js.map +1 -1
  16. package/dist/ai/models/openai/index.js +3 -3
  17. package/dist/ai/models/openai/index.js.map +1 -1
  18. package/dist/ai/models/style.d.ts +2 -0
  19. package/dist/ai/models/style.d.ts.map +1 -0
  20. package/dist/ai/models/style.js +31 -0
  21. package/dist/ai/models/style.js.map +1 -0
  22. package/dist/ai/prompts.d.ts +6 -7
  23. package/dist/ai/prompts.d.ts.map +1 -1
  24. package/dist/ai/prompts.js +16 -24
  25. package/dist/ai/prompts.js.map +1 -1
  26. package/dist/ai/utils/generateFileNameByPrompt.js.map +1 -1
  27. package/dist/ai/utils/generateSeedPrompt.d.ts.map +1 -1
  28. package/dist/ai/utils/generateSeedPrompt.js +5 -14
  29. package/dist/ai/utils/generateSeedPrompt.js.map +1 -1
  30. package/dist/collections/Instructions.d.ts.map +1 -1
  31. package/dist/collections/Instructions.js +13 -10
  32. package/dist/collections/Instructions.js.map +1 -1
  33. package/dist/defaults.d.ts +2 -3
  34. package/dist/defaults.d.ts.map +1 -1
  35. package/dist/defaults.js +2 -3
  36. package/dist/defaults.js.map +1 -1
  37. package/dist/endpoints/index.d.ts +1 -1
  38. package/dist/endpoints/index.d.ts.map +1 -1
  39. package/dist/endpoints/index.js +51 -17
  40. package/dist/endpoints/index.js.map +1 -1
  41. package/dist/exports/fields.d.ts +1 -3
  42. package/dist/exports/fields.d.ts.map +1 -1
  43. package/dist/exports/fields.js +0 -3
  44. package/dist/exports/fields.js.map +1 -1
  45. package/dist/fields/DescriptionField/DescriptionField.d.ts +3 -0
  46. package/dist/fields/DescriptionField/DescriptionField.d.ts.map +1 -0
  47. package/dist/fields/DescriptionField/DescriptionField.js +15 -0
  48. package/dist/fields/DescriptionField/DescriptionField.js.map +1 -0
  49. package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts +4 -0
  50. package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts.map +1 -0
  51. package/dist/fields/{ComposeField/ComposeField.js → DescriptionField/DescriptionFieldComponent.js} +5 -5
  52. package/dist/fields/DescriptionField/DescriptionFieldComponent.js.map +1 -0
  53. package/dist/fields/LexicalEditor/ActionsFeatureComponent.d.ts +2 -0
  54. package/dist/fields/LexicalEditor/ActionsFeatureComponent.d.ts.map +1 -0
  55. package/dist/fields/LexicalEditor/{ComposeFeatureComponent.js → ActionsFeatureComponent.js} +5 -5
  56. package/dist/fields/LexicalEditor/ActionsFeatureComponent.js.map +1 -0
  57. package/dist/fields/LexicalEditor/feature.client.d.ts +4 -1
  58. package/dist/fields/LexicalEditor/feature.client.d.ts.map +1 -1
  59. package/dist/fields/LexicalEditor/feature.client.js +2 -2
  60. package/dist/fields/LexicalEditor/feature.client.js.map +1 -1
  61. package/dist/fields/LexicalEditor/feature.server.d.ts +7 -1
  62. package/dist/fields/LexicalEditor/feature.server.d.ts.map +1 -1
  63. package/dist/fields/LexicalEditor/feature.server.js +11 -4
  64. package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
  65. package/dist/fields/PromptEditorField/PromptEditorField.d.ts +2 -2
  66. package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
  67. package/dist/fields/PromptEditorField/PromptEditorField.js +51 -32
  68. package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
  69. package/dist/fields/SelectField/SelectField.d.ts +2 -9
  70. package/dist/fields/SelectField/SelectField.d.ts.map +1 -1
  71. package/dist/fields/SelectField/SelectField.js +23 -26
  72. package/dist/fields/SelectField/SelectField.js.map +1 -1
  73. package/dist/index.d.ts +2 -2
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +3 -3
  76. package/dist/index.js.map +1 -1
  77. package/dist/init.d.ts +1 -2
  78. package/dist/init.d.ts.map +1 -1
  79. package/dist/init.js +19 -35
  80. package/dist/init.js.map +1 -1
  81. package/dist/plugin.d.ts.map +1 -1
  82. package/dist/plugin.js +73 -104
  83. package/dist/plugin.js.map +1 -1
  84. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts +3 -1
  85. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts.map +1 -1
  86. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  87. package/dist/providers/InstructionsProvider/hook.d.ts +9 -0
  88. package/dist/providers/InstructionsProvider/hook.d.ts.map +1 -0
  89. package/dist/providers/InstructionsProvider/hook.js +17 -0
  90. package/dist/providers/InstructionsProvider/hook.js.map +1 -0
  91. package/dist/providers/InstructionsProvider/index.d.ts +5 -0
  92. package/dist/providers/InstructionsProvider/index.d.ts.map +1 -0
  93. package/dist/providers/InstructionsProvider/index.js +10 -0
  94. package/dist/providers/InstructionsProvider/index.js.map +1 -0
  95. package/dist/types.d.ts +1 -2
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/types.js.map +1 -1
  98. package/dist/ui/Actions/Actions.d.ts +5 -0
  99. package/dist/ui/Actions/Actions.d.ts.map +1 -0
  100. package/dist/ui/{Compose/Compose.js → Actions/Actions.js} +18 -17
  101. package/dist/ui/Actions/Actions.js.map +1 -0
  102. package/dist/ui/{Compose → Actions}/UndoRedoActions.d.ts.map +1 -1
  103. package/dist/ui/{Compose → Actions}/UndoRedoActions.js +2 -15
  104. package/dist/ui/Actions/UndoRedoActions.js.map +1 -0
  105. package/dist/ui/Actions/hooks/highlight.module.scss +3 -0
  106. package/dist/ui/{Compose → Actions}/hooks/menu/Item.d.ts.map +1 -1
  107. package/dist/ui/{Compose → Actions}/hooks/menu/Item.js.map +1 -1
  108. package/dist/ui/Actions/hooks/menu/TranslateMenu.d.ts.map +1 -0
  109. package/dist/ui/{Compose → Actions}/hooks/menu/TranslateMenu.js.map +1 -1
  110. package/dist/ui/{Compose → Actions}/hooks/menu/items.d.ts.map +1 -1
  111. package/dist/ui/{Compose → Actions}/hooks/menu/items.js.map +1 -1
  112. package/dist/ui/{Compose → Actions}/hooks/menu/itemsMap.d.ts.map +1 -1
  113. package/dist/ui/{Compose → Actions}/hooks/menu/itemsMap.js.map +1 -1
  114. package/dist/ui/{Compose → Actions}/hooks/menu/useMenu.d.ts.map +1 -1
  115. package/dist/ui/{Compose → Actions}/hooks/menu/useMenu.js.map +1 -1
  116. package/dist/ui/{Compose → Actions}/hooks/useGenerate.d.ts.map +1 -1
  117. package/dist/ui/{Compose → Actions}/hooks/useGenerate.js +12 -10
  118. package/dist/ui/Actions/hooks/useGenerate.js.map +1 -0
  119. package/dist/ui/Actions/hooks/useHistory.d.ts.map +1 -0
  120. package/dist/ui/{Compose → Actions}/hooks/useHistory.js +1 -3
  121. package/dist/ui/Actions/hooks/useHistory.js.map +1 -0
  122. package/dist/ui/Floatype/Floatype.d.ts +21 -0
  123. package/dist/ui/Floatype/Floatype.d.ts.map +1 -0
  124. package/dist/ui/Floatype/Floatype.js +245 -0
  125. package/dist/ui/Floatype/Floatype.js.map +1 -0
  126. package/dist/ui/Floatype/floatype.module.css +25 -0
  127. package/dist/utilities/getFieldBySchemaPath.d.ts +2 -2
  128. package/dist/utilities/getFieldBySchemaPath.d.ts.map +1 -1
  129. package/dist/utilities/getFieldBySchemaPath.js.map +1 -1
  130. package/dist/utilities/updateFieldsConfig.d.ts.map +1 -1
  131. package/dist/utilities/updateFieldsConfig.js +8 -14
  132. package/dist/utilities/updateFieldsConfig.js.map +1 -1
  133. package/package.json +50 -72
  134. package/dist/ai/schemas/lexical.schema.d.ts.map +0 -1
  135. package/dist/ai/schemas/lexical.schema.js.map +0 -1
  136. package/dist/exports/client.d.ts +0 -3
  137. package/dist/exports/client.d.ts.map +0 -1
  138. package/dist/exports/client.js +0 -4
  139. package/dist/exports/client.js.map +0 -1
  140. package/dist/fields/ComposeField/ComposeField.d.ts +0 -4
  141. package/dist/fields/ComposeField/ComposeField.d.ts.map +0 -1
  142. package/dist/fields/ComposeField/ComposeField.js.map +0 -1
  143. package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts +0 -2
  144. package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts.map +0 -1
  145. package/dist/fields/LexicalEditor/ComposeFeatureComponent.js.map +0 -1
  146. package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts +0 -8
  147. package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts.map +0 -1
  148. package/dist/libraries/autocomplete/AutocompleteTextArea.js +0 -437
  149. package/dist/libraries/autocomplete/AutocompleteTextArea.js.map +0 -1
  150. package/dist/libraries/autocomplete/AutocompleteTextArea.module.scss +0 -35
  151. package/dist/libraries/handlebars/asyncHandlebars.d.ts +0 -2
  152. package/dist/libraries/handlebars/asyncHandlebars.d.ts.map +0 -1
  153. package/dist/libraries/handlebars/asyncHandlebars.js +0 -5
  154. package/dist/libraries/handlebars/asyncHandlebars.js.map +0 -1
  155. package/dist/libraries/handlebars/helpers.d.ts +0 -2
  156. package/dist/libraries/handlebars/helpers.d.ts.map +0 -1
  157. package/dist/libraries/handlebars/helpers.js +0 -22
  158. package/dist/libraries/handlebars/helpers.js.map +0 -1
  159. package/dist/libraries/handlebars/helpersMap.d.ts +0 -12
  160. package/dist/libraries/handlebars/helpersMap.d.ts.map +0 -1
  161. package/dist/libraries/handlebars/helpersMap.js +0 -13
  162. package/dist/libraries/handlebars/helpersMap.js.map +0 -1
  163. package/dist/libraries/handlebars/replacePlaceholders.d.ts +0 -2
  164. package/dist/libraries/handlebars/replacePlaceholders.d.ts.map +0 -1
  165. package/dist/libraries/handlebars/replacePlaceholders.js +0 -8
  166. package/dist/libraries/handlebars/replacePlaceholders.js.map +0 -1
  167. package/dist/providers/InstructionsProvider/useInstructions.d.ts +0 -4
  168. package/dist/providers/InstructionsProvider/useInstructions.d.ts.map +0 -1
  169. package/dist/providers/InstructionsProvider/useInstructions.js +0 -38
  170. package/dist/providers/InstructionsProvider/useInstructions.js.map +0 -1
  171. package/dist/ui/Compose/Compose.d.ts +0 -9
  172. package/dist/ui/Compose/Compose.d.ts.map +0 -1
  173. package/dist/ui/Compose/Compose.js.map +0 -1
  174. package/dist/ui/Compose/UndoRedoActions.js.map +0 -1
  175. package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts.map +0 -1
  176. package/dist/ui/Compose/hooks/useGenerate.js.map +0 -1
  177. package/dist/ui/Compose/hooks/useHistory.d.ts.map +0 -1
  178. package/dist/ui/Compose/hooks/useHistory.js.map +0 -1
  179. package/dist/utilities/getFieldInfo.d.ts +0 -3
  180. package/dist/utilities/getFieldInfo.d.ts.map +0 -1
  181. package/dist/utilities/getFieldInfo.js +0 -14
  182. package/dist/utilities/getFieldInfo.js.map +0 -1
  183. package/dist/utilities/isPluginActivated.d.ts +0 -2
  184. package/dist/utilities/isPluginActivated.d.ts.map +0 -1
  185. package/dist/utilities/isPluginActivated.js +0 -5
  186. package/dist/utilities/isPluginActivated.js.map +0 -1
  187. /package/dist/ai/{schemas → editor}/lexical.schema.js +0 -0
  188. /package/dist/ui/{Compose → Actions}/UndoRedoActions.d.ts +0 -0
  189. /package/dist/ui/{Compose/compose.module.scss → Actions/actions.module.scss} +0 -0
  190. /package/dist/ui/{Compose → Actions}/hooks/menu/Item.d.ts +0 -0
  191. /package/dist/ui/{Compose → Actions}/hooks/menu/Item.js +0 -0
  192. /package/dist/ui/{Compose → Actions}/hooks/menu/TranslateMenu.d.ts +0 -0
  193. /package/dist/ui/{Compose → Actions}/hooks/menu/TranslateMenu.js +0 -0
  194. /package/dist/ui/{Compose → Actions}/hooks/menu/items.d.ts +0 -0
  195. /package/dist/ui/{Compose → Actions}/hooks/menu/items.js +0 -0
  196. /package/dist/ui/{Compose → Actions}/hooks/menu/itemsMap.d.ts +0 -0
  197. /package/dist/ui/{Compose → Actions}/hooks/menu/itemsMap.js +0 -0
  198. /package/dist/ui/{Compose → Actions}/hooks/menu/menu.module.scss +0 -0
  199. /package/dist/ui/{Compose → Actions}/hooks/menu/useMenu.d.ts +0 -0
  200. /package/dist/ui/{Compose → Actions}/hooks/menu/useMenu.js +0 -0
  201. /package/dist/ui/{Compose → Actions}/hooks/useGenerate.d.ts +0 -0
  202. /package/dist/ui/{Compose → Actions}/hooks/useHistory.d.ts +0 -0
package/README.md CHANGED
@@ -8,15 +8,11 @@
8
8
 
9
9
  The Payload AI Plugin is an advanced extension that integrates modern AI capabilities into your Payload CMS, streamlining content creation and management.
10
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.
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 3.0.0-beta.65.
12
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
- ---
13
+ > To give it a try, we recommend using [Payload's website template](https://github.com/payloadcms/payload/tree/v3.0.0-beta.65/templates/website).
16
14
 
17
15
  ### 🎥 [Watch the Magic in Action](https://youtu.be/qaYukeGpuu4)
18
- Want to dive deeper?
19
- ### 🎥 [Explore More in Our Extended Demo](https://youtu.be/LEsuHbKalNY)
20
16
 
21
17
 
22
18
  ## ✨ Supported Fields and Features
@@ -42,7 +38,6 @@ Want to dive deeper?
42
38
  - ✅ **Fact Checking** (Coming Soon)
43
39
  - 🔄 **Automated Content Workflows** (Coming Soon)
44
40
  - 🌍 **Internationalization Support** (Coming Soon)
45
- - 🌍 **Editor AI suggestions** (Coming Soon)
46
41
  - 💬 **AI Chat Support** (Coming Soon)
47
42
 
48
43
  ## 📚 Table of Contents
@@ -114,15 +109,6 @@ ANTHROPIC_API_KEY=your-anthropic-api-key
114
109
  ELEVENLABS_API_KEY=your-elevenlabs-api-key
115
110
  ```
116
111
 
117
- ### Enabling AI for Custom Components
118
-
119
- > **⚠️ Note:** Custom fields don't fully adhere to the Payload schema, making it difficult to determine which components support injecting ComposeField as a Description.
120
- > If AI enabled fields don't display Compose settings, please manually add the following component path:
121
- >
122
- > `@ai-stack/payloadcms/fields#ComposeField`
123
- >
124
- > To view AI enabled fields, enable the `debugging` flag in your plugin config or check your server startup logs.
125
-
126
112
 
127
113
  ## 👥 Contributing
128
114
 
@@ -7,15 +7,15 @@ export declare const LexicalBaseNode: z.ZodObject<{
7
7
  indent: z.ZodOptional<z.ZodNumber>;
8
8
  version: z.ZodOptional<z.ZodNumber>;
9
9
  }, "strip", z.ZodTypeAny, {
10
- type?: string;
11
10
  children?: any[];
11
+ type?: string;
12
12
  direction?: "ltr";
13
13
  format?: string;
14
14
  indent?: number;
15
15
  version?: number;
16
16
  }, {
17
- type?: string;
18
17
  children?: any[];
18
+ type?: string;
19
19
  direction?: "ltr";
20
20
  format?: string;
21
21
  indent?: number;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexical.schema.d.ts","sourceRoot":"","sources":["../../../src/ai/editor/lexical.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;EAO1B,CAAA;AAEF,eAAO,MAAM,aAAa,iBAAkB,CAAC,OAAO,eAAe,CAAC,EAAE;;;;;;EA0ErE,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ai/editor/lexical.schema.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const LexicalBaseNode = z.object({\n type: z.string(),\n children: z.array(z.any()).optional(),\n direction: z.enum(['ltr']).nullable().optional(),\n format: z.string().optional(),\n indent: z.number().optional(),\n version: z.number().optional(),\n})\n\nexport const lexicalSchema = (customNodes?: (typeof LexicalBaseNode)[]) => {\n const BaseNode = z.object({\n type: z.string(),\n children: z.array(z.lazy(() => Node)).optional(),\n direction: z.enum(['ltr']).nullable().optional(),\n format: z.string().optional(),\n indent: z.number().optional(),\n version: z.number().optional(),\n })\n\n const TextNode = BaseNode.extend({\n type: z.literal('text'),\n format: z.number().optional(),\n text: z.string(),\n })\n\n const LinkNode = BaseNode.extend({\n id: z.string(),\n type: z.literal('link'),\n fields: z.object({\n linkType: z.string(),\n newTab: z.boolean(),\n url: z.string(),\n }),\n })\n\n const ListItemNode = BaseNode.extend({\n type: z.literal('listitem'),\n checked: z.boolean().optional(),\n value: z.number(),\n })\n\n const ListNode = BaseNode.extend({\n type: z.literal('list'),\n listType: z.enum(['check', 'number', 'bullet']),\n start: z.number(),\n tag: z.enum(['ul', 'ol']),\n })\n\n const HeadingNode = BaseNode.extend({\n type: z.literal('heading'),\n tag: z.enum(['h1', 'h2', 'h3', 'h4']),\n })\n\n // Example of custom node - wip\n const MediaNode = BaseNode.extend({\n type: z.literal('block'),\n version: z.literal(2),\n fields: z.object({\n id: z.string(),\n media: z.string(),\n position: z.enum(['fullscreen', 'default']),\n blockName: z.string(),\n blockType: z.literal('mediaBlock'),\n }),\n })\n\n const Node = z.union([\n TextNode,\n LinkNode,\n ListItemNode,\n ListNode,\n HeadingNode,\n BaseNode.extend({ type: z.enum(['paragraph', 'quote', 'horizontalrule']) }),\n ...(customNodes || []),\n ])\n\n const RootNode = BaseNode.extend({\n type: z.literal('root'),\n })\n\n return z.object({\n root: RootNode,\n })\n}\n"],"names":["z","LexicalBaseNode","object","type","string","children","array","any","optional","direction","enum","nullable","format","indent","number","version","lexicalSchema","customNodes","BaseNode","lazy","Node","TextNode","extend","literal","text","LinkNode","id","fields","linkType","newTab","boolean","url","ListItemNode","checked","value","ListNode","listType","start","tag","HeadingNode","MediaNode","media","position","blockName","blockType","union","RootNode","root"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,MAAMH,EAAEI,MAAM;IACdC,UAAUL,EAAEM,KAAK,CAACN,EAAEO,GAAG,IAAIC,QAAQ;IACnCC,WAAWT,EAAEU,IAAI,CAAC;QAAC;KAAM,EAAEC,QAAQ,GAAGH,QAAQ;IAC9CI,QAAQZ,EAAEI,MAAM,GAAGI,QAAQ;IAC3BK,QAAQb,EAAEc,MAAM,GAAGN,QAAQ;IAC3BO,SAASf,EAAEc,MAAM,GAAGN,QAAQ;AAC9B,GAAE;AAEF,OAAO,MAAMQ,gBAAgB,CAACC;IAC5B,MAAMC,WAAWlB,EAAEE,MAAM,CAAC;QACxBC,MAAMH,EAAEI,MAAM;QACdC,UAAUL,EAAEM,KAAK,CAACN,EAAEmB,IAAI,CAAC,IAAMC,OAAOZ,QAAQ;QAC9CC,WAAWT,EAAEU,IAAI,CAAC;YAAC;SAAM,EAAEC,QAAQ,GAAGH,QAAQ;QAC9CI,QAAQZ,EAAEI,MAAM,GAAGI,QAAQ;QAC3BK,QAAQb,EAAEc,MAAM,GAAGN,QAAQ;QAC3BO,SAASf,EAAEc,MAAM,GAAGN,QAAQ;IAC9B;IAEA,MAAMa,WAAWH,SAASI,MAAM,CAAC;QAC/BnB,MAAMH,EAAEuB,OAAO,CAAC;QAChBX,QAAQZ,EAAEc,MAAM,GAAGN,QAAQ;QAC3BgB,MAAMxB,EAAEI,MAAM;IAChB;IAEA,MAAMqB,WAAWP,SAASI,MAAM,CAAC;QAC/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AAS;aAAiB;QAAE;WACrEO,eAAe,EAAE;KACtB;IAED,MAAM6B,WAAW5B,SAASI,MAAM,CAAC;QAC/BnB,MAAMH,EAAEuB,OAAO,CAAC;IAClB;IAEA,OAAOvB,EAAEE,MAAM,CAAC;QACd6C,MAAMD;IACR;AACF,EAAC"}
@@ -1 +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,GAAGN,QAAQM,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEN,QAAQO,MAAM,CAAC;;;;;;;;AAQjB,EAAEC,KAAKC,SAAS,CAACZ,eAAe;;;;;;sEAMsC,CAAC;IACrE;IAEA,OAAOI,aAAaS,oBAAoB;AAC1C,EAAC"}
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"}
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAIzD,eAAO,MAAM,eAAe,EAAE,gBA8D7B,CAAA"}
@@ -1,51 +1,14 @@
1
- import { anthropic } from '@ai-sdk/anthropic';
2
- import { streamText } from 'ai';
3
1
  import { generateRichText } from './generateRichText.js';
4
- import { defaultSystemPrompt } from '../../prompts.js';
5
2
  export const AnthropicConfig = {
6
3
  models: [
7
4
  {
8
- id: 'anthropic-claude-text',
9
- name: 'Anthropic Claude',
5
+ id: 'anthropic/claude-3.5-sonnet',
6
+ name: 'Anthropic Claude 3.5 Sonnet',
10
7
  fields: [
11
8
  'text',
12
9
  'textarea'
13
10
  ],
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
- }
11
+ output: 'text'
49
12
  },
50
13
  {
51
14
  id: 'anthropic-claude-object',
@@ -54,6 +17,7 @@ export const AnthropicConfig = {
54
17
  'richText'
55
18
  ],
56
19
  handler: (text, options)=>{
20
+ //TODO: change it to open ai text to speech api
57
21
  return generateRichText(text, options);
58
22
  },
59
23
  output: 'text',
@@ -72,9 +36,6 @@ export const AnthropicConfig = {
72
36
  defaultValue: 'claude-3-5-sonnet-20240620',
73
37
  label: 'Model',
74
38
  options: [
75
- 'claude-3-haiku-20240307',
76
- 'claude-3-sonnet-20240229',
77
- 'claude-3-opus-20240229',
78
39
  'claude-3-5-sonnet-20240620'
79
40
  ]
80
41
  },
@@ -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 { 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"}
1
+ {"version":3,"sources":["../../../../src/ai/models/anthropic/index.ts"],"sourcesContent":["import type { GenerationConfig } from '../../../types.js'\n\nimport { generateRichText } from './generateRichText.js'\n\nexport const AnthropicConfig: GenerationConfig = {\n models: [\n {\n id: 'anthropic/claude-3.5-sonnet',\n name: 'Anthropic Claude 3.5 Sonnet',\n fields: ['text', 'textarea'],\n output: 'text',\n },\n {\n id: 'anthropic-claude-object',\n name: 'Anthropic Claude',\n fields: ['richText'],\n handler: (text: string, options) => {\n //TODO: change it to open ai text to speech api\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: ['claude-3-5-sonnet-20240620'],\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":["generateRichText","AnthropicConfig","models","id","name","fields","output","handler","text","options","settings","type","admin","condition","data","defaultValue","label","provider"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,wBAAuB;AAExD,OAAO,MAAMC,kBAAoC;IAC/CC,QAAQ;QACN;YACEC,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,QAAQ;QACV;QACA;YACEH,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBE,SAAS,CAACC,MAAcC;gBACtB,+CAA+C;gBAC/C,OAAOT,iBAAiBQ,MAAMC;YAChC;YACAH,QAAQ;YACRI,UAAU;gBACRN,MAAM;gBACNO,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAT,QAAQ;oBACN;wBACED,MAAM;wBACNO,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPP,SAAS;4BAAC;yBAA6B;oBACzC;oBACA;wBACEL,MAAM;wBACNO,MAAM;wBACNI,cAAc,CAAC;;;;+EAIoD,CAAC;wBACpEC,OAAO;oBACT;oBACA;wBACEZ,MAAM;wBACNO,MAAM;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDC,UAAU;AACZ,EAAC"}
@@ -1 +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"}
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;AA2GzD,eAAO,MAAM,gBAAgB,EAAE,gBAmC9B,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { SelectField } from '../../../fields/SelectField/SelectField.js';
1
2
  import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js';
2
3
  import { generateVoice } from './generateVoice.js';
3
4
  import { getAllVoices } from './voices.js';
@@ -81,10 +82,19 @@ if (voiceOptions.length) {
81
82
  fields.unshift({
82
83
  name: 'voice_id',
83
84
  type: 'select',
85
+ admin: {
86
+ components: {
87
+ Field: SelectField
88
+ },
89
+ custom: {
90
+ options: voiceOptions
91
+ }
92
+ },
84
93
  defaultValue: voiceOptions[0]?.voice_id,
85
94
  label: 'Voice',
86
95
  options: fieldVoiceOptions,
87
- required: true
96
+ required: true,
97
+ validate: ()=>true
88
98
  });
89
99
  }
90
100
  export const ElevenLabsConfig = {
@@ -1 +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"}
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 { SelectField } from '../../../fields/SelectField/SelectField.js'\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 admin: {\n components: {\n Field: SelectField,\n },\n custom: {\n options: voiceOptions,\n },\n },\n defaultValue: voiceOptions[0]?.voice_id,\n label: 'Voice',\n options: fieldVoiceOptions,\n required: true,\n validate: () => 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":["SelectField","generateFileNameByPrompt","generateVoice","getAllVoices","voices","voiceOptions","map","voice","label","name","value","voice_id","fieldVoiceOptions","option","fields","type","admin","initCollapsed","defaultValue","max","min","required","length","unshift","components","Field","custom","options","validate","ElevenLabsConfig","models","id","handler","text","voiceData","data","alt","file","buffer","mimetype","size","byteLength","output","settings","condition","provider"],"mappings":"AAIA,SAASA,WAAW,QAAQ,6CAA4C;AACxE,SAASC,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;QACNC,OAAO;YACLQ,YAAY;gBACVC,OAAOzB;YACT;YACA0B,QAAQ;gBACNC,SAAStB;YACX;QACF;QACAa,cAAcb,YAAY,CAAC,EAAE,EAAEM;QAC/BH,OAAO;QACPmB,SAASf;QACTS,UAAU;QACVO,UAAU,IAAM;IAClB;AACF;AAEA,OAAO,MAAMC,mBAAqC;IAChDC,QAAQ;QACN;YACEC,IAAI;YACJtB,MAAM;YACNK,QAAQ;gBAAC;aAAS;YAClBkB,SAAS,OAAOC,MAAcN;gBAC5B,MAAMO,YAAY,MAAMhC,cAAc+B,MAAMN;gBAC5C,OAAO;oBACLQ,MAAM;wBACJC,KAAK;oBACP;oBACAC,MAAM;wBACJ5B,MAAM,CAAC,MAAM,EAAER,yBAAyBgC,MAAM,IAAI,CAAC;wBACnDE,MAAMD,UAAUI,MAAM;wBACtBC,UAAU;wBACVC,MAAMN,UAAUI,MAAM,CAACG,UAAU;oBACnC;gBACF;YACF;YACAC,QAAQ;YACRC,UAAU;gBACRlC,MAAM;gBACNM,MAAM;gBACNC,OAAO;oBACL4B,WAAW,CAACT;wBACV,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACArB;gBACAN,OAAO;YACT;QACF;KACD;IACDqC,UAAU;AACZ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/models/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrD,eAAO,MAAM,gBAAgB,EAAE,eAAe,EAI7C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAOrD,eAAO,MAAM,gBAAgB,EAAE,eAAe,EAI7C,CAAA"}
@@ -1,11 +1,11 @@
1
- import * as process from 'node:process';
2
1
  import { AnthropicConfig } from './anthropic/index.js';
3
2
  import { ElevenLabsConfig } from './elevenLabs/index.js';
4
3
  import { OpenAIConfig } from './openai/index.js';
4
+ import * as process from 'node:process';
5
5
  export const GenerationModels = [
6
- ...process.env.OPENAI_API_KEY ? OpenAIConfig.models : [],
7
6
  ...process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : [],
8
- ...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []
7
+ ...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : [],
8
+ ...OpenAIConfig.models
9
9
  ];
10
10
 
11
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/models/index.ts"],"sourcesContent":["import * as process from 'node:process'\n\nimport type { GenerationModel } from '../../types.js'\n\nimport { AnthropicConfig } from './anthropic/index.js'\nimport { ElevenLabsConfig } from './elevenLabs/index.js'\nimport { OpenAIConfig } from './openai/index.js'\n\nexport const GenerationModels: GenerationModel[] = [\n ...(process.env.OPENAI_API_KEY ? OpenAIConfig.models : []),\n ...(process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : []),\n ...(process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []),\n]\n"],"names":["process","AnthropicConfig","ElevenLabsConfig","OpenAIConfig","GenerationModels","env","OPENAI_API_KEY","models","ANTHROPIC_API_KEY","ELEVENLABS_API_KEY"],"mappings":"AAAA,YAAYA,aAAa,eAAc;AAIvC,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,MAAMC,mBAAsC;OAC7CJ,QAAQK,GAAG,CAACC,cAAc,GAAGH,aAAaI,MAAM,GAAG,EAAE;OACrDP,QAAQK,GAAG,CAACG,iBAAiB,GAAGP,gBAAgBM,MAAM,GAAG,EAAE;OAC3DP,QAAQK,GAAG,CAACI,kBAAkB,GAAGP,iBAAiBK,MAAM,GAAG,EAAE;CAClE,CAAA"}
1
+ {"version":3,"sources":["../../../src/ai/models/index.ts"],"sourcesContent":["import type { GenerationModel } from '../../types.js'\n\nimport { AnthropicConfig } from './anthropic/index.js'\nimport { ElevenLabsConfig } from './elevenLabs/index.js'\nimport { OpenAIConfig } from './openai/index.js'\nimport * as process from 'node:process'\n\nexport const GenerationModels: GenerationModel[] = [\n ...(process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : []),\n ...(process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []),\n ...OpenAIConfig.models,\n]\n"],"names":["AnthropicConfig","ElevenLabsConfig","OpenAIConfig","process","GenerationModels","env","ANTHROPIC_API_KEY","models","ELEVENLABS_API_KEY"],"mappings":"AAEA,SAASA,eAAe,QAAQ,uBAAsB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,YAAYC,aAAa,eAAc;AAEvC,OAAO,MAAMC,mBAAsC;OAC7CD,QAAQE,GAAG,CAACC,iBAAiB,GAAGN,gBAAgBO,MAAM,GAAG,EAAE;OAC3DJ,QAAQE,GAAG,CAACG,kBAAkB,GAAGP,iBAAiBM,MAAM,GAAG,EAAE;OAC9DL,aAAaK,MAAM;CACvB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import { openai } from '@ai-sdk/openai'\nimport { streamObject } from 'ai'\n\nimport { exampleOutput } from '../example.js'\n\nexport const generateRichText = async (text: string, options: any) => {\n const streamResult = await streamObject({\n model: openai(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 return streamResult.toTextStreamResponse()\n}\n"],"names":["openai","streamObject","exampleOutput","generateRichText","text","options","streamResult","model","prompt","schema","editorSchema","system","layout","JSON","stringify","toTextStreamResponse"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,YAAY,QAAQ,KAAI;AAEjC,SAASC,aAAa,QAAQ,gBAAe;AAE7C,OAAO,MAAMC,mBAAmB,OAAOC,MAAcC;IACnD,MAAMC,eAAe,MAAML,aAAa;QACtCM,OAAOP,OAAOK,QAAQE,KAAK;QAC3BC,QAAQJ;QACRK,QAAQJ,QAAQK,YAAY;QAC5BC,QAAQ,GAAGN,QAAQM,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEN,QAAQO,MAAM,CAAC;;;;;;;;AAQjB,EAAEC,KAAKC,SAAS,CAACZ,eAAe;;;;;;sEAMsC,CAAC;IACrE;IACA,OAAOI,aAAaS,oBAAoB;AAC1C,EAAC"}
1
+ {"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import { openai } from '@ai-sdk/openai'\nimport { streamObject } from 'ai'\n\nimport { exampleOutput } from '../example.js'\n\nexport const generateRichText = async (text: string, options: any) => {\n const streamResult = await streamObject({\n model: openai(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 return streamResult.toTextStreamResponse()\n}\n"],"names":["openai","streamObject","exampleOutput","generateRichText","text","options","streamResult","model","prompt","schema","editorSchema","system","layout","JSON","stringify","toTextStreamResponse"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,YAAY,QAAQ,KAAI;AAEjC,SAASC,aAAa,QAAQ,gBAAe;AAE7C,OAAO,MAAMC,mBAAmB,OAAOC,MAAcC;IACnD,MAAMC,eAAe,MAAML,aAAa;QACtCM,OAAOP,OAAOK,QAAQE,KAAK;QAC3BC,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;IACA,OAAOI,aAAaS,oBAAoB;AAC1C,EAAC"}
@@ -4,8 +4,8 @@ import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.j
4
4
  import { generateImage } from './generateImage.js';
5
5
  import { generateRichText } from './generateRichText.js';
6
6
  import { generateVoice } from './generateVoice.js';
7
- import { defaultSystemPrompt } from '../../prompts.js';
8
7
  //TODO: Simplify this file by moving the handlers to separate files and remove duplicate code
8
+ //TODO: every config must have default settings selected
9
9
  export const OpenAIConfig = {
10
10
  models: [
11
11
  {
@@ -19,9 +19,9 @@ export const OpenAIConfig = {
19
19
  const streamTextResult = await streamText({
20
20
  model: openai(options.model),
21
21
  prompt,
22
- system: options.system || defaultSystemPrompt
22
+ system: options.system
23
23
  });
24
- return streamTextResult.toDataStreamResponse();
24
+ return streamTextResult.toAIStreamResponse();
25
25
  },
26
26
  output: 'text',
27
27
  settings: {
@@ -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 { openai } from '@ai-sdk/openai'\nimport { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\nimport { defaultSystemPrompt } from '../../prompts.js'\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: 'openai-gpt-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: 'openai-gpt-text-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'openai-gpt-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: 'openai-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: 'openai-gpt-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: 'openai-gpt-object-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'openai-gpt-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 name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\nYou are a highly skilled and professional blog writer,\nrenowned for crafting engaging and well-organized articles.\nWhen given a title, you meticulously create blogs that are not only\ninformative and accurate but also captivating and beautifully structured.`,\n label: 'System prompt',\n },\n {\n /**TODO's:\n * - Layouts can be saved in as an array\n * - user can add their own layout to collections and use it later for generate specific rich text\n * - user can select previously added layout\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: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["openai","streamText","generateFileNameByPrompt","generateImage","generateRichText","generateVoice","defaultSystemPrompt","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,MAAM,QAAQ,iBAAgB;AACvC,SAASC,UAAU,QAAQ,KAAI;AAI/B,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,mBAAmB,QAAQ,mBAAkB;AAEtD,6FAA6F;AAC7F,OAAO,MAAMC,eAAiC;IAC5CC,QAAQ;QACN;YACEC,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,SAAS,OACPC,QACAC;gBAEA,MAAMC,mBAAmB,MAAMd,WAAW;oBACxCe,OAAOhB,OAAOc,QAAQE,KAAK;oBAC3BH;oBACAI,QAAQH,QAAQG,MAAM,IAAIX;gBAC5B;gBAEA,OAAOS,iBAAiBG,oBAAoB;YAC9C;YACAC,QAAQ;YACRC,UAAU;gBACRV,MAAM;gBACNW,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAb,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAgB;oBACpE;iBACD;gBACDY,OAAO;YACT;QACF;QACA;YACEjB,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAS;YAClBC,SAAS,OAAOC,QAAgBC;gBAC9B,MAAMa,YAAY,MAAMxB,cAAcU,QAAQC;gBAC9C,OAAO;oBACL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ACT;iBACD;gBACDA,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 { openai } from '@ai-sdk/openai'\nimport { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\n\n//TODO: Simplify this file by moving the handlers to separate files and remove duplicate code\n//TODO: every config must have default settings selected\nexport const OpenAIConfig: GenerationConfig = {\n models: [\n {\n id: 'openai-gpt-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,\n })\n\n return streamTextResult.toAIStreamResponse()\n },\n output: 'text',\n settings: {\n name: 'openai-gpt-text-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'openai-gpt-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: 'openai-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: 'openai-gpt-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: 'openai-gpt-object-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'openai-gpt-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 name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\nYou are a highly skilled and professional blog writer,\nrenowned for crafting engaging and well-organized articles.\nWhen given a title, you meticulously create blogs that are not only\ninformative and accurate but also captivating and beautifully structured.`,\n label: 'System prompt',\n },\n {\n /**TODO's:\n * - Layouts can be saved in as an array\n * - user can add their own layout to collections and use it later for generate specific rich text\n * - user can select previously added layout\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: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["openai","streamText","generateFileNameByPrompt","generateImage","generateRichText","generateVoice","OpenAIConfig","models","id","name","fields","handler","prompt","options","streamTextResult","model","system","toAIStreamResponse","output","settings","type","admin","condition","data","defaultValue","label","imageData","alt","file","buffer","mimetype","size","byteLength","text","voiceData","max","min","provider"],"mappings":"AAGA,SAASA,MAAM,QAAQ,iBAAgB;AAC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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;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBC,SAAS,CAACsB,MAAcpB;gBACtB,OAAOT,iBAAiB6B,MAAMpB;YAChC;YACAK,QAAQ;YACRC,UAAU;gBACRV,MAAM;gBACNW,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAb,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAoB;oBACxE;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc,CAAC;;;;yEAI8C,CAAC;wBAC9DC,OAAO;oBACT;oBACA;wBACE;;;;aAIC,GACDhB,MAAM;wBACNW,MAAM;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDY,UAAU;AACZ,EAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const beerCssClasses = "\nabsolute left, right, top, bottom, front, back, small, medium, large\n\n<article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding\n\nbadge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round\n\n<details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active\n\nfield small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea\n\nfixed left, right, top, bottom, front, back, small, medium, large\n\n<h1>...<h6> small, medium, large\n\n<li> max, divider, small-divider, medium-divider, large-divider\n\nrow, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical\n\nsnackbar top, bottom, active\n\n<summary>\n\n<table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed\n\ntabs left-align, right-align, center-align, horizontal, vertical, min, max\n\ntooltip left, right, top, bottom, max\n";
2
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/ai/models/style.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,owCA4B1B,CAAA"}
@@ -0,0 +1,31 @@
1
+ export const beerCssClasses = `
2
+ absolute left, right, top, bottom, front, back, small, medium, large
3
+
4
+ <article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding
5
+
6
+ badge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round
7
+
8
+ <details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active
9
+
10
+ field small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea
11
+
12
+ fixed left, right, top, bottom, front, back, small, medium, large
13
+
14
+ <h1>...<h6> small, medium, large
15
+
16
+ <li> max, divider, small-divider, medium-divider, large-divider
17
+
18
+ row, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical
19
+
20
+ snackbar top, bottom, active
21
+
22
+ <summary>
23
+
24
+ <table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed
25
+
26
+ tabs left-align, right-align, center-align, horizontal, vertical, min, max
27
+
28
+ tooltip left, right, top, bottom, max
29
+ `;
30
+
31
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ai/models/style.ts"],"sourcesContent":["export const beerCssClasses = `\nabsolute left, right, top, bottom, front, back, small, medium, large\n\n<article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding\n\nbadge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round\n\n<details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active\n\nfield small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea\n\nfixed left, right, top, bottom, front, back, small, medium, large\n\n<h1>...<h6> small, medium, large\n\n<li> max, divider, small-divider, medium-divider, large-divider\n\nrow, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical\n\nsnackbar top, bottom, active\n\n<summary>\n\n<table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed\n\ntabs left-align, right-align, center-align, horizontal, vertical, min, max\n\ntooltip left, right, top, bottom, max\n`\n"],"names":["beerCssClasses"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/B,CAAC,CAAA"}
@@ -1,25 +1,24 @@
1
1
  import type { ActionMenuItems } from '../types.js';
2
2
  type ActionPromptOptions = {
3
- layout?: string;
4
- locale?: string;
5
3
  prompt?: string;
6
4
  systemPrompt?: string;
5
+ locale?: string;
6
+ layout?: string;
7
7
  };
8
8
  type ActionPrompt = {
9
- layout?: (options?: ActionPromptOptions) => string;
10
9
  name: ActionMenuItems;
11
10
  system: (options: ActionPromptOptions) => string;
11
+ layout?: (options?: ActionPromptOptions) => string;
12
12
  };
13
- export declare const defaultSystemPrompt = "IMPORTANT INSTRUCTION:\nProduce only the requested output text.\nDo not add any explanations, comments, or engagement.\nDo not use quotation marks in the response.\nBEGIN OUTPUT:";
14
13
  export declare const defaultPrompts: ActionPrompt[];
15
- export declare const seedPrompts: ({ fieldLabel, fieldSchemaPaths, fieldType, path }: {
14
+ export declare const seedPrompts: ({ fieldLabel, fieldType, path, fieldSchemaPaths }: {
16
15
  fieldLabel: any;
17
- fieldSchemaPaths: any;
18
16
  fieldType: any;
19
17
  path: any;
18
+ fieldSchemaPaths: any;
20
19
  }) => {
21
- prompt: string;
22
20
  system: string;
21
+ prompt: string;
23
22
  };
24
23
  export {};
25
24
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ai/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,mBAAmB,GAAG;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;IAClD,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAA;CACjD,CAAA;AAGD,eAAO,MAAM,mBAAmB,uLAIlB,CAAA;AAEd,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;CA6GvB,CAAA"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ai/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,mBAAmB,GAAG;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAA;IAChD,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;CACnD,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;CA2GvB,CAAA"}
@@ -1,9 +1,3 @@
1
- //TODO: This is a temporary solution make use of structured object in API
2
- export const defaultSystemPrompt = `IMPORTANT INSTRUCTION:
3
- Produce only the requested output text.
4
- Do not add any explanations, comments, or engagement.
5
- Do not use quotation marks in the response.
6
- BEGIN OUTPUT:`;
7
1
  export const defaultPrompts = [
8
2
  {
9
3
  name: 'Rephrase',
@@ -60,10 +54,6 @@ export const defaultPrompts = [
60
54
  },
61
55
  {
62
56
  name: 'Summarize',
63
- layout: ()=>`
64
- [heading] - Summary
65
- [paragraph] - Your summary goes here...
66
- `,
67
57
  system: ()=>`You are an expert at summarizing information. Your task is to create a concise summary of the given text that captures its key points and essential details while preserving the original meaning.
68
58
 
69
59
  INSTRUCTIONS:
@@ -73,7 +63,11 @@ INSTRUCTIONS:
73
63
  4. Preserve the original tone and intent of the text.
74
64
  5. Ensure your summary is approximately 25-30% of the original text length.
75
65
  6. Use clear and precise language, avoiding unnecessary jargon or complexity.
76
- `
66
+ `,
67
+ layout: ()=>`
68
+ [heading] - Summary
69
+ [paragraph] - Your summary goes here...
70
+ `
77
71
  },
78
72
  {
79
73
  name: 'Tone',
@@ -88,7 +82,7 @@ INSTRUCTIONS:
88
82
  },
89
83
  {
90
84
  name: 'Translate',
91
- system: ({ locale, prompt = '', systemPrompt = '' })=>`You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.
85
+ system: ({ prompt = '', systemPrompt = '', locale })=>`You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.
92
86
 
93
87
  -------------
94
88
  INSTRUCTIONS:
@@ -100,16 +94,8 @@ INSTRUCTIONS:
100
94
  -------------`
101
95
  }
102
96
  ];
103
- export const seedPrompts = ({ fieldLabel, fieldSchemaPaths, fieldType, path })=>{
97
+ export const seedPrompts = ({ fieldLabel, fieldType, path, fieldSchemaPaths })=>{
104
98
  return {
105
- prompt: `field-type: ${fieldType}
106
- field-name: ${fieldLabel}
107
- schema-path: ${path}
108
-
109
- Give me a prompt that relate to the given field type and schema path.
110
-
111
- Generated prompt:
112
- `,
113
99
  system: `# AI Assistant for CMS Prompt Generation
114
100
 
115
101
  Your role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.
@@ -192,21 +178,27 @@ For upload:
192
178
  field-type: upload
193
179
  field-name: Featured Image
194
180
  schema-path: posts.image
195
- Generated prompt: Imagine {{ title }}
181
+ Generated prompt: Imagine a high-quality featured image for '{{ title }}
196
182
 
197
183
  For upload:
198
184
  field-type: upload
199
185
  field-name: Voice
200
186
  schema-path: posts.upload
201
- Generated prompt: {{ title }} {{ toLexicalHTML [provide schema-path for richText] }}
187
+ Generated prompt: {{ title }} {{ toLexicalHTML [provide field-path for richText] }}
202
188
 
203
189
 
204
190
  Remember to adapt the prompts based on the specific schema-path provided, considering the context and purpose of the field within the CMS structure. The prompts should directly instruct the AI model on what content to generate or describe, without assuming a user perspective.
205
191
 
206
192
  Schema Map Context:
207
193
  ${JSON.stringify(fieldSchemaPaths)}
194
+ `,
195
+ prompt: `field-type: ${fieldType}
196
+ field-name: ${fieldLabel}
197
+ schema-path: ${path}
208
198
 
209
- ${defaultSystemPrompt}
199
+ Give me a prompt that relate to the given field type and schema path.
200
+
201
+ Generated prompt:
210
202
  `
211
203
  };
212
204
  };