@ai-stack/payloadcms 3.0.0-beta.65.0 → 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 (44) hide show
  1. package/dist/ai/models/anthropic/index.d.ts.map +1 -1
  2. package/dist/ai/models/anthropic/index.js +42 -3
  3. package/dist/ai/models/anthropic/index.js.map +1 -1
  4. package/dist/ai/models/index.d.ts.map +1 -1
  5. package/dist/ai/models/index.js +2 -2
  6. package/dist/ai/models/index.js.map +1 -1
  7. package/dist/ai/models/openai/index.d.ts.map +1 -1
  8. package/dist/ai/models/openai/index.js +0 -1
  9. package/dist/ai/models/openai/index.js.map +1 -1
  10. package/dist/ai/prompts.d.ts +6 -6
  11. package/dist/ai/prompts.d.ts.map +1 -1
  12. package/dist/ai/prompts.js +17 -15
  13. package/dist/ai/prompts.js.map +1 -1
  14. package/dist/ai/utils/generateSeedPrompt.d.ts.map +1 -1
  15. package/dist/ai/utils/generateSeedPrompt.js +14 -5
  16. package/dist/ai/utils/generateSeedPrompt.js.map +1 -1
  17. package/dist/collections/Instructions.js +1 -1
  18. package/dist/collections/Instructions.js.map +1 -1
  19. package/dist/defaults.d.ts +2 -1
  20. package/dist/defaults.d.ts.map +1 -1
  21. package/dist/defaults.js +2 -1
  22. package/dist/defaults.js.map +1 -1
  23. package/dist/fields/LexicalEditor/feature.server.d.ts.map +1 -1
  24. package/dist/fields/LexicalEditor/feature.server.js +2 -1
  25. package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
  26. package/dist/init.d.ts.map +1 -1
  27. package/dist/init.js +11 -12
  28. package/dist/init.js.map +1 -1
  29. package/dist/plugin.d.ts.map +1 -1
  30. package/dist/plugin.js +85 -73
  31. package/dist/plugin.js.map +1 -1
  32. package/dist/ui/Actions/Actions.d.ts.map +1 -1
  33. package/dist/ui/Actions/Actions.js +9 -10
  34. package/dist/ui/Actions/Actions.js.map +1 -1
  35. package/dist/ui/Actions/hooks/useGenerate.d.ts.map +1 -1
  36. package/dist/ui/Actions/hooks/useGenerate.js +5 -6
  37. package/dist/ui/Actions/hooks/useGenerate.js.map +1 -1
  38. package/dist/utilities/isPluginActivated.d.ts +2 -0
  39. package/dist/utilities/isPluginActivated.d.ts.map +1 -0
  40. package/dist/utilities/isPluginActivated.js +5 -0
  41. package/dist/utilities/isPluginActivated.js.map +1 -0
  42. package/dist/utilities/updateFieldsConfig.js.map +1 -1
  43. package/package.json +28 -25
  44. package/dist/ui/Actions/hooks/highlight.module.scss +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAIzD,eAAO,MAAM,eAAe,EAAE,gBA8D7B,CAAA"}
1
+ {"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,14 +1,50 @@
1
+ import { anthropic } from '@ai-sdk/anthropic';
2
+ import { streamText } from 'ai';
1
3
  import { generateRichText } from './generateRichText.js';
2
4
  export const AnthropicConfig = {
3
5
  models: [
4
6
  {
5
- id: 'anthropic/claude-3.5-sonnet',
6
- name: 'Anthropic Claude 3.5 Sonnet',
7
+ id: 'anthropic-claude-text',
8
+ name: 'Anthropic Claude',
7
9
  fields: [
8
10
  'text',
9
11
  'textarea'
10
12
  ],
11
- output: 'text'
13
+ handler: async (prompt, options)=>{
14
+ console.log('options ', options);
15
+ console.log('prompt ', prompt);
16
+ const streamTextResult = await streamText({
17
+ model: anthropic(options.model),
18
+ prompt,
19
+ system: options.system || 'IMPORTANT: JUST PRODUCE THE OUTPUT, DO NOT ENGAGE!'
20
+ });
21
+ return streamTextResult.toAIStreamResponse();
22
+ },
23
+ output: 'text',
24
+ settings: {
25
+ name: 'anthropic-claude-text-settings',
26
+ type: 'group',
27
+ admin: {
28
+ condition (data) {
29
+ return data['model-id'] === 'anthropic-claude-text';
30
+ }
31
+ },
32
+ fields: [
33
+ {
34
+ name: 'model',
35
+ type: 'select',
36
+ defaultValue: 'claude-3-5-sonnet-20240620',
37
+ label: 'Model',
38
+ options: [
39
+ 'claude-3-haiku-20240307',
40
+ 'claude-3-sonnet-20240229',
41
+ 'claude-3-opus-20240229',
42
+ 'claude-3-5-sonnet-20240620'
43
+ ]
44
+ }
45
+ ],
46
+ label: 'Anthropic Claude Settings'
47
+ }
12
48
  },
13
49
  {
14
50
  id: 'anthropic-claude-object',
@@ -36,6 +72,9 @@ export const AnthropicConfig = {
36
72
  defaultValue: 'claude-3-5-sonnet-20240620',
37
73
  label: 'Model',
38
74
  options: [
75
+ 'claude-3-haiku-20240307',
76
+ 'claude-3-sonnet-20240229',
77
+ 'claude-3-opus-20240229',
39
78
  'claude-3-5-sonnet-20240620'
40
79
  ]
41
80
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ai/models/anthropic/index.ts"],"sourcesContent":["import type { GenerationConfig } from '../../../types.js'\n\nimport { generateRichText } from './generateRichText.js'\n\nexport const AnthropicConfig: GenerationConfig = {\n models: [\n {\n id: 'anthropic/claude-3.5-sonnet',\n name: 'Anthropic Claude 3.5 Sonnet',\n fields: ['text', 'textarea'],\n output: 'text',\n },\n {\n id: 'anthropic-claude-object',\n name: 'Anthropic Claude',\n fields: ['richText'],\n handler: (text: string, options) => {\n //TODO: change it to open ai text to speech api\n return generateRichText(text, options)\n },\n output: 'text',\n settings: {\n name: 'anthropic-claude-object-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'anthropic-claude-object'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'claude-3-5-sonnet-20240620',\n label: 'Model',\n options: ['claude-3-5-sonnet-20240620'],\n },\n {\n name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\n You are a highly skilled and professional blog writer,\n renowned for crafting engaging and well-organized articles.\n When given a title, you meticulously create blogs that are not only\n informative and accurate but also captivating and beautifully structured.`,\n label: 'System prompt',\n },\n {\n name: 'layout',\n type: 'textarea',\n defaultValue: `[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.\n[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.\n[list] - Create a list with 3-5 items. Each list item should contain:\n a. [heading] - A brief, descriptive heading (up to 5 words)\n b. [paragraph] - A short explanation or elaboration (1-2 sentences)\n[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.\n[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.\n[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: \"Quote text.\" - Author Name`,\n label: 'Layout',\n },\n ],\n label: 'Anthropic Claude Settings',\n },\n },\n ],\n provider: 'Anthropic',\n}\n"],"names":["generateRichText","AnthropicConfig","models","id","name","fields","output","handler","text","options","settings","type","admin","condition","data","defaultValue","label","provider"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,wBAAuB;AAExD,OAAO,MAAMC,kBAAoC;IAC/CC,QAAQ;QACN;YACEC,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,QAAQ;QACV;QACA;YACEH,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBE,SAAS,CAACC,MAAcC;gBACtB,+CAA+C;gBAC/C,OAAOT,iBAAiBQ,MAAMC;YAChC;YACAH,QAAQ;YACRI,UAAU;gBACRN,MAAM;gBACNO,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAT,QAAQ;oBACN;wBACED,MAAM;wBACNO,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPP,SAAS;4BAAC;yBAA6B;oBACzC;oBACA;wBACEL,MAAM;wBACNO,MAAM;wBACNI,cAAc,CAAC;;;;+EAIoD,CAAC;wBACpEC,OAAO;oBACT;oBACA;wBACEZ,MAAM;wBACNO,MAAM;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDC,UAAU;AACZ,EAAC"}
1
+ {"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/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAOrD,eAAO,MAAM,gBAAgB,EAAE,eAAe,EAI7C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/models/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrD,eAAO,MAAM,gBAAgB,EAAE,eAAe,EAI7C,CAAA"}
@@ -1,11 +1,11 @@
1
+ import * as process from 'node:process';
1
2
  import { AnthropicConfig } from './anthropic/index.js';
2
3
  import { ElevenLabsConfig } from './elevenLabs/index.js';
3
4
  import { OpenAIConfig } from './openai/index.js';
4
- import * as process from 'node:process';
5
5
  export const GenerationModels = [
6
6
  ...process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : [],
7
7
  ...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : [],
8
- ...OpenAIConfig.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 type { GenerationModel } from '../../types.js'\n\nimport { AnthropicConfig } from './anthropic/index.js'\nimport { ElevenLabsConfig } from './elevenLabs/index.js'\nimport { OpenAIConfig } from './openai/index.js'\nimport * as process from 'node:process'\n\nexport const GenerationModels: GenerationModel[] = [\n ...(process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : []),\n ...(process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []),\n ...OpenAIConfig.models,\n]\n"],"names":["AnthropicConfig","ElevenLabsConfig","OpenAIConfig","process","GenerationModels","env","ANTHROPIC_API_KEY","models","ELEVENLABS_API_KEY"],"mappings":"AAEA,SAASA,eAAe,QAAQ,uBAAsB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,YAAYC,aAAa,eAAc;AAEvC,OAAO,MAAMC,mBAAsC;OAC7CD,QAAQE,GAAG,CAACC,iBAAiB,GAAGN,gBAAgBO,MAAM,GAAG,EAAE;OAC3DJ,QAAQE,GAAG,CAACG,kBAAkB,GAAGP,iBAAiBM,MAAM,GAAG,EAAE;OAC9DL,aAAaK,MAAM;CACvB,CAAA"}
1
+ {"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,"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"}
@@ -5,7 +5,6 @@ import { generateImage } from './generateImage.js';
5
5
  import { generateRichText } from './generateRichText.js';
6
6
  import { generateVoice } from './generateVoice.js';
7
7
  //TODO: Simplify this file by moving the handlers to separate files and remove duplicate code
8
- //TODO: every config must have default settings selected
9
8
  export const OpenAIConfig = {
10
9
  models: [
11
10
  {
@@ -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\n//TODO: every config must have default settings selected\nexport const OpenAIConfig: GenerationConfig = {\n models: [\n {\n id: 'openai-gpt-text',\n name: 'OpenAI GPT Text',\n fields: ['text', 'textarea'],\n handler: async (\n prompt: string,\n options: { locale: string; model: string; system: string },\n ) => {\n const streamTextResult = await streamText({\n model: openai(options.model),\n prompt,\n system: options.system,\n })\n\n return streamTextResult.toAIStreamResponse()\n },\n output: 'text',\n settings: {\n name: 'openai-gpt-text-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'openai-gpt-text'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gpt-4o-mini',\n label: 'Model',\n options: ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-3.5-turbo'],\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n {\n id: 'dall-e',\n name: 'OpenAI DALL-E',\n fields: ['upload'],\n handler: async (prompt: string, options) => {\n const imageData = await generateImage(prompt, options)\n return {\n data: {\n alt: imageData.alt,\n },\n file: {\n name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.jpeg`,\n data: imageData.buffer,\n mimetype: 'image/jpeg',\n size: imageData.buffer.byteLength,\n } as File,\n }\n },\n output: 'image',\n settings: {\n name: 'dalle-e-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'dall-e'\n },\n },\n fields: [\n {\n name: 'version',\n type: 'select',\n defaultValue: 'dall-e-3',\n label: 'Version',\n options: ['dall-e-3', 'dall-e-2'],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'size',\n type: 'select',\n defaultValue: '1024x1024',\n label: 'Size',\n options: ['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792'],\n },\n {\n name: 'style',\n type: 'select',\n defaultValue: 'natural',\n label: 'Style',\n options: ['vivid', 'natural'],\n },\n ],\n },\n {\n name: 'enable-prompt-optimization',\n type: 'checkbox',\n label: 'Optimize prompt',\n },\n ],\n label: 'OpenAI DALL-E Settings',\n },\n },\n {\n id: 'tts',\n name: 'OpenAI Text-to-Speech',\n fields: ['upload'],\n handler: async (text: string, options) => {\n //TODO: change it to open ai text to speech api\n const voiceData = await generateVoice(text, options)\n return {\n data: {\n alt: text,\n },\n file: {\n name: `voice_${generateFileNameByPrompt(text)}.mp3`,\n data: voiceData.buffer,\n mimetype: 'audio/mp3',\n size: voiceData.buffer.byteLength,\n } as File,\n }\n },\n output: 'audio',\n settings: {\n name: 'openai-tts-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'tts'\n },\n },\n fields: [\n {\n name: 'voice',\n type: 'select',\n defaultValue: 'alloy',\n label: 'Voice',\n options: ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'] as Array<\n SpeechCreateParams['voice']\n >,\n },\n {\n name: 'model',\n type: 'select',\n defaultValue: 'tts-1',\n label: 'Model',\n options: ['tts-1', 'tts-1-hd'] as Array<SpeechCreateParams['model']>,\n },\n {\n name: 'response_format',\n type: 'select',\n defaultValue: 'mp3',\n label: 'Response Format',\n options: ['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'] as Array<\n SpeechCreateParams['response_format']\n >,\n },\n {\n name: 'speed',\n type: 'number',\n defaultValue: 1,\n label: 'Speed',\n max: 4,\n min: 0.25,\n },\n ],\n label: 'OpenAI Text-to-Speech Settings',\n },\n },\n {\n id: 'openai-gpt-object',\n name: 'OpenAI GPT',\n fields: ['richText'],\n handler: (text: string, options) => {\n return generateRichText(text, options)\n },\n output: 'text',\n settings: {\n name: 'openai-gpt-object-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'openai-gpt-object'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gpt-4o-2024-08-06',\n label: 'Model',\n options: ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-4o-2024-08-06'],\n },\n {\n name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\nYou are a highly skilled and professional blog writer,\nrenowned for crafting engaging and well-organized articles.\nWhen given a title, you meticulously create blogs that are not only\ninformative and accurate but also captivating and beautifully structured.`,\n label: 'System prompt',\n },\n {\n /**TODO's:\n * - Layouts can be saved in as an array\n * - user can add their own layout to collections and use it later for generate specific rich text\n * - user can select previously added layout\n */\n name: 'layout',\n type: 'textarea',\n defaultValue: `[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.\n[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.\n[list] - Create a list with 3-5 items. Each list item should contain:\n a. [heading] - A brief, descriptive heading (up to 5 words)\n b. [paragraph] - A short explanation or elaboration (1-2 sentences)\n[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.\n[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.\n[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: \"Quote text.\" - Author Name`,\n label: 'Layout',\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["openai","streamText","generateFileNameByPrompt","generateImage","generateRichText","generateVoice","OpenAIConfig","models","id","name","fields","handler","prompt","options","streamTextResult","model","system","toAIStreamResponse","output","settings","type","admin","condition","data","defaultValue","label","imageData","alt","file","buffer","mimetype","size","byteLength","text","voiceData","max","min","provider"],"mappings":"AAGA,SAASA,MAAM,QAAQ,iBAAgB;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,wDAAwD;AACxD,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,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;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;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'\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"],"mapp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U;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,OAAOT,iBAAiB6B,MAAMpB;YAChC;YACAK,QAAQ;YACRC,UAAU;gBACRV,MAAM;gBACNW,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAb,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAoB;oBACxE;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc,CAAC;;;;yEAI8C,CAAC;wBAC9DC,OAAO;oBACT;oBACA;wBACE;;;;aAIC,GACDhB,MAAM;wBACNW,MAAM;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDY,UAAU;AACZ,EAAC"}
@@ -1,24 +1,24 @@
1
1
  import type { ActionMenuItems } from '../types.js';
2
2
  type ActionPromptOptions = {
3
+ layout?: string;
4
+ locale?: string;
3
5
  prompt?: string;
4
6
  systemPrompt?: string;
5
- locale?: string;
6
- layout?: string;
7
7
  };
8
8
  type ActionPrompt = {
9
+ layout?: (options?: ActionPromptOptions) => string;
9
10
  name: ActionMenuItems;
10
11
  system: (options: ActionPromptOptions) => string;
11
- layout?: (options?: ActionPromptOptions) => string;
12
12
  };
13
13
  export declare const defaultPrompts: ActionPrompt[];
14
- export declare const seedPrompts: ({ fieldLabel, fieldType, path, fieldSchemaPaths }: {
14
+ export declare const seedPrompts: ({ fieldLabel, fieldSchemaPaths, fieldType, path }: {
15
15
  fieldLabel: any;
16
+ fieldSchemaPaths: any;
16
17
  fieldType: any;
17
18
  path: any;
18
- fieldSchemaPaths: any;
19
19
  }) => {
20
- system: string;
21
20
  prompt: string;
21
+ system: string;
22
22
  };
23
23
  export {};
24
24
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ai/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,mBAAmB,GAAG;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAA;IAChD,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;CACnD,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;CA2GvB,CAAA"}
1
+ {"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"}
@@ -54,6 +54,10 @@ export const defaultPrompts = [
54
54
  },
55
55
  {
56
56
  name: 'Summarize',
57
+ layout: ()=>`
58
+ [heading] - Summary
59
+ [paragraph] - Your summary goes here...
60
+ `,
57
61
  system: ()=>`You are an expert at summarizing information. Your task is to create a concise summary of the given text that captures its key points and essential details while preserving the original meaning.
58
62
 
59
63
  INSTRUCTIONS:
@@ -63,11 +67,7 @@ INSTRUCTIONS:
63
67
  4. Preserve the original tone and intent of the text.
64
68
  5. Ensure your summary is approximately 25-30% of the original text length.
65
69
  6. Use clear and precise language, avoiding unnecessary jargon or complexity.
66
- `,
67
- layout: ()=>`
68
- [heading] - Summary
69
- [paragraph] - Your summary goes here...
70
- `
70
+ `
71
71
  },
72
72
  {
73
73
  name: 'Tone',
@@ -82,7 +82,7 @@ INSTRUCTIONS:
82
82
  },
83
83
  {
84
84
  name: 'Translate',
85
- system: ({ prompt = '', systemPrompt = '', locale })=>`You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.
85
+ system: ({ locale, prompt = '', systemPrompt = '' })=>`You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.
86
86
 
87
87
  -------------
88
88
  INSTRUCTIONS:
@@ -94,8 +94,16 @@ INSTRUCTIONS:
94
94
  -------------`
95
95
  }
96
96
  ];
97
- export const seedPrompts = ({ fieldLabel, fieldType, path, fieldSchemaPaths })=>{
97
+ export const seedPrompts = ({ fieldLabel, fieldSchemaPaths, fieldType, path })=>{
98
98
  return {
99
+ prompt: `field-type: ${fieldType}
100
+ field-name: ${fieldLabel}
101
+ schema-path: ${path}
102
+
103
+ Give me a prompt that relate to the given field type and schema path.
104
+
105
+ Generated prompt:
106
+ `,
99
107
  system: `# AI Assistant for CMS Prompt Generation
100
108
 
101
109
  Your role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.
@@ -178,7 +186,7 @@ For upload:
178
186
  field-type: upload
179
187
  field-name: Featured Image
180
188
  schema-path: posts.image
181
- Generated prompt: Imagine a high-quality featured image for '{{ title }}
189
+ Generated prompt: Imagine {{ title }}
182
190
 
183
191
  For upload:
184
192
  field-type: upload
@@ -191,14 +199,8 @@ Remember to adapt the prompts based on the specific schema-path provided, consid
191
199
 
192
200
  Schema Map Context:
193
201
  ${JSON.stringify(fieldSchemaPaths)}
194
- `,
195
- prompt: `field-type: ${fieldType}
196
- field-name: ${fieldLabel}
197
- schema-path: ${path}
198
202
 
199
- Give me a prompt that relate to the given field type and schema path.
200
-
201
- Generated prompt:
203
+ IMPORTANT: JUST PRODUCE THE OUTPUT, DO NOT ENGAGE!
202
204
  `
203
205
  };
204
206
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ai/prompts.ts"],"sourcesContent":["import type { ActionMenuItems } from '../types.js'\n\ntype ActionPromptOptions = {\n prompt?: string\n systemPrompt?: string\n locale?: string\n layout?: string\n}\n\ntype ActionPrompt = {\n name: ActionMenuItems\n system: (options: ActionPromptOptions) => string\n layout?: (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 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 layout: () => `\n[heading] - Summary\n[paragraph] - Your summary goes here...\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: ({ prompt = '', systemPrompt = '', locale }) =>\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, fieldType, path, fieldSchemaPaths }) => {\n return {\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 a high-quality featured image for '{{ 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`,\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 }\n}\n"],"names":["defaultPrompts","name","system","prompt","systemPrompt","layout","locale","seedPrompts","fieldLabel","fieldType","path","fieldSchemaPaths","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;QACNC,QAAQ,IACN,CAAC;;;;;;;;;AASP,CAAC;QACGG,QAAQ,IAAM,CAAC;;;IAGf,CAAC;IACH;IACA;QACEJ,MAAM;QACNC,QAAQ,IACN,CAAC;;;;;;;mBAOY,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EAAEC,SAAS,EAAE,EAAEC,eAAe,EAAE,EAAEE,MAAM,EAAE,GACjD,CAAC,gEAAgE,EAAEA,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,SAAS,EAAEC,IAAI,EAAEC,gBAAgB,EAAE;IAC3E,OAAO;QACLT,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Fb,EAAEU,KAAKC,SAAS,CAACF,kBAAkB;AACnC,CAAC;QACGR,QAAQ,CAAC,YAAY,EAAEM,UAAU;YACzB,EAAED,WAAW;aACZ,EAAEE,KAAK;;;;;AAKpB,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;IAC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;;;;;;;AA8Fb,EAAEU,KAAKC,SAAS,CAACJ,kBAAkB;;;AAGnC,CAAC;IACC;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateSeedPrompt.d.ts","sourceRoot":"","sources":["../../../src/ai/utils/generateSeedPrompt.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,SAAgB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,oBAUhF,CAAA"}
1
+ {"version":3,"file":"generateSeedPrompt.d.ts","sourceRoot":"","sources":["../../../src/ai/utils/generateSeedPrompt.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,SAAgB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,oBAmBhF,CAAA"}
@@ -1,12 +1,21 @@
1
- import { generateText } from 'ai';
1
+ import { anthropic } from '@ai-sdk/anthropic';
2
2
  import { openai } from '@ai-sdk/openai';
3
- import { PLUGIN_DEFAULT_MODEL_NAME } from '../../defaults.js';
3
+ import { generateText } from 'ai';
4
+ import { PLUGIN_DEFAULT_ANTHROPIC_MODEL, PLUGIN_DEFAULT_OPENAI_MODEL } from '../../defaults.js';
4
5
  export const generateSeedPrompt = async (data)=>{
5
6
  const { prompt, system } = data;
7
+ let model = null;
8
+ if (process.env.OPENAI_API_KEY) {
9
+ model = openai(PLUGIN_DEFAULT_OPENAI_MODEL);
10
+ } else if (process.env.ANTHROPIC_API_KEY) {
11
+ model = anthropic(PLUGIN_DEFAULT_ANTHROPIC_MODEL);
12
+ } else {
13
+ throw new Error('- AI Plugin: Please check your environment variables!');
14
+ }
6
15
  const { text } = await generateText({
7
- model: openai(PLUGIN_DEFAULT_MODEL_NAME),
8
- system,
9
- prompt
16
+ model,
17
+ prompt,
18
+ system
10
19
  });
11
20
  return text;
12
21
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/utils/generateSeedPrompt.ts"],"sourcesContent":["import { generateText } from 'ai'\nimport { openai } from '@ai-sdk/openai'\nimport { PLUGIN_DEFAULT_MODEL_NAME } from '../../defaults.js'\n\nexport const generateSeedPrompt = async (data: { prompt: string; system: string }) => {\n const { prompt, system } = data\n\n const { text } = await generateText({\n model: openai(PLUGIN_DEFAULT_MODEL_NAME),\n system,\n prompt,\n })\n\n return text\n}\n"],"names":["generateText","openai","PLUGIN_DEFAULT_MODEL_NAME","generateSeedPrompt","data","prompt","system","text","model"],"mappings":"AAAA,SAASA,YAAY,QAAQ,KAAI;AACjC,SAASC,MAAM,QAAQ,iBAAgB;AACvC,SAASC,yBAAyB,QAAQ,oBAAmB;AAE7D,OAAO,MAAMC,qBAAqB,OAAOC;IACvC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGF;IAE3B,MAAM,EAAEG,IAAI,EAAE,GAAG,MAAMP,aAAa;QAClCQ,OAAOP,OAAOC;QACdI;QACAD;IACF;IAEA,OAAOE;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/ai/utils/generateSeedPrompt.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { openai } from '@ai-sdk/openai'\nimport { generateText } from 'ai'\n\nimport { PLUGIN_DEFAULT_ANTHROPIC_MODEL, PLUGIN_DEFAULT_OPENAI_MODEL } from '../../defaults.js'\n\nexport const generateSeedPrompt = async (data: { prompt: string; system: string }) => {\n const { prompt, system } = data\n let model = null\n\n if (process.env.OPENAI_API_KEY) {\n model = openai(PLUGIN_DEFAULT_OPENAI_MODEL)\n } else if (process.env.ANTHROPIC_API_KEY) {\n model = anthropic(PLUGIN_DEFAULT_ANTHROPIC_MODEL)\n } else {\n throw new Error('- AI Plugin: Please check your environment variables!')\n }\n\n const { text } = await generateText({\n model,\n prompt,\n system,\n })\n\n return text\n}\n"],"names":["anthropic","openai","generateText","PLUGIN_DEFAULT_ANTHROPIC_MODEL","PLUGIN_DEFAULT_OPENAI_MODEL","generateSeedPrompt","data","prompt","system","model","process","env","OPENAI_API_KEY","ANTHROPIC_API_KEY","Error","text"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,MAAM,QAAQ,iBAAgB;AACvC,SAASC,YAAY,QAAQ,KAAI;AAEjC,SAASC,8BAA8B,EAAEC,2BAA2B,QAAQ,oBAAmB;AAE/F,OAAO,MAAMC,qBAAqB,OAAOC;IACvC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGF;IAC3B,IAAIG,QAAQ;IAEZ,IAAIC,QAAQC,GAAG,CAACC,cAAc,EAAE;QAC9BH,QAAQR,OAAOG;IACjB,OAAO,IAAIM,QAAQC,GAAG,CAACE,iBAAiB,EAAE;QACxCJ,QAAQT,UAAUG;IACpB,OAAO;QACL,MAAM,IAAIW,MAAM;IAClB;IAEA,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMb,aAAa;QAClCO;QACAF;QACAC;IACF;IAEA,OAAOO;AACT,EAAC"}
@@ -99,7 +99,7 @@ export const Instructions = {
99
99
  hooks: {
100
100
  beforeChange: [
101
101
  (req)=>{
102
- if (req.data['openai-gpt-object-settings'].layout?.length === 0) {
102
+ if (req.data['openai-gpt-object-settings']?.layout?.length === 0) {
103
103
  // TODO: why??
104
104
  req.data['openai-gpt-object-settings'].layout = '';
105
105
  }
@@ -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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Z,CAACC;gBACC,IAAIA,IAAIC,IAAI,CAAC,6BAA6B,CAACC,MAAM,EAAEC,WAAW,GAAG;oBAC/D,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'\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"}
@@ -5,5 +5,6 @@ export declare const PLUGIN_LEXICAL_EDITOR_FEATURE = "plugin-ai-actions-feature"
5
5
  export declare const PLUGIN_API_ENDPOINT_BASE = "/plugin-ai";
6
6
  export declare const PLUGIN_API_ENDPOINT_GENERATE = "/plugin-ai/generate";
7
7
  export declare const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = "/plugin-ai/generate/upload";
8
- export declare const PLUGIN_DEFAULT_MODEL_NAME = "gpt-4o-mini";
8
+ export declare const PLUGIN_DEFAULT_OPENAI_MODEL = "gpt-4o-mini";
9
+ export declare const PLUGIN_DEFAULT_ANTHROPIC_MODEL = "claude-3-sonnet-20240229";
9
10
  //# sourceMappingURL=defaults.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,cAAc,CAAA;AACtC,eAAO,MAAM,yBAAyB,2BAAgC,CAAA;AACtE,eAAO,MAAM,8BAA8B,yCAAoD,CAAA;AAC/F,eAAO,MAAM,6BAA6B,8BAAmC,CAAA;AAG7E,eAAO,MAAM,wBAAwB,eAAoB,CAAA;AACzD,eAAO,MAAM,4BAA4B,wBAAyC,CAAA;AAClF,eAAO,MAAM,mCAAmC,+BAA2C,CAAA;AAG3F,eAAO,MAAM,yBAAyB,gBAAgB,CAAA"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,cAAc,CAAA;AACtC,eAAO,MAAM,yBAAyB,2BAAgC,CAAA;AACtE,eAAO,MAAM,8BAA8B,yCAAoD,CAAA;AAC/F,eAAO,MAAM,6BAA6B,8BAAmC,CAAA;AAG7E,eAAO,MAAM,wBAAwB,eAAoB,CAAA;AACzD,eAAO,MAAM,4BAA4B,wBAAyC,CAAA;AAClF,eAAO,MAAM,mCAAmC,+BAA2C,CAAA;AAG3F,eAAO,MAAM,2BAA2B,gBAAgB,CAAA;AACxD,eAAO,MAAM,8BAA8B,6BAA6B,CAAA"}
package/dist/defaults.js CHANGED
@@ -7,6 +7,7 @@ export const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`;
7
7
  export const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`;
8
8
  export const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`;
9
9
  // LLM Settings
10
- export const PLUGIN_DEFAULT_MODEL_NAME = `gpt-4o-mini`;
10
+ export const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`;
11
+ export const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-sonnet-20240229`;
11
12
 
12
13
  //# sourceMappingURL=defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const PLUGIN_NAME = 'plugin-ai'\nexport const PLUGIN_INSTRUCTIONS_TABLE = `${PLUGIN_NAME}-instructions`\nexport const PLUGIN_INSTRUCTIONS_MAP_GLOBAL = `${PLUGIN_NAME}-${PLUGIN_INSTRUCTIONS_TABLE}-map`\nexport const PLUGIN_LEXICAL_EDITOR_FEATURE = `${PLUGIN_NAME}-actions-feature`\n\n// Endpoint defaults\nexport const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`\nexport const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`\nexport const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`\n\n// LLM Settings\nexport const PLUGIN_DEFAULT_MODEL_NAME = `gpt-4o-mini`\n"],"names":["PLUGIN_NAME","PLUGIN_INSTRUCTIONS_TABLE","PLUGIN_INSTRUCTIONS_MAP_GLOBAL","PLUGIN_LEXICAL_EDITOR_FEATURE","PLUGIN_API_ENDPOINT_BASE","PLUGIN_API_ENDPOINT_GENERATE","PLUGIN_API_ENDPOINT_GENERATE_UPLOAD","PLUGIN_DEFAULT_MODEL_NAME"],"mappings":"AAAA,OAAO,MAAMA,cAAc,YAAW;AACtC,OAAO,MAAMC,4BAA4B,CAAC,EAAED,YAAY,aAAa,CAAC,CAAA;AACtE,OAAO,MAAME,iCAAiC,CAAC,EAAEF,YAAY,CAAC,EAAEC,0BAA0B,IAAI,CAAC,CAAA;AAC/F,OAAO,MAAME,gCAAgC,CAAC,EAAEH,YAAY,gBAAgB,CAAC,CAAA;AAE7E,oBAAoB;AACpB,OAAO,MAAMI,2BAA2B,CAAC,CAAC,EAAEJ,YAAY,CAAC,CAAA;AACzD,OAAO,MAAMK,+BAA+B,CAAC,EAAED,yBAAyB,SAAS,CAAC,CAAA;AAClF,OAAO,MAAME,sCAAsC,CAAC,EAAED,6BAA6B,OAAO,CAAC,CAAA;AAE3F,eAAe;AACf,OAAO,MAAME,4BAA4B,CAAC,WAAW,CAAC,CAAA"}
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const PLUGIN_NAME = 'plugin-ai'\nexport const PLUGIN_INSTRUCTIONS_TABLE = `${PLUGIN_NAME}-instructions`\nexport const PLUGIN_INSTRUCTIONS_MAP_GLOBAL = `${PLUGIN_NAME}-${PLUGIN_INSTRUCTIONS_TABLE}-map`\nexport const PLUGIN_LEXICAL_EDITOR_FEATURE = `${PLUGIN_NAME}-actions-feature`\n\n// Endpoint defaults\nexport const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`\nexport const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`\nexport const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`\n\n// LLM Settings\nexport const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`\nexport const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-sonnet-20240229`\n"],"names":["PLUGIN_NAME","PLUGIN_INSTRUCTIONS_TABLE","PLUGIN_INSTRUCTIONS_MAP_GLOBAL","PLUGIN_LEXICAL_EDITOR_FEATURE","PLUGIN_API_ENDPOINT_BASE","PLUGIN_API_ENDPOINT_GENERATE","PLUGIN_API_ENDPOINT_GENERATE_UPLOAD","PLUGIN_DEFAULT_OPENAI_MODEL","PLUGIN_DEFAULT_ANTHROPIC_MODEL"],"mappings":"AAAA,OAAO,MAAMA,cAAc,YAAW;AACtC,OAAO,MAAMC,4BAA4B,CAAC,EAAED,YAAY,aAAa,CAAC,CAAA;AACtE,OAAO,MAAME,iCAAiC,CAAC,EAAEF,YAAY,CAAC,EAAEC,0BAA0B,IAAI,CAAC,CAAA;AAC/F,OAAO,MAAME,gCAAgC,CAAC,EAAEH,YAAY,gBAAgB,CAAC,CAAA;AAE7E,oBAAoB;AACpB,OAAO,MAAMI,2BAA2B,CAAC,CAAC,EAAEJ,YAAY,CAAC,CAAA;AACzD,OAAO,MAAMK,+BAA+B,CAAC,EAAED,yBAAyB,SAAS,CAAC,CAAA;AAClF,OAAO,MAAME,sCAAsC,CAAC,EAAED,6BAA6B,OAAO,CAAC,CAAA;AAE3F,eAAe;AACf,OAAO,MAAME,8BAA8B,CAAC,WAAW,CAAC,CAAA;AACxD,OAAO,MAAMC,iCAAiC,CAAC,wBAAwB,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../src/fields/LexicalEditor/feature.server.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mCAAmC;;;;;;EAiB9C,CAAA"}
1
+ {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../src/fields/LexicalEditor/feature.server.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mCAAmC;;;;;;EAiB9C,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { createServerFeature } from '@payloadcms/richtext-lexical';
2
2
  import { PLUGIN_LEXICAL_EDITOR_FEATURE } from '../../defaults.js';
3
+ import { isPluginActivated } from '../../utilities/isPluginActivated.js';
3
4
  import { LexicalEditorFeatureClient } from './feature.client.js';
4
5
  export const PayloadAiPluginLexicalEditorFeature = createServerFeature({
5
6
  feature: ({ props })=>{
@@ -8,7 +9,7 @@ export const PayloadAiPluginLexicalEditorFeature = createServerFeature({
8
9
  disableIfParentHasFixedToolbar: props?.disableIfParentHasFixedToolbar === undefined ? false : props.disableIfParentHasFixedToolbar
9
10
  };
10
11
  return {
11
- ClientFeature: LexicalEditorFeatureClient,
12
+ ClientFeature: isPluginActivated() ? LexicalEditorFeatureClient : null,
12
13
  clientFeatureProps: sanitizedProps,
13
14
  sanitizedServerFeatureProps: sanitizedProps
14
15
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/LexicalEditor/feature.server.ts"],"sourcesContent":["import { createServerFeature } from '@payloadcms/richtext-lexical'\n\nimport { PLUGIN_LEXICAL_EDITOR_FEATURE } from '../../defaults.js'\nimport { LexicalEditorFeatureClient } from './feature.client.js'\n\nexport const PayloadAiPluginLexicalEditorFeature = createServerFeature({\n feature: ({ props }: Record<any, any>) => {\n const sanitizedProps = {\n applyToFocusedEditor:\n props?.applyToFocusedEditor === undefined ? false : props.applyToFocusedEditor,\n disableIfParentHasFixedToolbar:\n props?.disableIfParentHasFixedToolbar === undefined\n ? false\n : props.disableIfParentHasFixedToolbar,\n }\n return {\n ClientFeature: LexicalEditorFeatureClient,\n clientFeatureProps: sanitizedProps,\n sanitizedServerFeatureProps: sanitizedProps,\n }\n },\n key: PLUGIN_LEXICAL_EDITOR_FEATURE,\n})\n"],"names":["createServerFeature","PLUGIN_LEXICAL_EDITOR_FEATURE","LexicalEditorFeatureClient","PayloadAiPluginLexicalEditorFeature","feature","props","sanitizedProps","applyToFocusedEditor","undefined","disableIfParentHasFixedToolbar","ClientFeature","clientFeatureProps","sanitizedServerFeatureProps","key"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,+BAA8B;AAElE,SAASC,6BAA6B,QAAQ,oBAAmB;AACjE,SAASC,0BAA0B,QAAQ,sBAAqB;AAEhE,OAAO,MAAMC,sCAAsCH,oBAAoB;IACrEI,SAAS,CAAC,EAAEC,KAAK,EAAoB;QACnC,MAAMC,iBAAiB;YACrBC,sBACEF,OAAOE,yBAAyBC,YAAY,QAAQH,MAAME,oBAAoB;YAChFE,gCACEJ,OAAOI,mCAAmCD,YACtC,QACAH,MAAMI,8BAA8B;QAC5C;QACA,OAAO;YACLC,eAAeR;YACfS,oBAAoBL;YACpBM,6BAA6BN;QAC/B;IACF;IACAO,KAAKZ;AACP,GAAE"}
1
+ {"version":3,"sources":["../../../src/fields/LexicalEditor/feature.server.ts"],"sourcesContent":["import { createServerFeature } from '@payloadcms/richtext-lexical'\n\nimport { PLUGIN_LEXICAL_EDITOR_FEATURE } from '../../defaults.js'\nimport { isPluginActivated } from '../../utilities/isPluginActivated.js'\nimport { LexicalEditorFeatureClient } from './feature.client.js'\n\nexport const PayloadAiPluginLexicalEditorFeature = createServerFeature({\n feature: ({ props }: Record<any, any>) => {\n const sanitizedProps = {\n applyToFocusedEditor:\n props?.applyToFocusedEditor === undefined ? false : props.applyToFocusedEditor,\n disableIfParentHasFixedToolbar:\n props?.disableIfParentHasFixedToolbar === undefined\n ? false\n : props.disableIfParentHasFixedToolbar,\n }\n return {\n ClientFeature: isPluginActivated() ? LexicalEditorFeatureClient : null,\n clientFeatureProps: sanitizedProps,\n sanitizedServerFeatureProps: sanitizedProps,\n }\n },\n key: PLUGIN_LEXICAL_EDITOR_FEATURE,\n})\n"],"names":["createServerFeature","PLUGIN_LEXICAL_EDITOR_FEATURE","isPluginActivated","LexicalEditorFeatureClient","PayloadAiPluginLexicalEditorFeature","feature","props","sanitizedProps","applyToFocusedEditor","undefined","disableIfParentHasFixedToolbar","ClientFeature","clientFeatureProps","sanitizedServerFeatureProps","key"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,+BAA8B;AAElE,SAASC,6BAA6B,QAAQ,oBAAmB;AACjE,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,0BAA0B,QAAQ,sBAAqB;AAEhE,OAAO,MAAMC,sCAAsCJ,oBAAoB;IACrEK,SAAS,CAAC,EAAEC,KAAK,EAAoB;QACnC,MAAMC,iBAAiB;YACrBC,sBACEF,OAAOE,yBAAyBC,YAAY,QAAQH,MAAME,oBAAoB;YAChFE,gCACEJ,OAAOI,mCAAmCD,YACtC,QACAH,MAAMI,8BAA8B;QAC5C;QACA,OAAO;YACLC,eAAeT,sBAAsBC,6BAA6B;YAClES,oBAAoBL;YACpBM,6BAA6BN;QAC/B;IACF;IACAO,KAAKb;AACP,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtC,eAAO,MAAM,IAAI,YAAmB,OAAO,yCAqE1C,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtC,eAAO,MAAM,IAAI,YAAmB,OAAO,yCAoE1C,CAAA"}
package/dist/init.js CHANGED
@@ -1,11 +1,10 @@
1
- import { PLUGIN_INSTRUCTIONS_MAP_GLOBAL, PLUGIN_INSTRUCTIONS_TABLE } from './defaults.js';
2
1
  import { GenerationModels } from './ai/models/index.js';
3
- import { generateSeedPrompt } from './ai/utils/generateSeedPrompt.js';
4
2
  import { seedPrompts } from './ai/prompts.js';
3
+ import { generateSeedPrompt } from './ai/utils/generateSeedPrompt.js';
4
+ import { PLUGIN_INSTRUCTIONS_MAP_GLOBAL, PLUGIN_INSTRUCTIONS_TABLE } from './defaults.js';
5
5
  export const init = async (payload, fieldSchemaPaths)=>{
6
6
  payload.logger.info(`— AI Plugin: Initializing...`);
7
7
  const paths = Object.keys(fieldSchemaPaths);
8
- // TODO: Add default options according to field type in INSTRUCTIONS table
9
8
  const fieldInstructionsMap = {};
10
9
  for(let i = 0; i < paths.length; i++){
11
10
  const path = paths[i];
@@ -22,26 +21,26 @@ export const init = async (payload, fieldSchemaPaths)=>{
22
21
  }
23
22
  });
24
23
  if (!entry?.docs?.length) {
25
- const { system, prompt } = seedPrompts({
26
- fieldType,
24
+ const { prompt, system } = seedPrompts({
27
25
  fieldLabel,
28
- path,
29
- fieldSchemaPaths
26
+ fieldSchemaPaths,
27
+ fieldType,
28
+ path
30
29
  });
31
30
  const generatedPrompt = await generateSeedPrompt({
32
- system,
33
- prompt
31
+ prompt,
32
+ system
34
33
  });
35
34
  payload.logger.info(`\nPrompt generated for "${fieldLabel}" field:\nprompt: ${generatedPrompt}\n\n`);
36
35
  const instructions = await payload.create({
37
36
  collection: PLUGIN_INSTRUCTIONS_TABLE,
38
37
  data: {
39
38
  'field-type': fieldType,
40
- 'schema-path': path,
41
39
  'model-id': GenerationModels.find((a)=>{
42
40
  return a.fields.includes(fieldType);
43
- }).id,
44
- prompt: generatedPrompt
41
+ })?.id,
42
+ prompt: generatedPrompt,
43
+ 'schema-path': path
45
44
  }
46
45
  });
47
46
  fieldInstructionsMap[path] = instructions.id;