@ai-stack/payloadcms 3.0.0-beta.104.1 → 3.0.0-beta.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/ai/{schemas → editor}/lexical.schema.d.ts +2 -2
- package/dist/ai/editor/lexical.schema.d.ts.map +1 -0
- package/dist/ai/editor/lexical.schema.js.map +1 -0
- package/dist/ai/models/anthropic/index.d.ts.map +1 -1
- package/dist/ai/models/anthropic/index.js +4 -43
- package/dist/ai/models/anthropic/index.js.map +1 -1
- package/dist/ai/models/elevenLabs/index.d.ts.map +1 -1
- package/dist/ai/models/elevenLabs/index.js +11 -1
- package/dist/ai/models/elevenLabs/index.js.map +1 -1
- package/dist/ai/models/index.d.ts.map +1 -1
- package/dist/ai/models/index.js +3 -3
- package/dist/ai/models/index.js.map +1 -1
- package/dist/ai/models/openai/index.js +3 -3
- package/dist/ai/models/openai/index.js.map +1 -1
- package/dist/ai/models/style.d.ts +2 -0
- package/dist/ai/models/style.d.ts.map +1 -0
- package/dist/ai/models/style.js +31 -0
- package/dist/ai/models/style.js.map +1 -0
- package/dist/ai/prompts.d.ts +6 -7
- package/dist/ai/prompts.d.ts.map +1 -1
- package/dist/ai/prompts.js +16 -21
- package/dist/ai/prompts.js.map +1 -1
- package/dist/ai/utils/generateSeedPrompt.d.ts.map +1 -1
- package/dist/ai/utils/generateSeedPrompt.js +5 -14
- package/dist/ai/utils/generateSeedPrompt.js.map +1 -1
- package/dist/collections/Instructions.d.ts.map +1 -1
- package/dist/collections/Instructions.js +13 -10
- package/dist/collections/Instructions.js.map +1 -1
- package/dist/defaults.d.ts +2 -3
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +2 -3
- package/dist/defaults.js.map +1 -1
- package/dist/endpoints/index.d.ts +1 -1
- package/dist/endpoints/index.d.ts.map +1 -1
- package/dist/endpoints/index.js +51 -17
- package/dist/endpoints/index.js.map +1 -1
- package/dist/exports/fields.d.ts +1 -3
- package/dist/exports/fields.d.ts.map +1 -1
- package/dist/exports/fields.js +0 -3
- package/dist/exports/fields.js.map +1 -1
- package/dist/fields/DescriptionField/DescriptionField.d.ts +2 -3
- package/dist/fields/DescriptionField/DescriptionField.d.ts.map +1 -1
- package/dist/fields/DescriptionField/DescriptionField.js +11 -14
- package/dist/fields/DescriptionField/DescriptionField.js.map +1 -1
- package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts +4 -0
- package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts.map +1 -0
- package/dist/fields/DescriptionField/DescriptionFieldComponent.js +18 -0
- package/dist/fields/DescriptionField/DescriptionFieldComponent.js.map +1 -0
- package/dist/fields/LexicalEditor/ActionsFeatureComponent.js +1 -1
- package/dist/fields/LexicalEditor/ActionsFeatureComponent.js.map +1 -1
- package/dist/fields/LexicalEditor/feature.server.d.ts +7 -1
- package/dist/fields/LexicalEditor/feature.server.d.ts.map +1 -1
- package/dist/fields/LexicalEditor/feature.server.js +11 -4
- package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.js +51 -32
- package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
- package/dist/fields/SelectField/SelectField.d.ts +2 -9
- package/dist/fields/SelectField/SelectField.d.ts.map +1 -1
- package/dist/fields/SelectField/SelectField.js +23 -26
- package/dist/fields/SelectField/SelectField.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -2
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +19 -35
- package/dist/init.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +73 -96
- package/dist/plugin.js.map +1 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts +3 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts.map +1 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
- package/dist/providers/InstructionsProvider/hook.d.ts +9 -0
- package/dist/providers/InstructionsProvider/hook.d.ts.map +1 -0
- package/dist/providers/InstructionsProvider/hook.js +17 -0
- package/dist/providers/InstructionsProvider/hook.js.map +1 -0
- package/dist/providers/InstructionsProvider/index.d.ts +5 -0
- package/dist/providers/InstructionsProvider/index.d.ts.map +1 -0
- package/dist/providers/InstructionsProvider/index.js +10 -0
- package/dist/providers/InstructionsProvider/index.js.map +1 -0
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/Actions/Actions.d.ts.map +1 -1
- package/dist/ui/Actions/Actions.js +48 -40
- package/dist/ui/Actions/Actions.js.map +1 -1
- package/dist/ui/Actions/hooks/highlight.module.scss +3 -0
- package/dist/ui/Actions/hooks/useGenerate.d.ts.map +1 -1
- package/dist/ui/Actions/hooks/useGenerate.js +10 -9
- package/dist/ui/Actions/hooks/useGenerate.js.map +1 -1
- package/dist/ui/Floatype/Floatype.d.ts +21 -0
- package/dist/ui/Floatype/Floatype.d.ts.map +1 -0
- package/dist/ui/Floatype/Floatype.js +245 -0
- package/dist/ui/Floatype/Floatype.js.map +1 -0
- package/dist/ui/Floatype/floatype.module.css +25 -0
- package/dist/utilities/getFieldBySchemaPath.d.ts +2 -2
- package/dist/utilities/getFieldBySchemaPath.d.ts.map +1 -1
- package/dist/utilities/getFieldBySchemaPath.js.map +1 -1
- package/dist/utilities/updateFieldsConfig.d.ts.map +1 -1
- package/dist/utilities/updateFieldsConfig.js +8 -18
- package/dist/utilities/updateFieldsConfig.js.map +1 -1
- package/package.json +33 -79
- package/dist/ai/schemas/lexical.schema.d.ts.map +0 -1
- package/dist/ai/schemas/lexical.schema.js.map +0 -1
- package/dist/exports/client.d.ts +0 -3
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js +0 -4
- package/dist/exports/client.js.map +0 -1
- package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts +0 -8
- package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts.map +0 -1
- package/dist/libraries/autocomplete/AutocompleteTextArea.js +0 -437
- package/dist/libraries/autocomplete/AutocompleteTextArea.js.map +0 -1
- package/dist/libraries/autocomplete/AutocompleteTextArea.module.scss +0 -35
- package/dist/libraries/handlebars/asyncHandlebars.d.ts +0 -2
- package/dist/libraries/handlebars/asyncHandlebars.d.ts.map +0 -1
- package/dist/libraries/handlebars/asyncHandlebars.js +0 -5
- package/dist/libraries/handlebars/asyncHandlebars.js.map +0 -1
- package/dist/libraries/handlebars/helpers.d.ts +0 -2
- package/dist/libraries/handlebars/helpers.d.ts.map +0 -1
- package/dist/libraries/handlebars/helpers.js +0 -22
- package/dist/libraries/handlebars/helpers.js.map +0 -1
- package/dist/libraries/handlebars/helpersMap.d.ts +0 -12
- package/dist/libraries/handlebars/helpersMap.d.ts.map +0 -1
- package/dist/libraries/handlebars/helpersMap.js +0 -13
- package/dist/libraries/handlebars/helpersMap.js.map +0 -1
- package/dist/libraries/handlebars/replacePlaceholders.d.ts +0 -2
- package/dist/libraries/handlebars/replacePlaceholders.d.ts.map +0 -1
- package/dist/libraries/handlebars/replacePlaceholders.js +0 -8
- package/dist/libraries/handlebars/replacePlaceholders.js.map +0 -1
- package/dist/providers/InstructionsProvider/useInstructions.d.ts +0 -4
- package/dist/providers/InstructionsProvider/useInstructions.d.ts.map +0 -1
- package/dist/providers/InstructionsProvider/useInstructions.js +0 -38
- package/dist/providers/InstructionsProvider/useInstructions.js.map +0 -1
- package/dist/utilities/getFieldInfo.d.ts +0 -3
- package/dist/utilities/getFieldInfo.d.ts.map +0 -1
- package/dist/utilities/getFieldInfo.js +0 -14
- package/dist/utilities/getFieldInfo.js.map +0 -1
- package/dist/utilities/isPluginActivated.d.ts +0 -2
- package/dist/utilities/isPluginActivated.d.ts.map +0 -1
- package/dist/utilities/isPluginActivated.js +0 -5
- package/dist/utilities/isPluginActivated.js.map +0 -1
- /package/dist/ai/{schemas → editor}/lexical.schema.js +0 -0
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
The Payload AI Plugin is an advanced extension that integrates modern AI capabilities into your Payload CMS, streamlining content creation and management.
|
|
10
10
|
|
|
11
|
-
> **⚠️ Important:** This plugin is in active development. We're doing our best to improve its features and functionality. Please be prepared for regular updates; at the moment, the plugin has only been tested with Payload version
|
|
11
|
+
> **⚠️ Important:** This plugin is in active development. We're doing our best to improve its features and functionality. Please be prepared for regular updates; at the moment, the plugin has only been tested with Payload version 3.0.0-beta.65.
|
|
12
12
|
>
|
|
13
|
-
> To give it a try, we recommend using [Payload's website template](https://github.com/payloadcms/payload/tree/v3.0.0-beta.
|
|
13
|
+
> To give it a try, we recommend using [Payload's website template](https://github.com/payloadcms/payload/tree/v3.0.0-beta.65/templates/website).
|
|
14
14
|
|
|
15
15
|
### 🎥 [Watch the Magic in Action](https://youtu.be/qaYukeGpuu4)
|
|
16
16
|
|
|
@@ -7,15 +7,15 @@ export declare const LexicalBaseNode: z.ZodObject<{
|
|
|
7
7
|
indent: z.ZodOptional<z.ZodNumber>;
|
|
8
8
|
version: z.ZodOptional<z.ZodNumber>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
type?: string;
|
|
11
10
|
children?: any[];
|
|
11
|
+
type?: string;
|
|
12
12
|
direction?: "ltr";
|
|
13
13
|
format?: string;
|
|
14
14
|
indent?: number;
|
|
15
15
|
version?: number;
|
|
16
16
|
}, {
|
|
17
|
-
type?: string;
|
|
18
17
|
children?: any[];
|
|
18
|
+
type?: string;
|
|
19
19
|
direction?: "ltr";
|
|
20
20
|
format?: string;
|
|
21
21
|
indent?: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical.schema.d.ts","sourceRoot":"","sources":["../../../src/ai/editor/lexical.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;EAO1B,CAAA;AAEF,eAAO,MAAM,aAAa,iBAAkB,CAAC,OAAO,eAAe,CAAC,EAAE;;;;;;EA0ErE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ai/editor/lexical.schema.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const LexicalBaseNode = z.object({\n type: z.string(),\n children: z.array(z.any()).optional(),\n direction: z.enum(['ltr']).nullable().optional(),\n format: z.string().optional(),\n indent: z.number().optional(),\n version: z.number().optional(),\n})\n\nexport const lexicalSchema = (customNodes?: (typeof LexicalBaseNode)[]) => {\n const BaseNode = z.object({\n type: z.string(),\n children: z.array(z.lazy(() => Node)).optional(),\n direction: z.enum(['ltr']).nullable().optional(),\n format: z.string().optional(),\n indent: z.number().optional(),\n version: z.number().optional(),\n })\n\n const TextNode = BaseNode.extend({\n type: z.literal('text'),\n format: z.number().optional(),\n text: z.string(),\n })\n\n const LinkNode = BaseNode.extend({\n id: z.string(),\n type: z.literal('link'),\n fields: z.object({\n linkType: z.string(),\n newTab: z.boolean(),\n url: z.string(),\n }),\n })\n\n const ListItemNode = BaseNode.extend({\n type: z.literal('listitem'),\n checked: z.boolean().optional(),\n value: z.number(),\n })\n\n const ListNode = BaseNode.extend({\n type: z.literal('list'),\n listType: z.enum(['check', 'number', 'bullet']),\n start: z.number(),\n tag: z.enum(['ul', 'ol']),\n })\n\n const HeadingNode = BaseNode.extend({\n type: z.literal('heading'),\n tag: z.enum(['h1', 'h2', 'h3', 'h4']),\n })\n\n // Example of custom node - wip\n const MediaNode = BaseNode.extend({\n type: z.literal('block'),\n version: z.literal(2),\n fields: z.object({\n id: z.string(),\n media: z.string(),\n position: z.enum(['fullscreen', 'default']),\n blockName: z.string(),\n blockType: z.literal('mediaBlock'),\n }),\n })\n\n const Node = z.union([\n TextNode,\n LinkNode,\n ListItemNode,\n ListNode,\n HeadingNode,\n BaseNode.extend({ type: z.enum(['paragraph', 'quote', 'horizontalrule']) }),\n ...(customNodes || []),\n ])\n\n const RootNode = BaseNode.extend({\n type: z.literal('root'),\n })\n\n return z.object({\n root: RootNode,\n })\n}\n"],"names":["z","LexicalBaseNode","object","type","string","children","array","any","optional","direction","enum","nullable","format","indent","number","version","lexicalSchema","customNodes","BaseNode","lazy","Node","TextNode","extend","literal","text","LinkNode","id","fields","linkType","newTab","boolean","url","ListItemNode","checked","value","ListNode","listType","start","tag","HeadingNode","MediaNode","media","position","blockName","blockType","union","RootNode","root"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,MAAMH,EAAEI,MAAM;IACdC,UAAUL,EAAEM,KAAK,CAACN,EAAEO,GAAG,IAAIC,QAAQ;IACnCC,WAAWT,EAAEU,IAAI,CAAC;QAAC;KAAM,EAAEC,QAAQ,GAAGH,QAAQ;IAC9CI,QAAQZ,EAAEI,MAAM,GAAGI,QAAQ;IAC3BK,QAAQb,EAAEc,MAAM,GAAGN,QAAQ;IAC3BO,SAASf,EAAEc,MAAM,GAAGN,QAAQ;AAC9B,GAAE;AAEF,OAAO,MAAMQ,gBAAgB,CAACC;IAC5B,MAAMC,WAAWlB,EAAEE,MAAM,CAAC;QACxBC,MAAMH,EAAEI,MAAM;QACdC,UAAUL,EAAEM,KAAK,CAACN,EAAEmB,IAAI,CAAC,IAAMC,OAAOZ,QAAQ;QAC9CC,WAAWT,EAAEU,IAAI,CAAC;YAAC;SAAM,EAAEC,QAAQ,GAAGH,QAAQ;QAC9CI,QAAQZ,EAAEI,MAAM,GAAGI,QAAQ;QAC3BK,QAAQb,EAAEc,MAAM,GAAGN,QAAQ;QAC3BO,SAASf,EAAEc,MAAM,GAAGN,QAAQ;IAC9B;IAEA,M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wC,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":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAIzD,eAAO,MAAM,eAAe,EAAE,gBA8D7B,CAAA"}
|
|
@@ -1,51 +1,14 @@
|
|
|
1
|
-
import { anthropic } from '@ai-sdk/anthropic';
|
|
2
|
-
import { streamText } from 'ai';
|
|
3
1
|
import { generateRichText } from './generateRichText.js';
|
|
4
|
-
import { defaultSystemPrompt } from '../../prompts.js';
|
|
5
2
|
export const AnthropicConfig = {
|
|
6
3
|
models: [
|
|
7
4
|
{
|
|
8
|
-
id: 'anthropic
|
|
9
|
-
name: 'Anthropic Claude',
|
|
5
|
+
id: 'anthropic/claude-3.5-sonnet',
|
|
6
|
+
name: 'Anthropic Claude 3.5 Sonnet',
|
|
10
7
|
fields: [
|
|
11
8
|
'text',
|
|
12
9
|
'textarea'
|
|
13
10
|
],
|
|
14
|
-
|
|
15
|
-
console.log('options ', options);
|
|
16
|
-
console.log('prompt ', prompt);
|
|
17
|
-
const streamTextResult = await streamText({
|
|
18
|
-
model: anthropic(options.model),
|
|
19
|
-
prompt,
|
|
20
|
-
system: options.system || defaultSystemPrompt
|
|
21
|
-
});
|
|
22
|
-
return streamTextResult.toDataStreamResponse();
|
|
23
|
-
},
|
|
24
|
-
output: 'text',
|
|
25
|
-
settings: {
|
|
26
|
-
name: 'anthropic-claude-text-settings',
|
|
27
|
-
type: 'group',
|
|
28
|
-
admin: {
|
|
29
|
-
condition (data) {
|
|
30
|
-
return data['model-id'] === 'anthropic-claude-text';
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
fields: [
|
|
34
|
-
{
|
|
35
|
-
name: 'model',
|
|
36
|
-
type: 'select',
|
|
37
|
-
defaultValue: 'claude-3-5-sonnet-20240620',
|
|
38
|
-
label: 'Model',
|
|
39
|
-
options: [
|
|
40
|
-
'claude-3-haiku-20240307',
|
|
41
|
-
'claude-3-sonnet-20240229',
|
|
42
|
-
'claude-3-opus-20240229',
|
|
43
|
-
'claude-3-5-sonnet-20240620'
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
label: 'Anthropic Claude Settings'
|
|
48
|
-
}
|
|
11
|
+
output: 'text'
|
|
49
12
|
},
|
|
50
13
|
{
|
|
51
14
|
id: 'anthropic-claude-object',
|
|
@@ -54,6 +17,7 @@ export const AnthropicConfig = {
|
|
|
54
17
|
'richText'
|
|
55
18
|
],
|
|
56
19
|
handler: (text, options)=>{
|
|
20
|
+
//TODO: change it to open ai text to speech api
|
|
57
21
|
return generateRichText(text, options);
|
|
58
22
|
},
|
|
59
23
|
output: 'text',
|
|
@@ -72,9 +36,6 @@ export const AnthropicConfig = {
|
|
|
72
36
|
defaultValue: 'claude-3-5-sonnet-20240620',
|
|
73
37
|
label: 'Model',
|
|
74
38
|
options: [
|
|
75
|
-
'claude-3-haiku-20240307',
|
|
76
|
-
'claude-3-sonnet-20240229',
|
|
77
|
-
'claude-3-opus-20240229',
|
|
78
39
|
'claude-3-5-sonnet-20240620'
|
|
79
40
|
]
|
|
80
41
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/anthropic/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/anthropic/index.ts"],"sourcesContent":["import type { GenerationConfig } from '../../../types.js'\n\nimport { generateRichText } from './generateRichText.js'\n\nexport const AnthropicConfig: GenerationConfig = {\n models: [\n {\n id: 'anthropic/claude-3.5-sonnet',\n name: 'Anthropic Claude 3.5 Sonnet',\n fields: ['text', 'textarea'],\n output: 'text',\n },\n {\n id: 'anthropic-claude-object',\n name: 'Anthropic Claude',\n fields: ['richText'],\n handler: (text: string, options) => {\n //TODO: change it to open ai text to speech api\n return generateRichText(text, options)\n },\n output: 'text',\n settings: {\n name: 'anthropic-claude-object-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'anthropic-claude-object'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'claude-3-5-sonnet-20240620',\n label: 'Model',\n options: ['claude-3-5-sonnet-20240620'],\n },\n {\n name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\n You are a highly skilled and professional blog writer,\n renowned for crafting engaging and well-organized articles.\n When given a title, you meticulously create blogs that are not only\n informative and accurate but also captivating and beautifully structured.`,\n label: 'System prompt',\n },\n {\n name: 'layout',\n type: 'textarea',\n defaultValue: `[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.\n[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.\n[list] - Create a list with 3-5 items. Each list item should contain:\n a. [heading] - A brief, descriptive heading (up to 5 words)\n b. [paragraph] - A short explanation or elaboration (1-2 sentences)\n[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.\n[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.\n[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: \"Quote text.\" - Author Name`,\n label: 'Layout',\n },\n ],\n label: 'Anthropic Claude Settings',\n },\n },\n ],\n provider: 'Anthropic',\n}\n"],"names":["generateRichText","AnthropicConfig","models","id","name","fields","output","handler","text","options","settings","type","admin","condition","data","defaultValue","label","provider"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,wBAAuB;AAExD,OAAO,MAAMC,kBAAoC;IAC/CC,QAAQ;QACN;YACEC,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,QAAQ;QACV;QACA;YACEH,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBE,SAAS,CAACC,MAAcC;gBACtB,+CAA+C;gBAC/C,OAAOT,iBAAiBQ,MAAMC;YAChC;YACAH,QAAQ;YACRI,UAAU;gBACRN,MAAM;gBACNO,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAT,QAAQ;oBACN;wBACED,MAAM;wBACNO,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPP,SAAS;4BAAC;yBAA6B;oBACzC;oBACA;wBACEL,MAAM;wBACNO,MAAM;wBACNI,cAAc,CAAC;;;;+EAIoD,CAAC;wBACpEC,OAAO;oBACT;oBACA;wBACEZ,MAAM;wBACNO,MAAM;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDC,UAAU;AACZ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/elevenLabs/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/elevenLabs/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AA2GzD,eAAO,MAAM,gBAAgB,EAAE,gBAmC9B,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SelectField } from '../../../fields/SelectField/SelectField.js';
|
|
1
2
|
import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js';
|
|
2
3
|
import { generateVoice } from './generateVoice.js';
|
|
3
4
|
import { getAllVoices } from './voices.js';
|
|
@@ -81,10 +82,19 @@ if (voiceOptions.length) {
|
|
|
81
82
|
fields.unshift({
|
|
82
83
|
name: 'voice_id',
|
|
83
84
|
type: 'select',
|
|
85
|
+
admin: {
|
|
86
|
+
components: {
|
|
87
|
+
Field: SelectField
|
|
88
|
+
},
|
|
89
|
+
custom: {
|
|
90
|
+
options: voiceOptions
|
|
91
|
+
}
|
|
92
|
+
},
|
|
84
93
|
defaultValue: voiceOptions[0]?.voice_id,
|
|
85
94
|
label: 'Voice',
|
|
86
95
|
options: fieldVoiceOptions,
|
|
87
|
-
required: true
|
|
96
|
+
required: true,
|
|
97
|
+
validate: ()=>true
|
|
88
98
|
});
|
|
89
99
|
}
|
|
90
100
|
export const ElevenLabsConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/elevenLabs/index.ts"],"sourcesContent":["import type { Field, File } from 'payload'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateVoice } from './generateVoice.js'\nimport { getAllVoices } from './voices.js'\n\nconst { voices = [] } = await getAllVoices()\n\nconst voiceOptions = voices.map((voice) => {\n return {\n label: voice.name,\n value: voice.voice_id,\n ...voice,\n }\n})\n\nconst fieldVoiceOptions = voiceOptions.map((option) => {\n return {\n label: option.name,\n value: option.voice_id,\n }\n})\n\nconst fields: Field[] = [\n {\n type: 'collapsible',\n admin: {\n initCollapsed: false,\n },\n fields: [\n {\n name: 'stability',\n type: 'number',\n defaultValue: 0.5,\n label: 'Stability',\n max: 1,\n min: 0,\n required: true,\n },\n {\n name: 'similarity_boost',\n type: 'number',\n defaultValue: 0.5,\n label: 'Similarity Boost',\n max: 1,\n min: 0,\n required: true,\n },\n {\n name: 'style',\n type: 'number',\n defaultValue: 0.5,\n label: 'Style',\n max: 1,\n min: 0,\n },\n {\n name: 'use_speaker_boost',\n type: 'checkbox',\n label: 'Use Speaker Boost',\n },\n ],\n label: 'Voice Settings',\n },\n {\n name: 'seed',\n type: 'number',\n label: 'Seed',\n },\n {\n type: 'row',\n fields: [\n {\n name: 'previous_text',\n type: 'textarea',\n label: 'Previous Text',\n },\n {\n name: 'next_text',\n type: 'textarea',\n label: 'Next Text',\n },\n ],\n },\n]\n\nif (voiceOptions.length) {\n fields.unshift({\n name: 'voice_id',\n type: 'select',\n defaultValue: voiceOptions[0]?.voice_id,\n label: 'Voice',\n options: fieldVoiceOptions,\n required: true,\n })\n}\n\nexport const ElevenLabsConfig: GenerationConfig = {\n models: [\n {\n id: 'elevenlabs/multilingual-v2',\n name: 'ElevenLabs Multilingual v2',\n fields: ['upload'],\n handler: async (text: string, options) => {\n const voiceData = await generateVoice(text, options)\n return {\n data: {\n alt: 'voice over',\n },\n file: {\n name: `voice_${generateFileNameByPrompt(text)}.mp3`,\n data: voiceData.buffer,\n mimetype: 'audio/mp3',\n size: voiceData.buffer.byteLength,\n } as File,\n }\n },\n output: 'audio',\n settings: {\n name: 'elevenlabs-multilingual-v2-settings',\n type: 'group',\n admin: {\n condition: (data) => {\n return data['model-id'] === 'elevenlabs/multilingual-v2'\n },\n },\n fields,\n label: 'ElevenLabs Multilingual v2 Settings',\n },\n },\n ],\n provider: 'ElevenLabs',\n}\n"],"names":["generateFileNameByPrompt","generateVoice","getAllVoices","voices","voiceOptions","map","voice","label","name","value","voice_id","fieldVoiceOptions","option","fields","type","admin","initCollapsed","defaultValue","max","min","required","length","unshift","options","ElevenLabsConfig","models","id","handler","text","voiceData","data","alt","file","buffer","mimetype","size","byteLength","output","settings","condition","provider"],"mappings":"AAIA,SAASA,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,YAAY,QAAQ,cAAa;AAE1C,MAAM,EAAEC,SAAS,EAAE,EAAE,GAAG,MAAMD;AAE9B,MAAME,eAAeD,OAAOE,GAAG,CAAC,CAACC;IAC/B,OAAO;QACLC,OAAOD,MAAME,IAAI;QACjBC,OAAOH,MAAMI,QAAQ;QACrB,GAAGJ,KAAK;IACV;AACF;AAEA,MAAMK,oBAAoBP,aAAaC,GAAG,CAAC,CAACO;IAC1C,OAAO;QACLL,OAAOK,OAAOJ,IAAI;QAClBC,OAAOG,OAAOF,QAAQ;IACxB;AACF;AAEA,MAAMG,SAAkB;IACtB;QACEC,MAAM;QACNC,OAAO;YACLC,eAAe;QACjB;QACAH,QAAQ;YACN;gBACEL,MAAM;gBACNM,MAAM;gBACNG,cAAc;gBACdV,OAAO;gBACPW,KAAK;gBACLC,KAAK;gBACLC,UAAU;YACZ;YACA;gBACEZ,MAAM;gBACNM,MAAM;gBACNG,cAAc;gBACdV,OAAO;gBACPW,KAAK;gBACLC,KAAK;gBACLC,UAAU;YACZ;YACA;gBACEZ,MAAM;gBACNM,MAAM;gBACNG,cAAc;gBACdV,OAAO;gBACPW,KAAK;gBACLC,KAAK;YACP;YACA;gBACEX,MAAM;gBACNM,MAAM;gBACNP,OAAO;YACT;SACD;QACDA,OAAO;IACT;IACA;QACEC,MAAM;QACNM,MAAM;QACNP,OAAO;IACT;IACA;QACEO,MAAM;QACND,QAAQ;YACN;gBACEL,MAAM;gBACNM,MAAM;gBACNP,OAAO;YACT;YACA;gBACEC,MAAM;gBACNM,MAAM;gBACNP,OAAO;YACT;SACD;IACH;CACD;AAED,IAAIH,aAAaiB,MAAM,EAAE;IACvBR,OAAOS,OAAO,CAAC;QACbd,MAAM;QACNM,MAAM;
|
|
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,OAA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;QACF;KACD;IACDqC,UAAU;AACZ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/models/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/ai/models/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as process from 'node:process';
|
|
2
1
|
import { AnthropicConfig } from './anthropic/index.js';
|
|
3
2
|
import { ElevenLabsConfig } from './elevenLabs/index.js';
|
|
4
3
|
import { OpenAIConfig } from './openai/index.js';
|
|
4
|
+
import * as process from 'node:process';
|
|
5
5
|
export const GenerationModels = [
|
|
6
|
-
...process.env.OPENAI_API_KEY ? OpenAIConfig.models : [],
|
|
7
6
|
...process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : [],
|
|
8
|
-
...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []
|
|
7
|
+
...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : [],
|
|
8
|
+
...OpenAIConfig.models
|
|
9
9
|
];
|
|
10
10
|
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/models/index.ts"],"sourcesContent":["import
|
|
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"}
|
|
@@ -4,8 +4,8 @@ import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.j
|
|
|
4
4
|
import { generateImage } from './generateImage.js';
|
|
5
5
|
import { generateRichText } from './generateRichText.js';
|
|
6
6
|
import { generateVoice } from './generateVoice.js';
|
|
7
|
-
import { defaultSystemPrompt } from '../../prompts.js';
|
|
8
7
|
//TODO: Simplify this file by moving the handlers to separate files and remove duplicate code
|
|
8
|
+
//TODO: every config must have default settings selected
|
|
9
9
|
export const OpenAIConfig = {
|
|
10
10
|
models: [
|
|
11
11
|
{
|
|
@@ -19,9 +19,9 @@ export const OpenAIConfig = {
|
|
|
19
19
|
const streamTextResult = await streamText({
|
|
20
20
|
model: openai(options.model),
|
|
21
21
|
prompt,
|
|
22
|
-
system: options.system
|
|
22
|
+
system: options.system
|
|
23
23
|
});
|
|
24
|
-
return streamTextResult.
|
|
24
|
+
return streamTextResult.toAIStreamResponse();
|
|
25
25
|
},
|
|
26
26
|
output: 'text',
|
|
27
27
|
settings: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/openai/index.ts"],"sourcesContent":["import type { SpeechCreateParams } from 'openai/resources/audio/speech'\nimport type { File } from 'payload'\n\nimport { openai } from '@ai-sdk/openai'\nimport { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\nimport { defaultSystemPrompt } from '../../prompts.js'\n\n//TODO: Simplify this file by moving the handlers to separate files and remove duplicate code\nexport const OpenAIConfig: GenerationConfig = {\n models: [\n {\n id: 'openai-gpt-text',\n name: 'OpenAI GPT Text',\n fields: ['text', 'textarea'],\n handler: async (\n prompt: string,\n options: { locale: string; model: string; system: string },\n ) => {\n const streamTextResult = await streamText({\n model: openai(options.model),\n prompt,\n system: options.system || defaultSystemPrompt,\n })\n\n return streamTextResult.toDataStreamResponse()\n },\n output: 'text',\n settings: {\n name: 'openai-gpt-text-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'openai-gpt-text'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gpt-4o-mini',\n label: 'Model',\n options: ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-3.5-turbo'],\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n {\n id: 'dall-e',\n name: 'OpenAI DALL-E',\n fields: ['upload'],\n handler: async (prompt: string, options) => {\n const imageData = await generateImage(prompt, options)\n return {\n data: {\n alt: imageData.alt,\n },\n file: {\n name: `image_${generateFileNameByPrompt(imageData.alt || prompt)}.jpeg`,\n data: imageData.buffer,\n mimetype: 'image/jpeg',\n size: imageData.buffer.byteLength,\n } as File,\n }\n },\n output: 'image',\n settings: {\n name: 'dalle-e-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'dall-e'\n },\n },\n fields: [\n {\n name: 'version',\n type: 'select',\n defaultValue: 'dall-e-3',\n label: 'Version',\n options: ['dall-e-3', 'dall-e-2'],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'size',\n type: 'select',\n defaultValue: '1024x1024',\n label: 'Size',\n options: ['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792'],\n },\n {\n name: 'style',\n type: 'select',\n defaultValue: 'natural',\n label: 'Style',\n options: ['vivid', 'natural'],\n },\n ],\n },\n {\n name: 'enable-prompt-optimization',\n type: 'checkbox',\n label: 'Optimize prompt',\n },\n ],\n label: 'OpenAI DALL-E Settings',\n },\n },\n {\n id: 'tts',\n name: 'OpenAI Text-to-Speech',\n fields: ['upload'],\n handler: async (text: string, options) => {\n //TODO: change it to open ai text to speech api\n const voiceData = await generateVoice(text, options)\n return {\n data: {\n alt: text,\n },\n file: {\n name: `voice_${generateFileNameByPrompt(text)}.mp3`,\n data: voiceData.buffer,\n mimetype: 'audio/mp3',\n size: voiceData.buffer.byteLength,\n } as File,\n }\n },\n output: 'audio',\n settings: {\n name: 'openai-tts-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'tts'\n },\n },\n fields: [\n {\n name: 'voice',\n type: 'select',\n defaultValue: 'alloy',\n label: 'Voice',\n options: ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'] as Array<\n SpeechCreateParams['voice']\n >,\n },\n {\n name: 'model',\n type: 'select',\n defaultValue: 'tts-1',\n label: 'Model',\n options: ['tts-1', 'tts-1-hd'] as Array<SpeechCreateParams['model']>,\n },\n {\n name: 'response_format',\n type: 'select',\n defaultValue: 'mp3',\n label: 'Response Format',\n options: ['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'] as Array<\n SpeechCreateParams['response_format']\n >,\n },\n {\n name: 'speed',\n type: 'number',\n defaultValue: 1,\n label: 'Speed',\n max: 4,\n min: 0.25,\n },\n ],\n label: 'OpenAI Text-to-Speech Settings',\n },\n },\n {\n id: 'openai-gpt-object',\n name: 'OpenAI GPT',\n fields: ['richText'],\n handler: (text: string, options) => {\n return generateRichText(text, options)\n },\n output: 'text',\n settings: {\n name: 'openai-gpt-object-settings',\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === 'openai-gpt-object'\n },\n },\n fields: [\n {\n name: 'model',\n type: 'select',\n defaultValue: 'gpt-4o-2024-08-06',\n label: 'Model',\n options: ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-4o-2024-08-06'],\n },\n {\n name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\nYou are a highly skilled and professional blog writer,\nrenowned for crafting engaging and well-organized articles.\nWhen given a title, you meticulously create blogs that are not only\ninformative and accurate but also captivating and beautifully structured.`,\n label: 'System prompt',\n },\n {\n /**TODO's:\n * - Layouts can be saved in as an array\n * - user can add their own layout to collections and use it later for generate specific rich text\n * - user can select previously added layout\n */\n name: 'layout',\n type: 'textarea',\n defaultValue: `[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.\n[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.\n[list] - Create a list with 3-5 items. Each list item should contain:\n a. [heading] - A brief, descriptive heading (up to 5 words)\n b. [paragraph] - A short explanation or elaboration (1-2 sentences)\n[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.\n[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.\n[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: \"Quote text.\" - Author Name`,\n label: 'Layout',\n },\n ],\n label: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["openai","streamText","generateFileNameByPrompt","generateImage","generateRichText","generateVoice","defaultSystemPrompt","OpenAIConfig","models","id","name","fields","handler","prompt","options","streamTextResult","model","system","toDataStreamResponse","output","settings","type","admin","condition","data","defaultValue","label","imageData","alt","file","buffer","mimetype","size","byteLength","text","voiceData","max","min","provider"],"mappings":"AAGA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,UAAU,QAAQ,KAAI;AAI/B,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,aAAa,QAAQ,q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AC;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"}
|
|
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,mB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A;YACEjB,IAAI;YACJC,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBC,SAAS,CAACsB,MAAcpB;gBACtB,OAAOT,iBAAiB6B,MAAMpB;YAChC;YACAK,QAAQ;YACRC,UAAU;gBACRV,MAAM;gBACNW,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK;oBAC9B;gBACF;gBACAb,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAoB;oBACxE;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc,CAAC;;;;yEAI8C,CAAC;wBAC9DC,OAAO;oBACT;oBACA;wBACE;;;;aAIC,GACDhB,MAAM;wBACNW,MAAM;wBACNI,cAAc,CAAC;;;;;;;2HAOgG,CAAC;wBAChHC,OAAO;oBACT;iBACD;gBACDA,OAAO;YACT;QACF;KACD;IACDY,UAAU;AACZ,EAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const beerCssClasses = "\nabsolute left, right, top, bottom, front, back, small, medium, large\n\n<article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding\n\nbadge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round\n\n<details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active\n\nfield small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea\n\nfixed left, right, top, bottom, front, back, small, medium, large\n\n<h1>...<h6> small, medium, large\n\n<li> max, divider, small-divider, medium-divider, large-divider\n\nrow, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical\n\nsnackbar top, bottom, active\n\n<summary>\n\n<table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed\n\ntabs left-align, right-align, center-align, horizontal, vertical, min, max\n\ntooltip left, right, top, bottom, max\n";
|
|
2
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/ai/models/style.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,owCA4B1B,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const beerCssClasses = `
|
|
2
|
+
absolute left, right, top, bottom, front, back, small, medium, large
|
|
3
|
+
|
|
4
|
+
<article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding
|
|
5
|
+
|
|
6
|
+
badge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round
|
|
7
|
+
|
|
8
|
+
<details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active
|
|
9
|
+
|
|
10
|
+
field small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea
|
|
11
|
+
|
|
12
|
+
fixed left, right, top, bottom, front, back, small, medium, large
|
|
13
|
+
|
|
14
|
+
<h1>...<h6> small, medium, large
|
|
15
|
+
|
|
16
|
+
<li> max, divider, small-divider, medium-divider, large-divider
|
|
17
|
+
|
|
18
|
+
row, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical
|
|
19
|
+
|
|
20
|
+
snackbar top, bottom, active
|
|
21
|
+
|
|
22
|
+
<summary>
|
|
23
|
+
|
|
24
|
+
<table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed
|
|
25
|
+
|
|
26
|
+
tabs left-align, right-align, center-align, horizontal, vertical, min, max
|
|
27
|
+
|
|
28
|
+
tooltip left, right, top, bottom, max
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ai/models/style.ts"],"sourcesContent":["export const beerCssClasses = `\nabsolute left, right, top, bottom, front, back, small, medium, large\n\n<article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding\n\nbadge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round\n\n<details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active\n\nfield small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea\n\nfixed left, right, top, bottom, front, back, small, medium, large\n\n<h1>...<h6> small, medium, large\n\n<li> max, divider, small-divider, medium-divider, large-divider\n\nrow, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical\n\nsnackbar top, bottom, active\n\n<summary>\n\n<table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed\n\ntabs left-align, right-align, center-align, horizontal, vertical, min, max\n\ntooltip left, right, top, bottom, max\n`\n"],"names":["beerCssClasses"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/B,CAAC,CAAA"}
|
package/dist/ai/prompts.d.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import type { ActionMenuItems } from '../types.js';
|
|
2
2
|
type ActionPromptOptions = {
|
|
3
|
-
layout?: string;
|
|
4
|
-
locale?: string;
|
|
5
3
|
prompt?: string;
|
|
6
4
|
systemPrompt?: string;
|
|
5
|
+
locale?: string;
|
|
6
|
+
layout?: string;
|
|
7
7
|
};
|
|
8
8
|
type ActionPrompt = {
|
|
9
|
-
layout?: (options?: ActionPromptOptions) => string;
|
|
10
9
|
name: ActionMenuItems;
|
|
11
10
|
system: (options: ActionPromptOptions) => string;
|
|
11
|
+
layout?: (options?: ActionPromptOptions) => string;
|
|
12
12
|
};
|
|
13
|
-
export declare const defaultSystemPrompt = "\nIMPORTANT: JUST PRODUCE THE OUTPUT WITHOUT QUOTES AND DO NOT ENGAGE!\n";
|
|
14
13
|
export declare const defaultPrompts: ActionPrompt[];
|
|
15
|
-
export declare const seedPrompts: ({ fieldLabel,
|
|
14
|
+
export declare const seedPrompts: ({ fieldLabel, fieldType, path, fieldSchemaPaths }: {
|
|
16
15
|
fieldLabel: any;
|
|
17
|
-
fieldSchemaPaths: any;
|
|
18
16
|
fieldType: any;
|
|
19
17
|
path: any;
|
|
18
|
+
fieldSchemaPaths: any;
|
|
20
19
|
}) => {
|
|
21
|
-
prompt: string;
|
|
22
20
|
system: string;
|
|
21
|
+
prompt: string;
|
|
23
22
|
};
|
|
24
23
|
export {};
|
|
25
24
|
//# sourceMappingURL=prompts.d.ts.map
|
package/dist/ai/prompts.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/ai/prompts.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export const defaultSystemPrompt = `
|
|
2
|
-
IMPORTANT: JUST PRODUCE THE OUTPUT WITHOUT QUOTES AND DO NOT ENGAGE!
|
|
3
|
-
`;
|
|
4
1
|
export const defaultPrompts = [
|
|
5
2
|
{
|
|
6
3
|
name: 'Rephrase',
|
|
@@ -57,10 +54,6 @@ export const defaultPrompts = [
|
|
|
57
54
|
},
|
|
58
55
|
{
|
|
59
56
|
name: 'Summarize',
|
|
60
|
-
layout: ()=>`
|
|
61
|
-
[heading] - Summary
|
|
62
|
-
[paragraph] - Your summary goes here...
|
|
63
|
-
`,
|
|
64
57
|
system: ()=>`You are an expert at summarizing information. Your task is to create a concise summary of the given text that captures its key points and essential details while preserving the original meaning.
|
|
65
58
|
|
|
66
59
|
INSTRUCTIONS:
|
|
@@ -70,7 +63,11 @@ INSTRUCTIONS:
|
|
|
70
63
|
4. Preserve the original tone and intent of the text.
|
|
71
64
|
5. Ensure your summary is approximately 25-30% of the original text length.
|
|
72
65
|
6. Use clear and precise language, avoiding unnecessary jargon or complexity.
|
|
73
|
-
|
|
66
|
+
`,
|
|
67
|
+
layout: ()=>`
|
|
68
|
+
[heading] - Summary
|
|
69
|
+
[paragraph] - Your summary goes here...
|
|
70
|
+
`
|
|
74
71
|
},
|
|
75
72
|
{
|
|
76
73
|
name: 'Tone',
|
|
@@ -85,7 +82,7 @@ INSTRUCTIONS:
|
|
|
85
82
|
},
|
|
86
83
|
{
|
|
87
84
|
name: 'Translate',
|
|
88
|
-
system: ({
|
|
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.
|
|
89
86
|
|
|
90
87
|
-------------
|
|
91
88
|
INSTRUCTIONS:
|
|
@@ -97,16 +94,8 @@ INSTRUCTIONS:
|
|
|
97
94
|
-------------`
|
|
98
95
|
}
|
|
99
96
|
];
|
|
100
|
-
export const seedPrompts = ({ fieldLabel,
|
|
97
|
+
export const seedPrompts = ({ fieldLabel, fieldType, path, fieldSchemaPaths })=>{
|
|
101
98
|
return {
|
|
102
|
-
prompt: `field-type: ${fieldType}
|
|
103
|
-
field-name: ${fieldLabel}
|
|
104
|
-
schema-path: ${path}
|
|
105
|
-
|
|
106
|
-
Give me a prompt that relate to the given field type and schema path.
|
|
107
|
-
|
|
108
|
-
Generated prompt:
|
|
109
|
-
`,
|
|
110
99
|
system: `# AI Assistant for CMS Prompt Generation
|
|
111
100
|
|
|
112
101
|
Your role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.
|
|
@@ -189,21 +178,27 @@ For upload:
|
|
|
189
178
|
field-type: upload
|
|
190
179
|
field-name: Featured Image
|
|
191
180
|
schema-path: posts.image
|
|
192
|
-
Generated prompt: Imagine {{ title }}
|
|
181
|
+
Generated prompt: Imagine a high-quality featured image for '{{ title }}
|
|
193
182
|
|
|
194
183
|
For upload:
|
|
195
184
|
field-type: upload
|
|
196
185
|
field-name: Voice
|
|
197
186
|
schema-path: posts.upload
|
|
198
|
-
Generated prompt: {{ title }} {{ toLexicalHTML [provide
|
|
187
|
+
Generated prompt: {{ title }} {{ toLexicalHTML [provide field-path for richText] }}
|
|
199
188
|
|
|
200
189
|
|
|
201
190
|
Remember to adapt the prompts based on the specific schema-path provided, considering the context and purpose of the field within the CMS structure. The prompts should directly instruct the AI model on what content to generate or describe, without assuming a user perspective.
|
|
202
191
|
|
|
203
192
|
Schema Map Context:
|
|
204
193
|
${JSON.stringify(fieldSchemaPaths)}
|
|
194
|
+
`,
|
|
195
|
+
prompt: `field-type: ${fieldType}
|
|
196
|
+
field-name: ${fieldLabel}
|
|
197
|
+
schema-path: ${path}
|
|
205
198
|
|
|
206
|
-
|
|
199
|
+
Give me a prompt that relate to the given field type and schema path.
|
|
200
|
+
|
|
201
|
+
Generated prompt:
|
|
207
202
|
`
|
|
208
203
|
};
|
|
209
204
|
};
|
package/dist/ai/prompts.js.map
CHANGED
|
@@ -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 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;;;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C;AACF,EAAC"}
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateSeedPrompt.d.ts","sourceRoot":"","sources":["../../../src/ai/utils/generateSeedPrompt.ts"],"names":[],"mappings":"
|
|
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,21 +1,12 @@
|
|
|
1
|
-
import { anthropic } from '@ai-sdk/anthropic';
|
|
2
|
-
import { openai } from '@ai-sdk/openai';
|
|
3
1
|
import { generateText } from 'ai';
|
|
4
|
-
import {
|
|
2
|
+
import { openai } from '@ai-sdk/openai';
|
|
3
|
+
import { PLUGIN_DEFAULT_MODEL_NAME } from '../../defaults.js';
|
|
5
4
|
export const generateSeedPrompt = async (data)=>{
|
|
6
5
|
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
|
-
}
|
|
15
6
|
const { text } = await generateText({
|
|
16
|
-
model,
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
model: openai(PLUGIN_DEFAULT_MODEL_NAME),
|
|
8
|
+
system,
|
|
9
|
+
prompt
|
|
19
10
|
});
|
|
20
11
|
return text;
|
|
21
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/utils/generateSeedPrompt.ts"],"sourcesContent":["import {
|
|
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"}
|