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

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 (194) 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 +3 -3
  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.js +2 -2
  13. package/dist/ai/models/index.js.map +1 -1
  14. package/dist/ai/models/openai/generateRichText.js.map +1 -1
  15. package/dist/ai/models/openai/index.d.ts.map +1 -1
  16. package/dist/ai/models/openai/index.js +2 -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 +0 -1
  23. package/dist/ai/prompts.d.ts.map +1 -1
  24. package/dist/ai/prompts.js +2 -8
  25. package/dist/ai/prompts.js.map +1 -1
  26. package/dist/ai/utils/generateFileNameByPrompt.js.map +1 -1
  27. package/dist/collections/Instructions.d.ts.map +1 -1
  28. package/dist/collections/Instructions.js +12 -9
  29. package/dist/collections/Instructions.js.map +1 -1
  30. package/dist/defaults.d.ts +1 -1
  31. package/dist/defaults.d.ts.map +1 -1
  32. package/dist/defaults.js +1 -1
  33. package/dist/defaults.js.map +1 -1
  34. package/dist/endpoints/index.d.ts +1 -1
  35. package/dist/endpoints/index.d.ts.map +1 -1
  36. package/dist/endpoints/index.js +51 -17
  37. package/dist/endpoints/index.js.map +1 -1
  38. package/dist/exports/fields.d.ts +1 -3
  39. package/dist/exports/fields.d.ts.map +1 -1
  40. package/dist/exports/fields.js +0 -3
  41. package/dist/exports/fields.js.map +1 -1
  42. package/dist/fields/DescriptionField/DescriptionField.d.ts +3 -0
  43. package/dist/fields/DescriptionField/DescriptionField.d.ts.map +1 -0
  44. package/dist/fields/DescriptionField/DescriptionField.js +15 -0
  45. package/dist/fields/DescriptionField/DescriptionField.js.map +1 -0
  46. package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts +4 -0
  47. package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts.map +1 -0
  48. package/dist/fields/{ComposeField/ComposeField.js → DescriptionField/DescriptionFieldComponent.js} +5 -5
  49. package/dist/fields/DescriptionField/DescriptionFieldComponent.js.map +1 -0
  50. package/dist/fields/LexicalEditor/ActionsFeatureComponent.d.ts +2 -0
  51. package/dist/fields/LexicalEditor/ActionsFeatureComponent.d.ts.map +1 -0
  52. package/dist/fields/LexicalEditor/{ComposeFeatureComponent.js → ActionsFeatureComponent.js} +5 -5
  53. package/dist/fields/LexicalEditor/ActionsFeatureComponent.js.map +1 -0
  54. package/dist/fields/LexicalEditor/feature.client.d.ts +4 -1
  55. package/dist/fields/LexicalEditor/feature.client.d.ts.map +1 -1
  56. package/dist/fields/LexicalEditor/feature.client.js +2 -2
  57. package/dist/fields/LexicalEditor/feature.client.js.map +1 -1
  58. package/dist/fields/LexicalEditor/feature.server.d.ts +7 -1
  59. package/dist/fields/LexicalEditor/feature.server.d.ts.map +1 -1
  60. package/dist/fields/LexicalEditor/feature.server.js +11 -3
  61. package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
  62. package/dist/fields/PromptEditorField/PromptEditorField.d.ts +2 -2
  63. package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
  64. package/dist/fields/PromptEditorField/PromptEditorField.js +51 -32
  65. package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
  66. package/dist/fields/SelectField/SelectField.d.ts +2 -9
  67. package/dist/fields/SelectField/SelectField.d.ts.map +1 -1
  68. package/dist/fields/SelectField/SelectField.js +23 -26
  69. package/dist/fields/SelectField/SelectField.js.map +1 -1
  70. package/dist/index.d.ts +2 -2
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +3 -3
  73. package/dist/index.js.map +1 -1
  74. package/dist/init.d.ts +1 -2
  75. package/dist/init.d.ts.map +1 -1
  76. package/dist/init.js +9 -26
  77. package/dist/init.js.map +1 -1
  78. package/dist/plugin.d.ts.map +1 -1
  79. package/dist/plugin.js +8 -27
  80. package/dist/plugin.js.map +1 -1
  81. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts +3 -1
  82. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts.map +1 -1
  83. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  84. package/dist/providers/InstructionsProvider/hook.d.ts +9 -0
  85. package/dist/providers/InstructionsProvider/hook.d.ts.map +1 -0
  86. package/dist/providers/InstructionsProvider/hook.js +17 -0
  87. package/dist/providers/InstructionsProvider/hook.js.map +1 -0
  88. package/dist/providers/InstructionsProvider/index.d.ts +5 -0
  89. package/dist/providers/InstructionsProvider/index.d.ts.map +1 -0
  90. package/dist/providers/InstructionsProvider/index.js +10 -0
  91. package/dist/providers/InstructionsProvider/index.js.map +1 -0
  92. package/dist/types.d.ts +1 -2
  93. package/dist/types.d.ts.map +1 -1
  94. package/dist/types.js.map +1 -1
  95. package/dist/ui/Actions/Actions.d.ts +5 -0
  96. package/dist/ui/Actions/Actions.d.ts.map +1 -0
  97. package/dist/ui/{Compose/Compose.js → Actions/Actions.js} +9 -9
  98. package/dist/ui/Actions/Actions.js.map +1 -0
  99. package/dist/ui/{Compose → Actions}/UndoRedoActions.d.ts.map +1 -1
  100. package/dist/ui/{Compose → Actions}/UndoRedoActions.js +2 -15
  101. package/dist/ui/Actions/UndoRedoActions.js.map +1 -0
  102. package/dist/ui/{Compose → Actions}/hooks/menu/Item.d.ts.map +1 -1
  103. package/dist/ui/{Compose → Actions}/hooks/menu/Item.js.map +1 -1
  104. package/dist/ui/Actions/hooks/menu/TranslateMenu.d.ts.map +1 -0
  105. package/dist/ui/{Compose → Actions}/hooks/menu/TranslateMenu.js.map +1 -1
  106. package/dist/ui/{Compose → Actions}/hooks/menu/items.d.ts.map +1 -1
  107. package/dist/ui/{Compose → Actions}/hooks/menu/items.js.map +1 -1
  108. package/dist/ui/{Compose → Actions}/hooks/menu/itemsMap.d.ts.map +1 -1
  109. package/dist/ui/{Compose → Actions}/hooks/menu/itemsMap.js.map +1 -1
  110. package/dist/ui/{Compose → Actions}/hooks/menu/useMenu.d.ts.map +1 -1
  111. package/dist/ui/{Compose → Actions}/hooks/menu/useMenu.js.map +1 -1
  112. package/dist/ui/{Compose → Actions}/hooks/useGenerate.d.ts.map +1 -1
  113. package/dist/ui/{Compose → Actions}/hooks/useGenerate.js +6 -5
  114. package/dist/ui/Actions/hooks/useGenerate.js.map +1 -0
  115. package/dist/ui/Actions/hooks/useHistory.d.ts.map +1 -0
  116. package/dist/ui/{Compose → Actions}/hooks/useHistory.js +1 -3
  117. package/dist/ui/Actions/hooks/useHistory.js.map +1 -0
  118. package/dist/ui/Floatype/Floatype.d.ts +21 -0
  119. package/dist/ui/Floatype/Floatype.d.ts.map +1 -0
  120. package/dist/ui/Floatype/Floatype.js +245 -0
  121. package/dist/ui/Floatype/Floatype.js.map +1 -0
  122. package/dist/ui/Floatype/floatype.module.css +25 -0
  123. package/dist/utilities/getFieldBySchemaPath.d.ts +2 -2
  124. package/dist/utilities/getFieldBySchemaPath.d.ts.map +1 -1
  125. package/dist/utilities/getFieldBySchemaPath.js.map +1 -1
  126. package/dist/utilities/updateFieldsConfig.d.ts.map +1 -1
  127. package/dist/utilities/updateFieldsConfig.js +8 -14
  128. package/dist/utilities/updateFieldsConfig.js.map +1 -1
  129. package/package.json +30 -49
  130. package/dist/ai/schemas/lexical.schema.d.ts.map +0 -1
  131. package/dist/ai/schemas/lexical.schema.js.map +0 -1
  132. package/dist/exports/client.d.ts +0 -3
  133. package/dist/exports/client.d.ts.map +0 -1
  134. package/dist/exports/client.js +0 -4
  135. package/dist/exports/client.js.map +0 -1
  136. package/dist/fields/ComposeField/ComposeField.d.ts +0 -4
  137. package/dist/fields/ComposeField/ComposeField.d.ts.map +0 -1
  138. package/dist/fields/ComposeField/ComposeField.js.map +0 -1
  139. package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts +0 -2
  140. package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts.map +0 -1
  141. package/dist/fields/LexicalEditor/ComposeFeatureComponent.js.map +0 -1
  142. package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts +0 -8
  143. package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts.map +0 -1
  144. package/dist/libraries/autocomplete/AutocompleteTextArea.js +0 -437
  145. package/dist/libraries/autocomplete/AutocompleteTextArea.js.map +0 -1
  146. package/dist/libraries/autocomplete/AutocompleteTextArea.module.scss +0 -35
  147. package/dist/libraries/handlebars/asyncHandlebars.d.ts +0 -2
  148. package/dist/libraries/handlebars/asyncHandlebars.d.ts.map +0 -1
  149. package/dist/libraries/handlebars/asyncHandlebars.js +0 -5
  150. package/dist/libraries/handlebars/asyncHandlebars.js.map +0 -1
  151. package/dist/libraries/handlebars/helpers.d.ts +0 -2
  152. package/dist/libraries/handlebars/helpers.d.ts.map +0 -1
  153. package/dist/libraries/handlebars/helpers.js +0 -22
  154. package/dist/libraries/handlebars/helpers.js.map +0 -1
  155. package/dist/libraries/handlebars/helpersMap.d.ts +0 -12
  156. package/dist/libraries/handlebars/helpersMap.d.ts.map +0 -1
  157. package/dist/libraries/handlebars/helpersMap.js +0 -13
  158. package/dist/libraries/handlebars/helpersMap.js.map +0 -1
  159. package/dist/libraries/handlebars/replacePlaceholders.d.ts +0 -2
  160. package/dist/libraries/handlebars/replacePlaceholders.d.ts.map +0 -1
  161. package/dist/libraries/handlebars/replacePlaceholders.js +0 -8
  162. package/dist/libraries/handlebars/replacePlaceholders.js.map +0 -1
  163. package/dist/providers/InstructionsProvider/useInstructions.d.ts +0 -4
  164. package/dist/providers/InstructionsProvider/useInstructions.d.ts.map +0 -1
  165. package/dist/providers/InstructionsProvider/useInstructions.js +0 -38
  166. package/dist/providers/InstructionsProvider/useInstructions.js.map +0 -1
  167. package/dist/ui/Compose/Compose.d.ts +0 -9
  168. package/dist/ui/Compose/Compose.d.ts.map +0 -1
  169. package/dist/ui/Compose/Compose.js.map +0 -1
  170. package/dist/ui/Compose/UndoRedoActions.js.map +0 -1
  171. package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts.map +0 -1
  172. package/dist/ui/Compose/hooks/useGenerate.js.map +0 -1
  173. package/dist/ui/Compose/hooks/useHistory.d.ts.map +0 -1
  174. package/dist/ui/Compose/hooks/useHistory.js.map +0 -1
  175. package/dist/utilities/getFieldInfo.d.ts +0 -3
  176. package/dist/utilities/getFieldInfo.d.ts.map +0 -1
  177. package/dist/utilities/getFieldInfo.js +0 -14
  178. package/dist/utilities/getFieldInfo.js.map +0 -1
  179. /package/dist/ai/{schemas → editor}/lexical.schema.js +0 -0
  180. /package/dist/ui/{Compose → Actions}/UndoRedoActions.d.ts +0 -0
  181. /package/dist/ui/{Compose/compose.module.scss → Actions/actions.module.scss} +0 -0
  182. /package/dist/ui/{Compose → Actions}/hooks/menu/Item.d.ts +0 -0
  183. /package/dist/ui/{Compose → Actions}/hooks/menu/Item.js +0 -0
  184. /package/dist/ui/{Compose → Actions}/hooks/menu/TranslateMenu.d.ts +0 -0
  185. /package/dist/ui/{Compose → Actions}/hooks/menu/TranslateMenu.js +0 -0
  186. /package/dist/ui/{Compose → Actions}/hooks/menu/items.d.ts +0 -0
  187. /package/dist/ui/{Compose → Actions}/hooks/menu/items.js +0 -0
  188. /package/dist/ui/{Compose → Actions}/hooks/menu/itemsMap.d.ts +0 -0
  189. /package/dist/ui/{Compose → Actions}/hooks/menu/itemsMap.js +0 -0
  190. /package/dist/ui/{Compose → Actions}/hooks/menu/menu.module.scss +0 -0
  191. /package/dist/ui/{Compose → Actions}/hooks/menu/useMenu.d.ts +0 -0
  192. /package/dist/ui/{Compose → Actions}/hooks/menu/useMenu.js +0 -0
  193. /package/dist/ui/{Compose → Actions}/hooks/useGenerate.d.ts +0 -0
  194. /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":"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"}
@@ -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":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAIzD,eAAO,MAAM,eAAe,EAAE,gBA0G7B,CAAA"}
@@ -1,7 +1,6 @@
1
1
  import { anthropic } from '@ai-sdk/anthropic';
2
2
  import { streamText } from 'ai';
3
3
  import { generateRichText } from './generateRichText.js';
4
- import { defaultSystemPrompt } from '../../prompts.js';
5
4
  export const AnthropicConfig = {
6
5
  models: [
7
6
  {
@@ -17,9 +16,9 @@ export const AnthropicConfig = {
17
16
  const streamTextResult = await streamText({
18
17
  model: anthropic(options.model),
19
18
  prompt,
20
- system: options.system || defaultSystemPrompt
19
+ system: options.system || 'IMPORTANT: JUST PRODUCE THE OUTPUT, DO NOT ENGAGE!'
21
20
  });
22
- return streamTextResult.toDataStreamResponse();
21
+ return streamTextResult.toAIStreamResponse();
23
22
  },
24
23
  output: 'text',
25
24
  settings: {
@@ -54,6 +53,7 @@ export const AnthropicConfig = {
54
53
  'richText'
55
54
  ],
56
55
  handler: (text, options)=>{
56
+ //TODO: change it to open ai text to speech api
57
57
  return generateRichText(text, options);
58
58
  },
59
59
  output: 'text',
@@ -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 { anthropic } from '@ai-sdk/anthropic'\nimport { openai } from '@ai-sdk/openai'\nimport { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { generateRichText } from './generateRichText.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 || 'IMPORTANT: JUST PRODUCE THE OUTPUT, DO NOT ENGAGE!',\n })\n\n return streamTextResult.toAIStreamResponse()\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 //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: [\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","AnthropicConfig","models","id","name","fields","handler","prompt","options","console","log","streamTextResult","model","system","toAIStreamResponse","output","settings","type","admin","condition","data","defaultValue","label","text","provider"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAE7C,SAASC,UAAU,QAAQ,KAAI;AAI/B,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,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,MAAMZ,WAAW;oBACxCa,OAAOd,UAAUU,QAAQI,KAAK;oBAC9BL;oBACAM,QAAQL,QAAQK,MAAM,IAAI;gBAC5B;gBAEA,OAAOF,iBAAiBG,kBAAkB;YAC5C;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,+CAA+C;gBAC/C,OAAOR,iBAAiBuB,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 +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"}
@@ -3,9 +3,9 @@ import { AnthropicConfig } from './anthropic/index.js';
3
3
  import { ElevenLabsConfig } from './elevenLabs/index.js';
4
4
  import { OpenAIConfig } from './openai/index.js';
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
+ ...process.env.OPENAI_API_KEY ? 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 * 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.ANTHROPIC_API_KEY ? AnthropicConfig.models : []),\n ...(process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []),\n ...(process.env.OPENAI_API_KEY ? OpenAIConfig.models : []),\n]\n"],"names":["process","AnthropicConfig","ElevenLabsConfig","OpenAIConfig","GenerationModels","env","ANTHROPIC_API_KEY","models","ELEVENLABS_API_KEY","OPENAI_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,iBAAiB,GAAGL,gBAAgBM,MAAM,GAAG,EAAE;OAC3DP,QAAQK,GAAG,CAACG,kBAAkB,GAAGN,iBAAiBK,MAAM,GAAG,EAAE;OAC7DP,QAAQK,GAAG,CAACI,cAAc,GAAGN,aAAaI,MAAM,GAAG,EAAE;CAC1D,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AASzD,eAAO,MAAM,YAAY,EAAE,gBAkO1B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAQzD,eAAO,MAAM,YAAY,EAAE,gBAkO1B,CAAA"}
@@ -4,7 +4,6 @@ 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
9
8
  export const OpenAIConfig = {
10
9
  models: [
@@ -19,9 +18,9 @@ export const OpenAIConfig = {
19
18
  const streamTextResult = await streamText({
20
19
  model: openai(options.model),
21
20
  prompt,
22
- system: options.system || defaultSystemPrompt
21
+ system: options.system
23
22
  });
24
- return streamTextResult.toDataStreamResponse();
23
+ return streamTextResult.toAIStreamResponse();
25
24
  },
26
25
  output: 'text',
27
26
  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":"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"}
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\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":"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"}
@@ -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"}
@@ -10,7 +10,6 @@ type ActionPrompt = {
10
10
  name: ActionMenuItems;
11
11
  system: (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
14
  export declare const seedPrompts: ({ fieldLabel, fieldSchemaPaths, fieldType, path }: {
16
15
  fieldLabel: any;
@@ -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,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;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;CA6GvB,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',
@@ -198,7 +192,7 @@ For upload:
198
192
  field-type: upload
199
193
  field-name: Voice
200
194
  schema-path: posts.upload
201
- Generated prompt: {{ title }} {{ toLexicalHTML [provide schema-path for richText] }}
195
+ Generated prompt: {{ title }} {{ toLexicalHTML [provide field-path for richText] }}
202
196
 
203
197
 
204
198
  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.
@@ -206,7 +200,7 @@ Remember to adapt the prompts based on the specific schema-path provided, consid
206
200
  Schema Map Context:
207
201
  ${JSON.stringify(fieldSchemaPaths)}
208
202
 
209
- ${defaultSystemPrompt}
203
+ IMPORTANT: JUST PRODUCE THE OUTPUT, DO NOT ENGAGE!
210
204
  `
211
205
  };
212
206
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ai/prompts.ts"],"sourcesContent":["import type { ActionMenuItems } from '../types.js'\n\ntype ActionPromptOptions = {\n layout?: string\n locale?: string\n prompt?: string\n systemPrompt?: string\n}\n\ntype ActionPrompt = {\n layout?: (options?: ActionPromptOptions) => string\n name: ActionMenuItems\n system: (options: ActionPromptOptions) => string\n}\n\n//TODO: This is a temporary solution make use of structured object in API\nexport 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:`\n\nexport const defaultPrompts: ActionPrompt[] = [\n {\n name: 'Rephrase',\n system: ({\n prompt = '',\n systemPrompt = '',\n }) => `You are a skilled language expert. Rephrase the given text while maintaining its original meaning, tone, and emotional content. Use different words and sentence structures where possible, but preserve the overall style and sentiment of the original.\n \n -------------\n INSTRUCTIONS:\n - Rephrase the text according to the guidelines of the ORIGINAL SYSTEM PROMPT, if provided.\n - Retain the original meaning, tone, and emotional content.\n - Use different vocabulary and sentence structures where appropriate.\n - Ensure the rephrased text conveys the same message and feeling as the original.\n ${prompt ? '\\n\\nPrevious prompt:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n {\n name: 'Expand',\n system:\n () => `You are a creative writer and subject matter expert. Expand the given text by adding depth, detail, and relevant information while maintaining the original tone and style.\n \n -------------\n INSTRUCTIONS:\n - Understand the main ideas and tone of the text.\n - Add more details, examples, explanations, or context.\n - Maintain the original tone, style, and intent.\n - Ensure the expanded version flows naturally and coherently.\n - Do not contradict or alter the original meaning.\n -------------`,\n },\n {\n name: 'Proofread',\n system:\n () => `You are an English language expert. Proofread the given text, focusing on correcting grammar and spelling mistakes without altering the content, style, or tone.\n \n -------------\n INSTRUCTIONS:\n - Correct grammar and spelling errors.\n - Do not change the content, meaning, tone, or style.\n - Return the full text, whether corrections were made or not.\n - Do not provide additional comments or analysis.\n -------------`,\n },\n {\n name: 'Simplify',\n system: ({\n prompt = '',\n }) => `You are a skilled communicator specializing in clear and concise writing. Simplify the given text to make it easier to understand while retaining its core message.\n \n -------------\n INSTRUCTIONS:\n - Simplify the language, using more common words and shorter sentences.\n - Remove unnecessary details or jargon while keeping essential information.\n - Maintain the original meaning and key points.\n - Aim for clarity and readability for a general audience.\n - The simplified text should be more concise than the original.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n -------------`,\n },\n {\n name: 'Summarize',\n layout: () => `\n[heading] - Summary\n[paragraph] - Your summary goes here...\n `,\n system: () =>\n `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.\n\nINSTRUCTIONS:\n1. Carefully read and analyze the provided text.\n2. Identify and extract the main ideas and crucial supporting details.\n3. Condense the information into a clear and coherent summary that maintains the core message.\n4. Preserve the original tone and intent of the text.\n5. Ensure your summary is approximately 25-30% of the original text length.\n6. Use clear and precise language, avoiding unnecessary jargon or complexity.\n`,\n },\n {\n name: 'Tone',\n system: () =>\n `You are a tone adjustment specialist. Modify the tone of the given text as specified while keeping the original message and content intact.\n \n -------------\n INSTRUCTIONS:\n - Adjust the tone to match the specified style (e.g., formal, informal, professional, friendly).\n - Maintain the original content and meaning.\n - Ensure the adjusted text flows naturally with the new tone.\n -------------`,\n },\n {\n name: 'Translate',\n system: ({ locale, prompt = '', systemPrompt = '' }) =>\n `You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.\n \n -------------\n INSTRUCTIONS:\n - Accurately translate the text into ${locale}.\n - Preserve the original meaning, tone, and context.\n - Ensure the translation is culturally appropriate and natural in the target language.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n]\n\nexport const seedPrompts = ({ fieldLabel, fieldSchemaPaths, fieldType, path }) => {\n return {\n prompt: `field-type: ${fieldType}\nfield-name: ${fieldLabel}\nschema-path: ${path}\n\nGive me a prompt that relate to the given field type and schema path.\n\nGenerated prompt:\n`,\n system: `# AI Assistant for CMS Prompt Generation\n\nYour role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.\n\n## Key Guidelines:\n- Tailor prompts to specific field-type and purpose\n- Use schema-path for context\n- Include '{{ title }}' in every prompt\n- Be clear, concise, and instructive\n- Focus on content generation, not user perspective\n- For Image, Voice, or Banner fields, use provided example prompts verbatim\n- Image, Banner prompt MUST NOT CONTAIN ANY TYPOGRAPHY/TEXT DETAILS\n\n## Field Types and Prompts:\n\n1. richText:\n - Craft detailed, structured content\n - Include intro, sections, body, formatting, and conclusion\n - Aim for engaging, informative, and valuable content\n\n2. text:\n - For titles: Generate concise, engaging titles\n - For keywords: List relevant SEO terms\n\n3. textarea:\n - Provide comprehensive details (e.g., event information)\n\n4. upload:\n - Describe high-quality images or media\n\n## Schema-path Examples:\n- posts.title: Blog/article title\n- products.name: Product name\n\n## Must Follow:\n- Adapt prompts to schema-path context\n- Generate content directly, avoid personal pronouns\n- Use provided examples as guidelines\n\n### Examples for each field type along with generated prompt:\n\nFor richText:\n field-type: richText\n field-name: Content\n schema-path: posts.content\n Generated prompt: Craft compelling content for a blog post with the title \"{{ title }}\". Develop a well-structured narrative that captivates readers from start to finish. Incorporate the following elements to create a polished and engaging piece:\n\n- Engaging introduction that hooks the reader\n- Clearly defined sections with relevant subheadings\n- Well-researched and informative body paragraphs\n- Creative use of formatting to enhance readability (e.g., bullet points, blockquotes, italics, headings, bolds, other text formats)\n- Compelling conclusion that reinforces the main theme\n- Make the format easily digestible and clear for enhanced readability and improved CTR. \n- The user should be engaged, consistently interested, and feel that they’ve gained the knowledge they were seeking. \n\nInfuse the content with your expertise and a touch of personality to make it both informative and enjoyable to read. Aim to provide value to your target audience while maintaining a professional tone that aligns with the blog's overall style.\nFeel free to incorporate relevant anecdotes, statistics, or examples to support your points and add depth to the post. Remember, the goal is to create content that not only informs but also inspires and entertains your readers.\n\nFor text:\n field-type: text\n field-name: title\n schema-path: posts.title\n Generated prompt: Generate a captivating title for the blog post based on '{{ title }}' that effectively encapsulates the main theme and draws in readers. The title should be concise, engaging, and relevant to the content being presented. If no input is provided then generate creative title.\n\nFor text:\n field-type: text\n field-name: keywords\n schema-path: posts.keywords\n Generated prompt: Identify and list relevant keywords for the blog post titled \"{{ title }}\". Focus on terms that enhance search engine optimization and accurately reflect the main themes and topics of the content.\nkeywords will with comma separated.\n\n\nFor textarea:\n field-type: textarea:\n field-name: details\n schema-path: posts.details\n Generated prompt: Provide comprehensive details for the event '{{ title }}'. Include essential information such as date, time, location, and any specific instructions or requirements.\n\nFor upload:\n field-type: upload\n field-name: Featured Image\n schema-path: posts.image\n Generated prompt: Imagine {{ title }}\n\nFor upload:\n field-type: upload\n field-name: Voice\n schema-path: posts.upload\n Generated prompt: {{ title }} {{ toLexicalHTML [provide schema-path for richText] }}\n\n\nRemember 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.\n\nSchema Map Context:\n${JSON.stringify(fieldSchemaPaths)}\n\n${defaultSystemPrompt}\n`,\n }\n}\n"],"names":["defaultSystemPrompt","defaultPrompts","name","system","prompt","systemPrompt","layout","locale","seedPrompts","fieldLabel","fieldSchemaPaths","fieldType","path","JSON","stringify"],"mappings":"AAeA,yEAAyE;AACzE,OAAO,MAAMA,sBAAsB,CAAC;;;;aAIvB,CAAC,CAAA;AAEd,OAAO,MAAMC,iBAAiC;IAC5C;QACEC,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACXC,eAAe,EAAE,EAClB,GAAK,CAAC;;;;;;;;MAQL,EAAED,SAAS,2BAA2BA,SAAS,GAAG;MAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;mBACxD,CAAC;IAClB;IACA;QACEH,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;;mBASM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;mBAQM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACZ,GAAK,CAAC;;;;;;;;;MASL,EAAEA,SAAS,2BAA2BA,SAAS,GAAG;mBACrC,CAAC;IAClB;IACA;QACEF,MAAM;QACNI,QAAQ,IAAM,CAAC;;;IAGf,CAAC;QACDH,QAAQ,IACN,CAAC;;;;;;;;;AASP,CAAC;IACC;IACA;QACED,MAAM;QACNC,QAAQ,IACN,CAAC;;;;;;;mBAOY,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EAAEI,MAAM,EAAEH,SAAS,EAAE,EAAEC,eAAe,EAAE,EAAE,GACjD,CAAC,gEAAgE,EAAEE,OAAO;;;;yCAIvC,EAAEA,OAAO;;;IAG9C,EAAEH,SAAS,2BAA2BA,SAAS,GAAG;IAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;iBACxD,CAAC;IAChB;CACD,CAAA;AAED,OAAO,MAAMG,cAAc,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,IAAI,EAAE;IAC3E,OAAO;QACLR,QAAQ,CAAC,YAAY,EAAEO,UAAU;YACzB,EAAEF,WAAW;aACZ,EAAEG,KAAK;;;;;AAKpB,CAAC;QACGT,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Fb,EAAEU,KAAKC,SAAS,CAACJ,kBAAkB;;AAEnC,EAAEV,oBAAoB;AACtB,CAAC;IACC;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/ai/prompts.ts"],"sourcesContent":["import type { ActionMenuItems } from '../types.js'\n\ntype ActionPromptOptions = {\n layout?: string\n locale?: string\n prompt?: string\n systemPrompt?: string\n}\n\ntype ActionPrompt = {\n layout?: (options?: ActionPromptOptions) => string\n name: ActionMenuItems\n system: (options: ActionPromptOptions) => string\n}\n\nexport const defaultPrompts: ActionPrompt[] = [\n {\n name: 'Rephrase',\n system: ({\n prompt = '',\n systemPrompt = '',\n }) => `You are a skilled language expert. Rephrase the given text while maintaining its original meaning, tone, and emotional content. Use different words and sentence structures where possible, but preserve the overall style and sentiment of the original.\n \n -------------\n INSTRUCTIONS:\n - Rephrase the text according to the guidelines of the ORIGINAL SYSTEM PROMPT, if provided.\n - Retain the original meaning, tone, and emotional content.\n - Use different vocabulary and sentence structures where appropriate.\n - Ensure the rephrased text conveys the same message and feeling as the original.\n ${prompt ? '\\n\\nPrevious prompt:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n {\n name: 'Expand',\n system:\n () => `You are a creative writer and subject matter expert. Expand the given text by adding depth, detail, and relevant information while maintaining the original tone and style.\n \n -------------\n INSTRUCTIONS:\n - Understand the main ideas and tone of the text.\n - Add more details, examples, explanations, or context.\n - Maintain the original tone, style, and intent.\n - Ensure the expanded version flows naturally and coherently.\n - Do not contradict or alter the original meaning.\n -------------`,\n },\n {\n name: 'Proofread',\n system:\n () => `You are an English language expert. Proofread the given text, focusing on correcting grammar and spelling mistakes without altering the content, style, or tone.\n \n -------------\n INSTRUCTIONS:\n - Correct grammar and spelling errors.\n - Do not change the content, meaning, tone, or style.\n - Return the full text, whether corrections were made or not.\n - Do not provide additional comments or analysis.\n -------------`,\n },\n {\n name: 'Simplify',\n system: ({\n prompt = '',\n }) => `You are a skilled communicator specializing in clear and concise writing. Simplify the given text to make it easier to understand while retaining its core message.\n \n -------------\n INSTRUCTIONS:\n - Simplify the language, using more common words and shorter sentences.\n - Remove unnecessary details or jargon while keeping essential information.\n - Maintain the original meaning and key points.\n - Aim for clarity and readability for a general audience.\n - The simplified text should be more concise than the original.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n -------------`,\n },\n {\n name: 'Summarize',\n layout: () => `\n[heading] - Summary\n[paragraph] - Your summary goes here...\n `,\n system: () =>\n `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.\n\nINSTRUCTIONS:\n1. Carefully read and analyze the provided text.\n2. Identify and extract the main ideas and crucial supporting details.\n3. Condense the information into a clear and coherent summary that maintains the core message.\n4. Preserve the original tone and intent of the text.\n5. Ensure your summary is approximately 25-30% of the original text length.\n6. Use clear and precise language, avoiding unnecessary jargon or complexity.\n`,\n },\n {\n name: 'Tone',\n system: () =>\n `You are a tone adjustment specialist. Modify the tone of the given text as specified while keeping the original message and content intact.\n \n -------------\n INSTRUCTIONS:\n - Adjust the tone to match the specified style (e.g., formal, informal, professional, friendly).\n - Maintain the original content and meaning.\n - Ensure the adjusted text flows naturally with the new tone.\n -------------`,\n },\n {\n name: 'Translate',\n system: ({ locale, prompt = '', systemPrompt = '' }) =>\n `You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.\n \n -------------\n INSTRUCTIONS:\n - Accurately translate the text into ${locale}.\n - Preserve the original meaning, tone, and context.\n - Ensure the translation is culturally appropriate and natural in the target language.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n]\n\nexport const seedPrompts = ({ fieldLabel, fieldSchemaPaths, fieldType, path }) => {\n return {\n prompt: `field-type: ${fieldType}\nfield-name: ${fieldLabel}\nschema-path: ${path}\n\nGive me a prompt that relate to the given field type and schema path.\n\nGenerated prompt:\n`,\n system: `# AI Assistant for CMS Prompt Generation\n\nYour role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.\n\n## Key Guidelines:\n- Tailor prompts to specific field-type and purpose\n- Use schema-path for context\n- Include '{{ title }}' in every prompt\n- Be clear, concise, and instructive\n- Focus on content generation, not user perspective\n- For Image, Voice, or Banner fields, use provided example prompts verbatim\n- Image, Banner prompt MUST NOT CONTAIN ANY TYPOGRAPHY/TEXT DETAILS\n\n## Field Types and Prompts:\n\n1. richText:\n - Craft detailed, structured content\n - Include intro, sections, body, formatting, and conclusion\n - Aim for engaging, informative, and valuable content\n\n2. text:\n - For titles: Generate concise, engaging titles\n - For keywords: List relevant SEO terms\n\n3. textarea:\n - Provide comprehensive details (e.g., event information)\n\n4. upload:\n - Describe high-quality images or media\n\n## Schema-path Examples:\n- posts.title: Blog/article title\n- products.name: Product name\n\n## Must Follow:\n- Adapt prompts to schema-path context\n- Generate content directly, avoid personal pronouns\n- Use provided examples as guidelines\n\n### Examples for each field type along with generated prompt:\n\nFor richText:\n field-type: richText\n field-name: Content\n schema-path: posts.content\n Generated prompt: Craft compelling content for a blog post with the title \"{{ title }}\". Develop a well-structured narrative that captivates readers from start to finish. Incorporate the following elements to create a polished and engaging piece:\n\n- Engaging introduction that hooks the reader\n- Clearly defined sections with relevant subheadings\n- Well-researched and informative body paragraphs\n- Creative use of formatting to enhance readability (e.g., bullet points, blockquotes, italics, headings, bolds, other text formats)\n- Compelling conclusion that reinforces the main theme\n- Make the format easily digestible and clear for enhanced readability and improved CTR. \n- The user should be engaged, consistently interested, and feel that they’ve gained the knowledge they were seeking. \n\nInfuse the content with your expertise and a touch of personality to make it both informative and enjoyable to read. Aim to provide value to your target audience while maintaining a professional tone that aligns with the blog's overall style.\nFeel free to incorporate relevant anecdotes, statistics, or examples to support your points and add depth to the post. Remember, the goal is to create content that not only informs but also inspires and entertains your readers.\n\nFor text:\n field-type: text\n field-name: title\n schema-path: posts.title\n Generated prompt: Generate a captivating title for the blog post based on '{{ title }}' that effectively encapsulates the main theme and draws in readers. The title should be concise, engaging, and relevant to the content being presented. If no input is provided then generate creative title.\n\nFor text:\n field-type: text\n field-name: keywords\n schema-path: posts.keywords\n Generated prompt: Identify and list relevant keywords for the blog post titled \"{{ title }}\". Focus on terms that enhance search engine optimization and accurately reflect the main themes and topics of the content.\nkeywords will with comma separated.\n\n\nFor textarea:\n field-type: textarea:\n field-name: details\n schema-path: posts.details\n Generated prompt: Provide comprehensive details for the event '{{ title }}'. Include essential information such as date, time, location, and any specific instructions or requirements.\n\nFor upload:\n field-type: upload\n field-name: Featured Image\n schema-path: posts.image\n Generated prompt: Imagine {{ title }}\n\nFor upload:\n field-type: upload\n field-name: Voice\n schema-path: posts.upload\n Generated prompt: {{ title }} {{ toLexicalHTML [provide field-path for richText] }}\n\n\nRemember 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.\n\nSchema Map Context:\n${JSON.stringify(fieldSchemaPaths)}\n\nIMPORTANT: JUST PRODUCE THE OUTPUT, DO NOT ENGAGE!\n`,\n }\n}\n"],"names":["defaultPrompts","name","system","prompt","systemPrompt","layout","locale","seedPrompts","fieldLabel","fieldSchemaPaths","fieldType","path","JSON","stringify"],"mappings":"AAeA,OAAO,MAAMA,iBAAiC;IAC5C;QACEC,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACXC,eAAe,EAAE,EAClB,GAAK,CAAC;;;;;;;;MAQL,EAAED,SAAS,2BAA2BA,SAAS,GAAG;MAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;mBACxD,CAAC;IAClB;IACA;QACEH,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;;mBASM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;mBAQM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACZ,GAAK,CAAC;;;;;;;;;MASL,EAAEA,SAAS,2BAA2BA,SAAS,GAAG;mBACrC,CAAC;IAClB;IACA;QACEF,MAAM;QACNI,QAAQ,IAAM,CAAC;;;IAGf,CAAC;QACDH,QAAQ,IACN,CAAC;;;;;;;;;AASP,CAAC;IACC;IACA;QACED,MAAM;QACNC,QAAQ,IACN,CAAC;;;;;;;mBAOY,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EAAEI,MAAM,EAAEH,SAAS,EAAE,EAAEC,eAAe,EAAE,EAAE,GACjD,CAAC,gEAAgE,EAAEE,OAAO;;;;yCAIvC,EAAEA,OAAO;;;IAG9C,EAAEH,SAAS,2BAA2BA,SAAS,GAAG;IAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;iBACxD,CAAC;IAChB;CACD,CAAA;AAED,OAAO,MAAMG,cAAc,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,IAAI,EAAE;IAC3E,OAAO;QACLR,QAAQ,CAAC,YAAY,EAAEO,UAAU;YACzB,EAAEF,WAAW;aACZ,EAAEG,KAAK;;;;;AAKpB,CAAC;QACGT,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Fb,EAAEU,KAAKC,SAAS,CAACJ,kBAAkB;;;AAGnC,CAAC;IACC;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/utils/generateFileNameByPrompt.ts"],"sourcesContent":["export function generateFileNameByPrompt(prompt) {\n // Helper function to get a random integer between min and max (inclusive)\n function getRandomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min\n }\n\n // Define the desired length of the filename part from the prompt\n const maxLength = 30\n const promptLength = prompt.length\n\n // Determine the start position for the random substring\n const startPos = getRandomInt(0, Math.max(0, promptLength - maxLength))\n\n // Get the random substring and truncate it if necessary\n let randomSubstring = prompt.substring(startPos, startPos + maxLength)\n\n // Replace invalid filename characters with an underscore\n randomSubstring = randomSubstring.replace(/[^a-z\\d]/gi, '_').toLowerCase()\n\n // Add a timestamp for uniqueness\n const timestamp = new Date().toISOString().replace(/[:.-]/g, '')\n\n // Combine the truncated prompt and timestamp to form the filename\n return `${randomSubstring}_${timestamp}`\n}\n"],"names":["generateFileNameByPrompt","prompt","getRandomInt","min","max","Math","floor","random","maxLength","promptLength","length","startPos","randomSubstring","substring","replace","toLowerCase","timestamp","Date","toISOString"],"mappings":"AAAA,OAAO,SAASA,yBAAyBC,MAAM;IAC7C,0EAA0E;IAC1E,SAASC,aAAaC,GAAG,EAAEC,GAAG;QAC5B,OAAOC,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAMH,CAAAA,MAAMD,MAAM,CAAA,KAAMA;IACvD;IAEA,iEAAiE;IACjE,MAAMK,YAAY;IAClB,MAAMC,eAAeR,OAAOS,MAAM;IAElC,wDAAwD;IACxD,MAAMC,WAAWT,aAAa,GAAGG,KAAKD,GAAG,CAAC,GAAGK,eAAeD;IAE5D,wDAAwD;IACxD,IAAII,kBAAkBX,OAAOY,SAAS,CAACF,UAAUA,WAAWH;IAE5D,yDAAyD;IACzDI,kBAAkBA,gBAAgBE,OAAO,CAAC,cAAc,KAAKC,WAAW;IAExE,iCAAiC;IACjC,MAAMC,YAAY,IAAIC,OAAOC,WAAW,GAAGJ,OAAO,CAAC,UAAU;IAE7D,kEAAkE;IAClE,OAAO,GAAGF,gBAAgB,CAAC,EAAEI,WAAW;AAC1C"}
1
+ {"version":3,"sources":["../../../src/ai/utils/generateFileNameByPrompt.ts"],"sourcesContent":["export function generateFileNameByPrompt(prompt) {\n // Helper function to get a random integer between min and max (inclusive)\n function getRandomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min\n }\n\n // Define the desired length of the filename part from the prompt\n const maxLength = 30\n const promptLength = prompt.length\n\n // Determine the start position for the random substring\n const startPos = getRandomInt(0, Math.max(0, promptLength - maxLength))\n\n // Get the random substring and truncate it if necessary\n let randomSubstring = prompt.substring(startPos, startPos + maxLength)\n\n // Replace invalid filename characters with an underscore\n randomSubstring = randomSubstring.replace(/[^a-z\\d]/gi, '_').toLowerCase()\n\n // Add a timestamp for uniqueness\n const timestamp = new Date().toISOString().replace(/[:.-]/g, '')\n\n // Combine the truncated prompt and timestamp to form the filename\n return `${randomSubstring}_${timestamp}`\n}\n"],"names":["generateFileNameByPrompt","prompt","getRandomInt","min","max","Math","floor","random","maxLength","promptLength","length","startPos","randomSubstring","substring","replace","toLowerCase","timestamp","Date","toISOString"],"mappings":"AAAA,OAAO,SAASA,yBAAyBC,MAAM;IAC7C,0EAA0E;IAC1E,SAASC,aAAaC,GAAG,EAAEC,GAAG;QAC5B,OAAOC,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAMH,CAAAA,MAAMD,MAAM,CAAA,KAAMA;IACvD;IAEA,iEAAiE;IACjE,MAAMK,YAAY;IAClB,MAAMC,eAAeR,OAAOS,MAAM;IAElC,wDAAwD;IACxD,MAAMC,WAAWT,aAAa,GAAGG,KAAKD,GAAG,CAAC,GAAGK,eAAeD;IAE5D,wDAAwD;IACxD,IAAII,kBAAkBX,OAAOY,SAAS,CAACF,UAAUA,WAAWH;IAE5D,yDAAyD;IACzDI,kBAAkBA,gBAAgBE,OAAO,CAAC,cAAc,KAAKC,WAAW;IAExE,iCAAiC;IACjC,MAAMC,YAAY,IAAIC,OAAOC,WAAW,GAAGJ,OAAO,CAAC,UAAU;IAE7D,kEAAkE;IAClE,OAAO,CAAC,EAAEF,gBAAgB,CAAC,EAAEI,UAAU,CAAC;AAC1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"Instructions.d.ts","sourceRoot":"","sources":["../../src/collections/Instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,SAAS,CAAA;AAoB3D,eAAO,MAAM,YAAY,EAAE,gBA4F1B,CAAA"}
1
+ {"version":3,"file":"Instructions.d.ts","sourceRoot":"","sources":["../../src/collections/Instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,SAAS,CAAA;AAsB3D,eAAO,MAAM,YAAY,EAAE,gBA6F1B,CAAA"}
@@ -1,5 +1,7 @@
1
1
  import { GenerationModels } from '../ai/models/index.js';
2
2
  import { PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js';
3
+ import { PromptEditorField } from '../fields/PromptEditorField/PromptEditorField.js';
4
+ import { SelectField } from '../fields/SelectField/SelectField.js';
3
5
  const groupSettings = GenerationModels.reduce((fields, model)=>{
4
6
  if (model.settings) {
5
7
  fields.push(model.settings);
@@ -29,6 +31,7 @@ export const Instructions = {
29
31
  name: 'schema-path',
30
32
  type: 'text',
31
33
  admin: {
34
+ hidden: true,
32
35
  readOnly: true
33
36
  },
34
37
  unique: true
@@ -37,6 +40,7 @@ export const Instructions = {
37
40
  name: 'field-type',
38
41
  type: 'select',
39
42
  admin: {
43
+ hidden: true,
40
44
  readOnly: true
41
45
  },
42
46
  defaultValue: 'text',
@@ -65,13 +69,11 @@ export const Instructions = {
65
69
  type: 'select',
66
70
  admin: {
67
71
  components: {
68
- Field: {
69
- clientProps: {
70
- filterByField: 'field-type',
71
- options: modelOptions
72
- },
73
- path: '@ai-stack/payloadcms/fields#SelectField'
74
- }
72
+ Field: SelectField
73
+ },
74
+ custom: {
75
+ filterByField: 'field-type',
76
+ options: modelOptions
75
77
  }
76
78
  },
77
79
  label: 'Model',
@@ -80,14 +82,15 @@ export const Instructions = {
80
82
  label: option.label,
81
83
  value: option.value
82
84
  };
83
- })
85
+ }),
86
+ validate: ()=>true
84
87
  },
85
88
  {
86
89
  name: 'prompt',
87
90
  type: 'textarea',
88
91
  admin: {
89
92
  components: {
90
- Field: '@ai-stack/payloadcms/fields#PromptEditorField'
93
+ Field: PromptEditorField
91
94
  }
92
95
  }
93
96
  },