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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/ai/models/anthropic/index.d.ts.map +1 -1
  2. package/dist/ai/models/anthropic/index.js +3 -3
  3. package/dist/ai/models/anthropic/index.js.map +1 -1
  4. package/dist/ai/models/elevenLabs/index.d.ts.map +1 -1
  5. package/dist/ai/models/elevenLabs/index.js +1 -11
  6. package/dist/ai/models/elevenLabs/index.js.map +1 -1
  7. package/dist/ai/models/index.js +2 -2
  8. package/dist/ai/models/index.js.map +1 -1
  9. package/dist/ai/models/openai/index.d.ts.map +1 -1
  10. package/dist/ai/models/openai/index.js +3 -2
  11. package/dist/ai/models/openai/index.js.map +1 -1
  12. package/dist/ai/prompts.d.ts +1 -0
  13. package/dist/ai/prompts.d.ts.map +1 -1
  14. package/dist/ai/prompts.js +5 -2
  15. package/dist/ai/prompts.js.map +1 -1
  16. package/dist/ai/{editor → schemas}/lexical.schema.d.ts +2 -2
  17. package/dist/ai/schemas/lexical.schema.d.ts.map +1 -0
  18. package/dist/ai/schemas/lexical.schema.js.map +1 -0
  19. package/dist/collections/Instructions.d.ts.map +1 -1
  20. package/dist/collections/Instructions.js +9 -12
  21. package/dist/collections/Instructions.js.map +1 -1
  22. package/dist/endpoints/index.d.ts +1 -1
  23. package/dist/endpoints/index.d.ts.map +1 -1
  24. package/dist/endpoints/index.js +17 -50
  25. package/dist/endpoints/index.js.map +1 -1
  26. package/dist/exports/client.d.ts +4 -0
  27. package/dist/exports/client.d.ts.map +1 -0
  28. package/dist/exports/client.js +5 -0
  29. package/dist/exports/client.js.map +1 -0
  30. package/dist/exports/fields.d.ts +3 -1
  31. package/dist/exports/fields.d.ts.map +1 -1
  32. package/dist/exports/fields.js +3 -0
  33. package/dist/exports/fields.js.map +1 -1
  34. package/dist/fields/DescriptionField/DescriptionField.d.ts +1 -2
  35. package/dist/fields/DescriptionField/DescriptionField.d.ts.map +1 -1
  36. package/dist/fields/DescriptionField/DescriptionField.js +2 -1
  37. package/dist/fields/DescriptionField/DescriptionField.js.map +1 -1
  38. package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts +1 -2
  39. package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts.map +1 -1
  40. package/dist/fields/DescriptionField/DescriptionFieldComponent.js +2 -1
  41. package/dist/fields/DescriptionField/DescriptionFieldComponent.js.map +1 -1
  42. package/dist/fields/LexicalEditor/ActionsFeatureComponent.js +1 -1
  43. package/dist/fields/LexicalEditor/ActionsFeatureComponent.js.map +1 -1
  44. package/dist/fields/LexicalEditor/feature.server.d.ts.map +1 -1
  45. package/dist/fields/LexicalEditor/feature.server.js +2 -2
  46. package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
  47. package/dist/fields/PromptEditorField/PromptEditorField.d.ts +1 -1
  48. package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
  49. package/dist/fields/PromptEditorField/PromptEditorField.js +32 -51
  50. package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
  51. package/dist/fields/SelectField/SelectField.d.ts +9 -2
  52. package/dist/fields/SelectField/SelectField.d.ts.map +1 -1
  53. package/dist/fields/SelectField/SelectField.js +26 -23
  54. package/dist/fields/SelectField/SelectField.js.map +1 -1
  55. package/dist/index.d.ts +2 -2
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +3 -3
  58. package/dist/index.js.map +1 -1
  59. package/dist/init.d.ts.map +1 -1
  60. package/dist/init.js +14 -2
  61. package/dist/init.js.map +1 -1
  62. package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts +8 -0
  63. package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts.map +1 -0
  64. package/dist/libraries/autocomplete/AutocompleteTextArea.js +435 -0
  65. package/dist/libraries/autocomplete/AutocompleteTextArea.js.map +1 -0
  66. package/dist/libraries/autocomplete/AutocompleteTextArea.module.scss +35 -0
  67. package/dist/libraries/handlebars/asyncHandlebars.d.ts +2 -0
  68. package/dist/libraries/handlebars/asyncHandlebars.d.ts.map +1 -0
  69. package/dist/libraries/handlebars/asyncHandlebars.js +5 -0
  70. package/dist/libraries/handlebars/asyncHandlebars.js.map +1 -0
  71. package/dist/libraries/handlebars/helpers.d.ts +2 -0
  72. package/dist/libraries/handlebars/helpers.d.ts.map +1 -0
  73. package/dist/libraries/handlebars/helpers.js +22 -0
  74. package/dist/libraries/handlebars/helpers.js.map +1 -0
  75. package/dist/libraries/handlebars/helpersMap.d.ts +12 -0
  76. package/dist/libraries/handlebars/helpersMap.d.ts.map +1 -0
  77. package/dist/libraries/handlebars/helpersMap.js +13 -0
  78. package/dist/libraries/handlebars/helpersMap.js.map +1 -0
  79. package/dist/libraries/handlebars/replacePlaceholders.d.ts +2 -0
  80. package/dist/libraries/handlebars/replacePlaceholders.d.ts.map +1 -0
  81. package/dist/libraries/handlebars/replacePlaceholders.js +8 -0
  82. package/dist/libraries/handlebars/replacePlaceholders.js.map +1 -0
  83. package/dist/plugin.d.ts.map +1 -1
  84. package/dist/plugin.js +7 -4
  85. package/dist/plugin.js.map +1 -1
  86. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts +1 -3
  87. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts.map +1 -1
  88. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  89. package/dist/providers/InstructionsProvider/useInstructions.d.ts +4 -0
  90. package/dist/providers/InstructionsProvider/useInstructions.d.ts.map +1 -0
  91. package/dist/providers/InstructionsProvider/useInstructions.js +34 -0
  92. package/dist/providers/InstructionsProvider/useInstructions.js.map +1 -0
  93. package/dist/types.d.ts +1 -1
  94. package/dist/types.d.ts.map +1 -1
  95. package/dist/types.js.map +1 -1
  96. package/dist/ui/Actions/Actions.js +32 -39
  97. package/dist/ui/Actions/Actions.js.map +1 -1
  98. package/dist/ui/Actions/hooks/useGenerate.d.ts.map +1 -1
  99. package/dist/ui/Actions/hooks/useGenerate.js +4 -4
  100. package/dist/ui/Actions/hooks/useGenerate.js.map +1 -1
  101. package/dist/utilities/getFieldBySchemaPath.d.ts +2 -2
  102. package/dist/utilities/getFieldBySchemaPath.d.ts.map +1 -1
  103. package/dist/utilities/getFieldBySchemaPath.js.map +1 -1
  104. package/dist/utilities/getFieldInfo.d.ts +3 -0
  105. package/dist/utilities/getFieldInfo.d.ts.map +1 -0
  106. package/dist/utilities/getFieldInfo.js +14 -0
  107. package/dist/utilities/getFieldInfo.js.map +1 -0
  108. package/dist/utilities/updateFieldsConfig.d.ts.map +1 -1
  109. package/dist/utilities/updateFieldsConfig.js +1 -5
  110. package/dist/utilities/updateFieldsConfig.js.map +1 -1
  111. package/package.json +59 -38
  112. package/dist/ai/editor/lexical.schema.d.ts.map +0 -1
  113. package/dist/ai/editor/lexical.schema.js.map +0 -1
  114. package/dist/ai/models/style.d.ts +0 -2
  115. package/dist/ai/models/style.d.ts.map +0 -1
  116. package/dist/ai/models/style.js +0 -31
  117. package/dist/ai/models/style.js.map +0 -1
  118. package/dist/providers/InstructionsProvider/hook.d.ts +0 -9
  119. package/dist/providers/InstructionsProvider/hook.d.ts.map +0 -1
  120. package/dist/providers/InstructionsProvider/hook.js +0 -17
  121. package/dist/providers/InstructionsProvider/hook.js.map +0 -1
  122. package/dist/providers/InstructionsProvider/index.d.ts +0 -5
  123. package/dist/providers/InstructionsProvider/index.d.ts.map +0 -1
  124. package/dist/providers/InstructionsProvider/index.js +0 -10
  125. package/dist/providers/InstructionsProvider/index.js.map +0 -1
  126. package/dist/ui/Floatype/Floatype.d.ts +0 -21
  127. package/dist/ui/Floatype/Floatype.d.ts.map +0 -1
  128. package/dist/ui/Floatype/Floatype.js +0 -245
  129. package/dist/ui/Floatype/Floatype.js.map +0 -1
  130. package/dist/ui/Floatype/floatype.module.css +0 -25
  131. /package/dist/ai/{editor → schemas}/lexical.schema.js +0 -0
@@ -1 +1 @@
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
+ {"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,6 +1,7 @@
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';
4
5
  export const AnthropicConfig = {
5
6
  models: [
6
7
  {
@@ -16,9 +17,9 @@ export const AnthropicConfig = {
16
17
  const streamTextResult = await streamText({
17
18
  model: anthropic(options.model),
18
19
  prompt,
19
- system: options.system || 'IMPORTANT: JUST PRODUCE THE OUTPUT, DO NOT ENGAGE!'
20
+ system: options.system || defaultSystemPrompt
20
21
  });
21
- return streamTextResult.toAIStreamResponse();
22
+ return streamTextResult.toDataStreamResponse();
22
23
  },
23
24
  output: 'text',
24
25
  settings: {
@@ -53,7 +54,6 @@ export const AnthropicConfig = {
53
54
  'richText'
54
55
  ],
55
56
  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 { 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
+ {"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"],"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AAc,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;AA2GzD,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;AAiGzD,eAAO,MAAM,gBAAgB,EAAE,gBAmC9B,CAAA"}
@@ -1,4 +1,3 @@
1
- import { SelectField } from '../../../fields/SelectField/SelectField.js';
2
1
  import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js';
3
2
  import { generateVoice } from './generateVoice.js';
4
3
  import { getAllVoices } from './voices.js';
@@ -82,19 +81,10 @@ if (voiceOptions.length) {
82
81
  fields.unshift({
83
82
  name: 'voice_id',
84
83
  type: 'select',
85
- admin: {
86
- components: {
87
- Field: SelectField
88
- },
89
- custom: {
90
- options: voiceOptions
91
- }
92
- },
93
84
  defaultValue: voiceOptions[0]?.voice_id,
94
85
  label: 'Voice',
95
86
  options: fieldVoiceOptions,
96
- required: true,
97
- validate: ()=>true
87
+ required: true
98
88
  });
99
89
  }
100
90
  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 { 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;gBACE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../../../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"}
@@ -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 : [],
6
7
  ...process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : [],
7
- ...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : [],
8
- ...process.env.OPENAI_API_KEY ? OpenAIConfig.models : []
8
+ ...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.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.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
+ {"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 +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;AAQzD,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;AASzD,eAAO,MAAM,YAAY,EAAE,gBAkO1B,CAAA"}
@@ -4,6 +4,7 @@ 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';
7
8
  //TODO: Simplify this file by moving the handlers to separate files and remove duplicate code
8
9
  export const OpenAIConfig = {
9
10
  models: [
@@ -18,9 +19,9 @@ export const OpenAIConfig = {
18
19
  const streamTextResult = await streamText({
19
20
  model: openai(options.model),
20
21
  prompt,
21
- system: options.system
22
+ system: options.system || defaultSystemPrompt
22
23
  });
23
- return streamTextResult.toAIStreamResponse();
24
+ return streamTextResult.toDataStreamResponse();
24
25
  },
25
26
  output: 'text',
26
27
  settings: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ai/models/openai/index.ts"],"sourcesContent":["import type { SpeechCreateParams } from 'openai/resources/audio/speech'\nimport type { File } from 'payload'\n\nimport { openai } from '@ai-sdk/openai'\nimport { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\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":"AAGA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,UAAU,QAAQ,KAAI;AAI/B,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,aAAa,QAAQ,qBAAoB;AAElD,6FAA6F;AAC7F,OAAO,MAAMC,eAAiC;IAC5CC,QAAQ;QACN;YACEC,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,SAAS,OACPC,QACAC;gBAEA,MAAMC,mBAAmB,MAAMb,WAAW;oBACxCc,OAAOf,OAAOa,QAAQE,KAAK;oBAC3BH;oBACAI,QAAQH,QAAQG,MAAM;gBACxB;gBAEA,OAAOF,iBAAiBG,kBAAkB;YAC5C;YACAC,QAAQ;YACRC,UAAU;gBACRV,MAAM;gBACNW,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAb,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAgB;oBACpE;iBACD;gBACDY,OAAO;YACT;QACF;QACA;YACEjB,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAS;YAClBC,SAAS,OAAOC,QAAgBC;gBAC9B,MAAMa,YAAY,MAAMvB,cAAcS,QAAQC;gBAC9C,OAAO;oBACL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;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDY,UAAU;AACZ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/ai/models/openai/index.ts"],"sourcesContent":["import type { SpeechCreateParams } from 'openai/resources/audio/speech'\nimport type { File } from 'payload'\n\nimport { openai } from '@ai-sdk/openai'\nimport { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\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"],"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;4BAAS;4BAAQ;4BAAS;4BAAQ;4BAAQ;yBAAU;oBAGhE;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAS;yBAAW;oBAChC;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAO;4BAAQ;4BAAO;4BAAQ;4BAAO;yBAAM;oBAGvD;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPU,KAAK;wBACLC,KAAK;oBACP;iBACD;gBACDX,OAAO;YACT;QACF;QACA;YACEjB,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBC,SAAS,CAACsB,MAAcpB;gBACtB,OAAOV,iBAAiB8B,MAAMpB;YAChC;YACAK,QAAQ;YACRC,UAAU;gBACRV,MAAM;gBACNW,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAb,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAoB;oBACxE;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc,CAAC;;;;yEAI8C,CAAC;wBAC9DC,OAAO;oBACT;oBACA;wBACE;;;;aAIC,GACDhB,MAAM;wBACNW,MAAM;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDY,UAAU;AACZ,EAAC"}
@@ -10,6 +10,7 @@ type ActionPrompt = {
10
10
  name: ActionMenuItems;
11
11
  system: (options: ActionPromptOptions) => string;
12
12
  };
13
+ export declare const defaultSystemPrompt = "\nIMPORTANT: JUST PRODUCE THE OUTPUT WITHOUT QUOTES AND DO NOT ENGAGE!\n";
13
14
  export declare const defaultPrompts: ActionPrompt[];
14
15
  export declare const seedPrompts: ({ fieldLabel, fieldSchemaPaths, fieldType, path }: {
15
16
  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;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,mBAAmB,6EAE/B,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;CA6GvB,CAAA"}
@@ -1,3 +1,6 @@
1
+ export const defaultSystemPrompt = `
2
+ IMPORTANT: JUST PRODUCE THE OUTPUT WITHOUT QUOTES AND DO NOT ENGAGE!
3
+ `;
1
4
  export const defaultPrompts = [
2
5
  {
3
6
  name: 'Rephrase',
@@ -192,7 +195,7 @@ For upload:
192
195
  field-type: upload
193
196
  field-name: Voice
194
197
  schema-path: posts.upload
195
- Generated prompt: {{ title }} {{ toLexicalHTML [provide field-path for richText] }}
198
+ Generated prompt: {{ title }} {{ toLexicalHTML [provide schema-path for richText] }}
196
199
 
197
200
 
198
201
  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.
@@ -200,7 +203,7 @@ Remember to adapt the prompts based on the specific schema-path provided, consid
200
203
  Schema Map Context:
201
204
  ${JSON.stringify(fieldSchemaPaths)}
202
205
 
203
- IMPORTANT: JUST PRODUCE THE OUTPUT, DO NOT ENGAGE!
206
+ ${defaultSystemPrompt}
204
207
  `
205
208
  };
206
209
  };
@@ -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\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
+ {"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 defaultSystemPrompt = `\nIMPORTANT: JUST PRODUCE THE OUTPUT WITHOUT QUOTES AND DO NOT ENGAGE!\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 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,OAAO,MAAMA,sBAAsB,CAAC;;AAEpC,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"}
@@ -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
- children?: any[];
11
10
  type?: string;
11
+ children?: any[];
12
12
  direction?: "ltr";
13
13
  format?: string;
14
14
  indent?: number;
15
15
  version?: number;
16
16
  }, {
17
- children?: any[];
18
17
  type?: string;
18
+ children?: any[];
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/schemas/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/schemas/lexical.schema.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const LexicalBaseNode = z.object({\n type: z.string(),\n children: z.array(z.any()).optional(),\n direction: z.enum(['ltr']).nullable().optional(),\n format: z.string().optional(),\n indent: z.number().optional(),\n version: z.number().optional(),\n})\n\nexport const lexicalSchema = (customNodes?: (typeof LexicalBaseNode)[]) => {\n const BaseNode = z.object({\n type: z.string(),\n children: z.array(z.lazy(() => Node)).optional(),\n direction: z.enum(['ltr']).nullable().optional(),\n format: z.string().optional(),\n indent: z.number().optional(),\n version: z.number().optional(),\n })\n\n const TextNode = BaseNode.extend({\n type: z.literal('text'),\n format: z.number().optional(),\n text: z.string(),\n })\n\n const LinkNode = BaseNode.extend({\n id: z.string(),\n type: z.literal('link'),\n fields: z.object({\n linkType: z.string(),\n newTab: z.boolean(),\n url: z.string(),\n }),\n })\n\n const ListItemNode = BaseNode.extend({\n type: z.literal('listitem'),\n checked: z.boolean().optional(),\n value: z.number(),\n })\n\n const ListNode = BaseNode.extend({\n type: z.literal('list'),\n listType: z.enum(['check', 'number', 'bullet']),\n start: z.number(),\n tag: z.enum(['ul', 'ol']),\n })\n\n const HeadingNode = BaseNode.extend({\n type: z.literal('heading'),\n tag: z.enum(['h1', 'h2', 'h3', 'h4']),\n })\n\n // Example of custom node - wip\n const MediaNode = BaseNode.extend({\n type: z.literal('block'),\n version: z.literal(2),\n fields: z.object({\n id: z.string(),\n media: z.string(),\n position: z.enum(['fullscreen', 'default']),\n blockName: z.string(),\n blockType: z.literal('mediaBlock'),\n }),\n })\n\n const Node = z.union([\n TextNode,\n LinkNode,\n ListItemNode,\n ListNode,\n HeadingNode,\n BaseNode.extend({ type: z.enum(['paragraph', 'quote', 'horizontalrule']) }),\n ...(customNodes || []),\n ])\n\n const RootNode = BaseNode.extend({\n type: z.literal('root'),\n })\n\n return z.object({\n root: RootNode,\n })\n}\n"],"names":["z","LexicalBaseNode","object","type","string","children","array","any","optional","direction","enum","nullable","format","indent","number","version","lexicalSchema","customNodes","BaseNode","lazy","Node","TextNode","extend","literal","text","LinkNode","id","fields","linkType","newTab","boolean","url","ListItemNode","checked","value","ListNode","listType","start","tag","HeadingNode","MediaNode","media","position","blockName","blockType","union","RootNode","root"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,MAAMH,EAAEI,MAAM;IACdC,UAAUL,EAAEM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MAAM,CAAC;QAC/BnB,MAAMH,EAAEuB,OAAO,CAAC;QAChBa,UAAUpC,EAAEU,IAAI,CAAC;YAAC;YAAS;YAAU;SAAS;QAC9C2B,OAAOrC,EAAEc,MAAM;QACfwB,KAAKtC,EAAEU,IAAI,CAAC;YAAC;YAAM;SAAK;IAC1B;IAEA,MAAM6B,cAAcrB,SAASI,MAAM,CAAC;QAClCnB,MAAMH,EAAEuB,OAAO,CAAC;QAChBe,KAAKtC,EAAEU,IAAI,CAAC;YAAC;YAAM;YAAM;YAAM;SAAK;IACtC;IAEA,+BAA+B;IAC/B,MAAM8B,YAAYtB,SAASI,MAAM,CAAC;QAChCnB,MAAMH,EAAEuB,OAAO,CAAC;QAChBR,SAASf,EAAEuB,OAAO,CAAC;QACnBI,QAAQ3B,EAAEE,MAAM,CAAC;YACfwB,IAAI1B,EAAEI,MAAM;YACZqC,OAAOzC,EAAEI,MAAM;YACfsC,UAAU1C,EAAEU,IAAI,CAAC;gBAAC;gBAAc;aAAU;YAC1CiC,WAAW3C,EAAEI,MAAM;YACnBwC,WAAW5C,EAAEuB,OAAO,CAAC;QACvB;IACF;IAEA,MAAMH,OAAOpB,EAAE6C,KAAK,CAAC;QACnBxB;QACAI;QACAO;QACAG;QACAI;QACArB,SAASI,MAAM,CAAC;YAAEnB,MAAMH,EAAEU,IAAI,CAAC;gBAAC;gBAAa;gBAAS;aAAiB;QAAE;WACrEO,eAAe,EAAE;KACtB;IAED,MAAM6B,WAAW5B,SAASI,MAAM,CAAC;QAC/BnB,MAAMH,EAAEuB,OAAO,CAAC;IAClB;IAEA,OAAOvB,EAAEE,MAAM,CAAC;QACd6C,MAAMD;IACR;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"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
+ {"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,7 +1,5 @@
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';
5
3
  const groupSettings = GenerationModels.reduce((fields, model)=>{
6
4
  if (model.settings) {
7
5
  fields.push(model.settings);
@@ -31,7 +29,6 @@ export const Instructions = {
31
29
  name: 'schema-path',
32
30
  type: 'text',
33
31
  admin: {
34
- hidden: true,
35
32
  readOnly: true
36
33
  },
37
34
  unique: true
@@ -40,7 +37,6 @@ export const Instructions = {
40
37
  name: 'field-type',
41
38
  type: 'select',
42
39
  admin: {
43
- hidden: true,
44
40
  readOnly: true
45
41
  },
46
42
  defaultValue: 'text',
@@ -69,11 +65,13 @@ export const Instructions = {
69
65
  type: 'select',
70
66
  admin: {
71
67
  components: {
72
- Field: SelectField
73
- },
74
- custom: {
75
- filterByField: 'field-type',
76
- options: modelOptions
68
+ Field: {
69
+ clientProps: {
70
+ filterByField: 'field-type',
71
+ options: modelOptions
72
+ },
73
+ path: '@ai-stack/payloadcms/fields#SelectField'
74
+ }
77
75
  }
78
76
  },
79
77
  label: 'Model',
@@ -82,15 +80,14 @@ export const Instructions = {
82
80
  label: option.label,
83
81
  value: option.value
84
82
  };
85
- }),
86
- validate: ()=>true
83
+ })
87
84
  },
88
85
  {
89
86
  name: 'prompt',
90
87
  type: 'textarea',
91
88
  admin: {
92
89
  components: {
93
- Field: PromptEditorField
90
+ Field: '@ai-stack/payloadcms/fields#PromptEditorField'
94
91
  }
95
92
  }
96
93
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/Instructions.ts"],"sourcesContent":["import type { CollectionConfig, GroupField } from 'payload'\n\nimport { GenerationModels } from '../ai/models/index.js'\nimport { PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js'\nimport { PromptEditorField } from '../fields/PromptEditorField/PromptEditorField.js'\nimport { SelectField } from '../fields/SelectField/SelectField.js'\n\nconst groupSettings = GenerationModels.reduce((fields, model) => {\n if (model.settings) {\n fields.push(model.settings)\n }\n return fields\n}, [] as GroupField[])\n\nconst modelOptions = GenerationModels.map((model) => {\n return {\n fields: model.fields,\n label: model.name,\n value: model.id,\n }\n})\n\nexport const Instructions: CollectionConfig = {\n slug: PLUGIN_INSTRUCTIONS_TABLE,\n\n // TODO: Revisit permissions, better if end user can provide this\n access: {\n create: () => true,\n read: () => true,\n update: () => true,\n },\n admin: {\n hidden: true,\n },\n fields: [\n {\n name: 'schema-path',\n type: 'text',\n admin: {\n hidden: true,\n readOnly: true,\n },\n unique: true,\n },\n {\n name: 'field-type',\n type: 'select',\n admin: {\n hidden: true,\n readOnly: true,\n },\n defaultValue: 'text',\n label: 'Field type',\n options: [\n {\n label: 'text',\n value: 'text',\n },\n {\n label: 'textarea',\n value: 'textarea',\n },\n {\n label: 'upload',\n value: 'upload',\n },\n {\n label: 'richText',\n value: 'richText',\n },\n ],\n },\n {\n name: 'model-id',\n type: 'select',\n admin: {\n components: {\n Field: SelectField,\n },\n custom: {\n filterByField: 'field-type',\n options: modelOptions,\n },\n },\n label: 'Model',\n options: modelOptions.map((option) => {\n return {\n label: option.label,\n value: option.value,\n }\n }),\n validate: () => true,\n },\n {\n name: 'prompt',\n type: 'textarea',\n admin: {\n components: {\n Field: PromptEditorField,\n },\n },\n },\n ...groupSettings,\n ],\n hooks: {\n beforeChange: [\n (req) => {\n if (req.data['openai-gpt-object-settings']?.layout?.length === 0) {\n // TODO: why??\n req.data['openai-gpt-object-settings'].layout = ''\n }\n return req.data\n },\n ],\n },\n}\n"],"names":["GenerationModels","PLUGIN_INSTRUCTIONS_TABLE","PromptEditorField","SelectField","groupSettings","reduce","fields","model","settings","push","modelOptions","map","label","name","value","id","Instructions","slug","access","create","read","update","admin","hidden","type","readOnly","unique","defaultValue","options","components","Field","custom","filterByField","option","validate","hooks","beforeChange","req","data","layout","length"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,yBAAyB,QAAQ,iBAAgB;AAC1D,SAASC,iBAAiB,QAAQ,mDAAkD;AACpF,SAASC,WAAW,QAAQ,uCAAsC;AAElE,MAAMC,gBAAgBJ,iBAAiBK,MAAM,CAAC,CAACC,QAAQC;IACrD,IAAIA,MAAMC,QAAQ,EAAE;QAClBF,OAAOG,IAAI,CAACF,MAAMC,QAAQ;IAC5B;IACA,OAAOF;AACT,GAAG,EAAE;AAEL,MAAMI,eAAeV,iBAAiBW,GAAG,CAAC,CAACJ;IACzC,OAAO;QACLD,QAAQC,MAAMD,MAAM;QACpBM,OAAOL,MAAMM,IAAI;QACjBC,OAAOP,MAAMQ,EAAE;IACjB;AACF;AAEA,OAAO,MAAMC,eAAiC;IAC5CC,MAAMhB;IAEN,iEAAiE;IACjEiB,QAAQ;QACNC,QAAQ,IAAM;QACdC,MAAM,IAAM;QACZC,QAAQ,IAAM;IAChB;IACAC,OAAO;QACLC,QAAQ;IACV;IACAjB,QAAQ;QACN;YACEO,MAAM;YACNW,MAAM;YACNF,OAAO;gBACLC,QAAQ;gBACRE,UAAU;YACZ;YACAC,QAAQ;QACV;QACA;YACEb,MAAM;YACNW,MAAM;YACNF,OAAO;gBACLC,QAAQ;gBACRE,UAAU;YACZ;YACAE,cAAc;YACdf,OAAO;YACPgB,SAAS;gBACP;oBACEhB,OAAO;oBACPE,OAAO;gBACT;gBACA;oBACEF,OAAO;oBACPE,OAAO;gBACT;gBACA;oBACEF,OAAO;oBACPE,OAAO;gBACT;gBACA;oBACEF,OAAO;oBACPE,OAAO;gBACT;aACD;QACH;QACA;YACED,MAAM;YACNW,MAAM;YACNF,OAAO;gBACLO,YAAY;oBACVC,OAAO3B;gBACT;gBACA4B,QAAQ;oBACNC,eAAe;oBACfJ,SAASlB;gBACX;YACF;YACAE,OAAO;YACPgB,SAASlB,aAAaC,GAAG,CAAC,CAACsB;gBACzB,OAAO;oBACLrB,OAAOqB,OAAOrB,KAAK;oBACnBE,OAAOmB,OAAOnB,KAAK;gBACrB;YACF;YACAoB,UAAU,IAAM;QAClB;QACA;YACErB,MAAM;YACNW,MAAM;YACNF,OAAO;gBACLO,YAAY;oBACVC,OAAO5B;gBACT;YACF;QACF;WACGE;KACJ;IACD+B,OAAO;QACLC,cAAc;YACZ,CAACC;gBACC,IAAIA,IAAIC,IAAI,CAAC,6BAA6B,EAAEC,QAAQC,WAAW,GAAG;oBAChE,cAAc;oBACdH,IAAIC,IAAI,CAAC,6BAA6B,CAACC,MAAM,GAAG;gBAClD;gBACA,OAAOF,IAAIC,IAAI;YACjB;SACD;IACH;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/collections/Instructions.ts"],"sourcesContent":["import type { CollectionConfig, GroupField } from 'payload'\n\nimport { GenerationModels } from '../ai/models/index.js'\nimport { PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js'\n\nconst groupSettings = GenerationModels.reduce((fields, model) => {\n if (model.settings) {\n fields.push(model.settings)\n }\n return fields\n}, [] as GroupField[])\n\nconst modelOptions = GenerationModels.map((model) => {\n return {\n fields: model.fields,\n label: model.name,\n value: model.id,\n }\n})\n\nexport const Instructions: CollectionConfig = {\n slug: PLUGIN_INSTRUCTIONS_TABLE,\n\n // TODO: Revisit permissions, better if end user can provide this\n access: {\n create: () => true,\n read: () => true,\n update: () => true,\n },\n admin: {\n hidden: true,\n },\n fields: [\n {\n name: 'schema-path',\n type: 'text',\n admin: {\n readOnly: true,\n },\n unique: true,\n },\n {\n name: 'field-type',\n type: 'select',\n admin: {\n readOnly: true,\n },\n defaultValue: 'text',\n label: 'Field type',\n options: [\n {\n label: 'text',\n value: 'text',\n },\n {\n label: 'textarea',\n value: 'textarea',\n },\n {\n label: 'upload',\n value: 'upload',\n },\n {\n label: 'richText',\n value: 'richText',\n },\n ],\n },\n {\n name: 'model-id',\n type: 'select',\n admin: {\n components: {\n Field: {\n clientProps: {\n filterByField: 'field-type',\n options: modelOptions,\n },\n path: '@ai-stack/payloadcms/fields#SelectField',\n },\n },\n },\n label: 'Model',\n options: modelOptions.map((option) => {\n return {\n label: option.label,\n value: option.value,\n }\n }),\n },\n {\n name: 'prompt',\n type: 'textarea',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/fields#PromptEditorField',\n },\n },\n },\n ...groupSettings,\n ],\n hooks: {\n beforeChange: [\n (req) => {\n if (req.data['openai-gpt-object-settings']?.layout?.length === 0) {\n // TODO: why??\n req.data['openai-gpt-object-settings'].layout = ''\n }\n return req.data\n },\n ],\n },\n}\n"],"names":["GenerationModels","PLUGIN_INSTRUCTIONS_TABLE","groupSettings","reduce","fields","model","settings","push","modelOptions","map","label","name","value","id","Instructions","slug","access","create","read","update","admin","hidden","type","readOnly","unique","defaultValue","options","components","Field","clientProps","filterByField","path","option","hooks","beforeChange","req","data","layout","length"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,yBAAyB,QAAQ,iBAAgB;AAE1D,MAAMC,gBAAgBF,iBAAiBG,MAAM,CAAC,CAACC,QAAQC;IACrD,IAAIA,MAAMC,QAAQ,EAAE;QAClBF,OAAOG,IAAI,CAACF,MAAMC,QAAQ;IAC5B;IACA,OAAOF;AACT,GAAG,EAAE;AAEL,MAAMI,eAAeR,iBAAiBS,GAAG,CAAC,CAACJ;IACzC,OAAO;QACLD,QAAQC,MAAMD,MAAM;QACpBM,OAAOL,MAAMM,IAAI;QACjBC,OAAOP,MAAMQ,EAAE;IACjB;AACF;AAEA,OAAO,MAAMC,eAAiC;IAC5CC,MAAMd;IAEN,iEAAiE;IACjEe,QAAQ;QACNC,QAAQ,IAAM;QACdC,MAAM,IAAM;QACZC,QAAQ,IAAM;IAChB;IACAC,OAAO;QACLC,QAAQ;IACV;IACAjB,QAAQ;QACN;YACEO,MAAM;YACNW,MAAM;YACNF,OAAO;gBACLG,UAAU;YACZ;YACAC,QAAQ;QACV;QACA;YACEb,MAAM;YACNW,MAAM;YACNF,OAAO;gBACLG,UAAU;YACZ;YACAE,cAAc;YACdf,OAAO;YACPgB,SAAS;gBACP;oBACEhB,OAAO;oBACPE,OAAO;gBACT;gBACA;oBACEF,OAAO;oBACPE,OAAO;gBACT;gBACA;oBACEF,OAAO;oBACPE,OAAO;gBACT;gBACA;oBACEF,OAAO;oBACPE,OAAO;gBACT;aACD;QACH;QACA;YACED,MAAM;YACNW,MAAM;YACNF,OAAO;gBACLO,YAAY;oBACVC,OAAO;wBACLC,aAAa;4BACXC,eAAe;4BACfJ,SAASlB;wBACX;wBACAuB,MAAM;oBACR;gBACF;YACF;YACArB,OAAO;YACPgB,SAASlB,aAAaC,GAAG,CAAC,CAACuB;gBACzB,OAAO;oBACLtB,OAAOsB,OAAOtB,KAAK;oBACnBE,OAAOoB,OAAOpB,KAAK;gBACrB;YACF;QACF;QACA;YACED,MAAM;YACNW,MAAM;YACNF,OAAO;gBACLO,YAAY;oBACVC,OAAO;gBACT;YACF;QACF;WACG1B;KACJ;IACD+B,OAAO;QACLC,cAAc;YACZ,CAACC;gBACC,IAAIA,IAAIC,IAAI,CAAC,6BAA6B,EAAEC,QAAQC,WAAW,GAAG;oBAChE,cAAc;oBACdH,IAAIC,IAAI,CAAC,6BAA6B,CAACC,MAAM,GAAG;gBAClD;gBACA,OAAOF,IAAIC,IAAI;YACjB;SACD;IACH;AACF,EAAC"}
@@ -1,3 +1,3 @@
1
- import { Endpoints } from '../types.js';
1
+ import type { Endpoints } from '../types.js';
2
2
  export declare const endpoints: Endpoints;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/endpoints/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,SAAS,EAAE,MAAM,aAAa,CAAA;AAiHxD,eAAO,MAAM,SAAS,EAAE,SAwIvB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/endpoints/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,aAAa,CAAA;AAsE7D,eAAO,MAAM,SAAS,EAAE,SAwIvB,CAAA"}
@@ -1,29 +1,22 @@
1
- import Handlebars from 'handlebars';
2
- import asyncHelpers from 'handlebars-async-helpers';
1
+ import { lexicalSchema } from '../ai/schemas/lexical.schema.js';
3
2
  import { GenerationModels } from '../ai/models/index.js';
4
3
  import { defaultPrompts } from '../ai/prompts.js';
5
4
  import { PLUGIN_API_ENDPOINT_GENERATE, PLUGIN_API_ENDPOINT_GENERATE_UPLOAD, PLUGIN_INSTRUCTIONS_TABLE, PLUGIN_NAME } from '../defaults.js';
6
- import { getFieldBySchemaPath } from '../utilities/getFieldBySchemaPath.js';
7
- import { lexicalToHTML } from '../utilities/lexicalToHTML.js';
8
- import { lexicalSchema } from '../ai/editor/lexical.schema.js';
9
- const asyncHandlebars = asyncHelpers(Handlebars);
10
- const replacePlaceholders = (prompt, values)=>{
11
- return asyncHandlebars.compile(prompt, {
12
- trackIds: true
13
- })(values);
14
- };
15
- const assignPrompt = async (action, { type, actionParams, context, field, systemPrompt = '', template, layout })=>{
5
+ import { registerEditorHelper } from '../libraries/handlebars/helpers.js';
6
+ import { handlebarsHelpersMap } from '../libraries/handlebars/helpersMap.js';
7
+ import { replacePlaceholders } from '../libraries/handlebars/replacePlaceholders.js';
8
+ const assignPrompt = async (action, { type, actionParams, context, field, layout, systemPrompt = '', template })=>{
16
9
  const prompt = await replacePlaceholders(template, context);
17
- const toLexicalHTML = type === 'richText' ? 'toLexicalHTML' : '';
10
+ const toLexicalHTML = type === 'richText' ? handlebarsHelpersMap.toHTML.name : '';
18
11
  const assignedPrompts = {
12
+ layout,
19
13
  prompt,
20
- system: systemPrompt,
21
- layout
14
+ system: systemPrompt
22
15
  };
23
16
  if (action === 'Compose') {
24
17
  return assignedPrompts;
25
18
  }
26
- const { system: getSystemPrompt, layout: getLayout } = defaultPrompts.find((p)=>p.name === action);
19
+ const { layout: getLayout, system: getSystemPrompt } = defaultPrompts.find((p)=>p.name === action);
27
20
  let updatedLayout = layout;
28
21
  if (getLayout) {
29
22
  updatedLayout = getLayout();
@@ -34,38 +27,12 @@ const assignPrompt = async (action, { type, actionParams, context, field, system
34
27
  systemPrompt
35
28
  });
36
29
  return {
30
+ layout: updatedLayout,
31
+ // TODO: revisit this toLexicalHTML
37
32
  prompt: await replacePlaceholders(`{{${toLexicalHTML} ${field}}}`, context),
38
- system,
39
- layout: updatedLayout
33
+ system
40
34
  };
41
35
  };
42
- const registerEditorHelper = (payload, schemaPath)=>{
43
- //TODO: add autocomplete ability using handlebars template on PromptEditorField and include custom helpers in dropdown
44
- let fieldInfo = getFieldInfo(payload.collections, schemaPath);
45
- const schemaPathChunks = schemaPath.split('.');
46
- asyncHandlebars.registerHelper('toLexicalHTML', async function(content, options) {
47
- const collectionSlug = schemaPathChunks[0];
48
- const { ids } = options;
49
- for (const id of ids){
50
- //TODO: Find a better way to get schemaPath of defined field in prompt editor
51
- const path = `${collectionSlug}.${id}`;
52
- fieldInfo = getFieldInfo(payload.collections, path);
53
- }
54
- const html = await lexicalToHTML(content, fieldInfo.editor?.editorConfig);
55
- return new asyncHandlebars.SafeString(html);
56
- });
57
- };
58
- const getFieldInfo = (collections, schemaPath)=>{
59
- let fieldInfo = null;
60
- //TODO: Only run below for enabled collections
61
- for(const collectionsKey in collections){
62
- const collection = collections[collectionsKey];
63
- fieldInfo = getFieldBySchemaPath(collection.config, schemaPath);
64
- if (fieldInfo) {
65
- return fieldInfo;
66
- }
67
- }
68
- };
69
36
  export const endpoints = {
70
37
  textarea: {
71
38
  handler: async (req)=>{
@@ -76,7 +43,7 @@ export const endpoints = {
76
43
  if (!instructionId) {
77
44
  throw new Error(`Instruction ID is required for "${PLUGIN_NAME}" to work, please check your configuration`);
78
45
  }
79
- let instructions = await req.payload.findByID({
46
+ const instructions = await req.payload.findByID({
80
47
  id: instructionId,
81
48
  collection: PLUGIN_INSTRUCTIONS_TABLE
82
49
  });
@@ -105,17 +72,17 @@ export const endpoints = {
105
72
  actionParams,
106
73
  context: contextData,
107
74
  field: fieldName,
75
+ layout: modelOptions.layout,
108
76
  systemPrompt: modelOptions.system,
109
- template: promptTemplate,
110
- layout: modelOptions.layout
77
+ template: promptTemplate
111
78
  });
112
79
  console.log('Running handler with prompts:', prompts);
113
80
  return model.handler?.(prompts.prompt, {
114
81
  ...modelOptions,
115
82
  ...opt,
116
- system: prompts.system,
117
83
  editorSchema,
118
- layout: prompts.layout
84
+ layout: prompts.layout,
85
+ system: prompts.system
119
86
  }).catch((error)=>{
120
87
  console.error('Error: endpoint - generating text:', error);
121
88
  return new Response(JSON.stringify(error.message), {