@ai-stack/payloadcms 3.2.5-beta → 3.2.8-beta
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 +13 -2
- package/dist/ai/models/anthropic/generateRichText.d.ts.map +1 -1
- package/dist/ai/models/elevenLabs/generateVoice.d.ts +1 -2
- package/dist/ai/models/elevenLabs/generateVoice.d.ts.map +1 -1
- package/dist/ai/models/elevenLabs/generateVoice.js.map +1 -1
- package/dist/ai/models/index.d.ts +1 -1
- package/dist/ai/models/index.d.ts.map +1 -1
- package/dist/ai/models/index.js +1 -1
- package/dist/ai/models/index.js.map +1 -1
- package/dist/ai/models/openai/generateImage.d.ts.map +1 -1
- package/dist/ai/models/openai/generateRichText.d.ts.map +1 -1
- package/dist/ai/models/openai/generateRichText.js +5 -9
- package/dist/ai/models/openai/generateRichText.js.map +1 -1
- package/dist/ai/models/openai/generateVoice.d.ts +1 -1
- package/dist/ai/models/openai/generateVoice.d.ts.map +1 -1
- package/dist/ai/models/openai/index.d.ts.map +1 -1
- package/dist/ai/models/openai/index.js +1 -1
- package/dist/ai/models/openai/index.js.map +1 -1
- package/dist/ai/models/openai/openai.d.ts +2 -0
- package/dist/ai/models/openai/openai.d.ts.map +1 -0
- package/dist/ai/models/openai/openai.js +9 -0
- package/dist/ai/models/openai/openai.js.map +1 -0
- package/dist/ai/prompts.d.ts.map +1 -1
- package/dist/ai/schemas/lexicalJsonSchema.d.ts +4 -0
- package/dist/ai/schemas/lexicalJsonSchema.d.ts.map +1 -1
- package/dist/ai/schemas/lexicalJsonSchema.js +8 -0
- package/dist/ai/schemas/lexicalJsonSchema.js.map +1 -1
- package/dist/ai/utils/systemGenerate.d.ts +1 -1
- package/dist/ai/utils/systemGenerate.d.ts.map +1 -1
- package/dist/ai/utils/systemGenerate.js +6 -2
- package/dist/ai/utils/systemGenerate.js.map +1 -1
- package/dist/collections/Instructions.d.ts +2 -1
- package/dist/collections/Instructions.d.ts.map +1 -1
- package/dist/collections/Instructions.js +24 -21
- package/dist/collections/Instructions.js.map +1 -1
- package/dist/endpoints/index.d.ts +2 -2
- package/dist/endpoints/index.d.ts.map +1 -1
- package/dist/endpoints/index.js +97 -96
- package/dist/endpoints/index.js.map +1 -1
- package/dist/exports/types.d.ts +1 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/fields/ComposeField/ComposeField.d.ts +1 -2
- package/dist/fields/ComposeField/ComposeField.d.ts.map +1 -1
- package/dist/fields/ComposeField/ComposeField.js.map +1 -1
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts.map +1 -1
- package/dist/fields/LexicalEditor/feature.client.d.ts.map +1 -1
- package/dist/fields/LexicalEditor/feature.client.js.map +1 -1
- package/dist/fields/LexicalEditor/feature.server.d.ts.map +1 -1
- package/dist/fields/LexicalEditor/feature.server.js +2 -3
- package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.js +5 -1
- package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
- package/dist/fields/SelectField/SelectField.d.ts.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +5 -3
- package/dist/init.js.map +1 -1
- package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts.map +1 -1
- package/dist/libraries/handlebars/helpers.d.ts.map +1 -1
- package/dist/libraries/handlebars/replacePlaceholders.d.ts +1 -1
- package/dist/libraries/handlebars/replacePlaceholders.d.ts.map +1 -1
- package/dist/libraries/handlebars/replacePlaceholders.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +10 -5
- package/dist/plugin.js.map +1 -1
- package/dist/providers/FieldProvider/FieldProvider.d.ts.map +1 -1
- package/dist/providers/InstructionsProvider/useInstructions.d.ts.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/Compose/Compose.d.ts +7 -3
- package/dist/ui/Compose/Compose.d.ts.map +1 -1
- package/dist/ui/Compose/Compose.js +37 -15
- package/dist/ui/Compose/Compose.js.map +1 -1
- package/dist/ui/Compose/UndoRedoActions.d.ts.map +1 -1
- package/dist/ui/Compose/UndoRedoActions.js +9 -9
- package/dist/ui/Compose/UndoRedoActions.js.map +1 -1
- package/dist/ui/Compose/compose.module.css +2 -0
- package/dist/ui/Compose/hooks/menu/Item.d.ts.map +1 -1
- package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts.map +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.d.ts.map +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.js +2 -4
- package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/useGenerate.d.ts.map +1 -1
- package/dist/ui/Compose/hooks/useGenerate.js +22 -9
- package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
- package/dist/ui/Icons/Icons.d.ts.map +1 -1
- package/dist/ui/Icons/LottieAnimation.d.ts.map +1 -1
- package/dist/utilities/editorSchemaValidator.d.ts.map +1 -1
- package/dist/utilities/editorSchemaValidator.js +2 -1
- package/dist/utilities/editorSchemaValidator.js.map +1 -1
- package/dist/utilities/getFieldBySchemaPath.d.ts.map +1 -1
- package/dist/utilities/getFieldInfo.d.ts.map +1 -1
- package/dist/utilities/getGenerationModels.d.ts +3 -0
- package/dist/utilities/getGenerationModels.d.ts.map +1 -0
- package/dist/utilities/getGenerationModels.js +10 -0
- package/dist/utilities/getGenerationModels.js.map +1 -0
- package/dist/utilities/isPluginActivated.d.ts +2 -1
- package/dist/utilities/isPluginActivated.d.ts.map +1 -1
- package/dist/utilities/isPluginActivated.js +3 -2
- package/dist/utilities/isPluginActivated.js.map +1 -1
- package/dist/utilities/setSafeLexicalState.d.ts.map +1 -1
- package/dist/utilities/setSafeLexicalState.js +1 -1
- package/dist/utilities/setSafeLexicalState.js.map +1 -1
- package/dist/utilities/updateFieldsConfig.d.ts.map +1 -1
- package/package.json +8 -7
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 v3.
|
|
11
|
+
> **⚠️ Important:** This plugin is in active development. We're doing our best to improve its features and functionality. Please be prepared for regular updates; at the moment, the plugin has only been tested with Payload version v3.31.0.
|
|
12
12
|
>
|
|
13
|
-
> To give it a try, we recommend using [Payload's website template](https://github.com/payloadcms/payload/tree/v3.
|
|
13
|
+
> To give it a try, we recommend using [Payload's website template](https://github.com/payloadcms/payload/tree/v3.31.0/templates/website).
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
@@ -120,6 +120,17 @@ OPENAI_API_KEY=your-openai-api-key
|
|
|
120
120
|
ANTHROPIC_API_KEY=your-anthropic-api-key
|
|
121
121
|
ELEVENLABS_API_KEY=your-elevenlabs-api-key
|
|
122
122
|
```
|
|
123
|
+
|
|
124
|
+
> **⚠️ Important:** Once you've configured or installed this plugin, a server restart is required to activate the changes.
|
|
125
|
+
|
|
126
|
+
### OpenAI Endpoint
|
|
127
|
+
|
|
128
|
+
If you want to use a custom endpoint for the OpenAI provider, set your base URL like this:
|
|
129
|
+
```
|
|
130
|
+
OPENAI_BASE_URL=https://api.openai.com/v1
|
|
131
|
+
```
|
|
132
|
+
If not specified, the [default](src/ai/models/openai/openai.ts) OpenAI endpoint will be used.
|
|
133
|
+
|
|
123
134
|
For detailed guidance on personalizing and configuring the plugin to match your needs, check out the **[Complete Guide](guide.md)**. It walks you through every step, from setting up fields to generating amazing content!
|
|
124
135
|
|
|
125
136
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,GAAU,MAAM,MAAM,EAAE,SAAS,GAAG,sBAiChE,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type * as ElevenLabs from 'elevenlabs/api';
|
|
2
1
|
type ElevenLabsTextToSpeechOptions = {
|
|
3
2
|
voice_id: string;
|
|
4
|
-
}
|
|
3
|
+
};
|
|
5
4
|
export declare const generateVoice: (text: string, options: ElevenLabsTextToSpeechOptions) => Promise<{
|
|
6
5
|
alignment: string[];
|
|
7
6
|
buffer: Buffer<ArrayBuffer>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateVoice.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/elevenLabs/generateVoice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateVoice.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/elevenLabs/generateVoice.ts"],"names":[],"mappings":"AAEA,KAAK,6BAA6B,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,aAAa,GAAU,MAAM,MAAM,EAAE,SAAS,6BAA6B;;;EAoBvF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/elevenLabs/generateVoice.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/elevenLabs/generateVoice.ts"],"sourcesContent":["import { ElevenLabsClient } from 'elevenlabs'\n\ntype ElevenLabsTextToSpeechOptions = {\n voice_id: string\n}\n\nexport const generateVoice = async (text: string, options: ElevenLabsTextToSpeechOptions) => {\n const elevenLabs = new ElevenLabsClient({\n apiKey: process.env.ELEVENLABS_API_KEY,\n })\n const response = (await elevenLabs.textToSpeech.convertWithTimstamps(options.voice_id, {\n ...options,\n text,\n })) as {\n alignment: string[]\n audio_base64: string\n }\n if (response?.audio_base64) {\n const audioBuffer = Buffer.from(response.audio_base64, 'base64')\n // const transcript = convertToTranscript(mp3Audio.alignment)\n\n return {\n alignment: response.alignment,\n buffer: audioBuffer,\n }\n }\n}\n"],"names":["ElevenLabsClient","generateVoice","text","options","elevenLabs","apiKey","process","env","ELEVENLABS_API_KEY","response","textToSpeech","convertWithTimstamps","voice_id","audio_base64","audioBuffer","Buffer","from","alignment","buffer"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAY;AAM7C,OAAO,MAAMC,gBAAgB,OAAOC,MAAcC;IAChD,MAAMC,aAAa,IAAIJ,iBAAiB;QACtCK,QAAQC,QAAQC,GAAG,CAACC,kBAAkB;IACxC;IACA,MAAMC,WAAY,MAAML,WAAWM,YAAY,CAACC,oBAAoB,CAACR,QAAQS,QAAQ,EAAE;QACrF,GAAGT,OAAO;QACVD;IACF;IAIA,IAAIO,UAAUI,cAAc;QAC1B,MAAMC,cAAcC,OAAOC,IAAI,CAACP,SAASI,YAAY,EAAE;QACvD,6DAA6D;QAE7D,OAAO;YACLI,WAAWR,SAASQ,SAAS;YAC7BC,QAAQJ;QACV;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/models/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrD,eAAO,MAAM,
|
|
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,uBAAuB,EAAE,eAAe,EAIpD,CAAA"}
|
package/dist/ai/models/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as process from 'node:process';
|
|
|
2
2
|
import { AnthropicConfig } from './anthropic/index.js';
|
|
3
3
|
import { ElevenLabsConfig } from './elevenLabs/index.js';
|
|
4
4
|
import { OpenAIConfig } from './openai/index.js';
|
|
5
|
-
export const
|
|
5
|
+
export const defaultGenerationModels = [
|
|
6
6
|
...process.env.OPENAI_API_KEY ? OpenAIConfig.models : [],
|
|
7
7
|
...process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : [],
|
|
8
8
|
...process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/models/index.ts"],"sourcesContent":["import * as process from 'node:process'\n\nimport type { GenerationModel } from '../../types.js'\n\nimport { AnthropicConfig } from './anthropic/index.js'\nimport { ElevenLabsConfig } from './elevenLabs/index.js'\nimport { OpenAIConfig } from './openai/index.js'\n\nexport const
|
|
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 defaultGenerationModels: GenerationModel[] = [\n ...(process.env.OPENAI_API_KEY ? OpenAIConfig.models : []),\n ...(process.env.ANTHROPIC_API_KEY ? AnthropicConfig.models : []),\n ...(process.env.ELEVENLABS_API_KEY ? ElevenLabsConfig.models : []),\n]\n"],"names":["process","AnthropicConfig","ElevenLabsConfig","OpenAIConfig","defaultGenerationModels","env","OPENAI_API_KEY","models","ANTHROPIC_API_KEY","ELEVENLABS_API_KEY"],"mappings":"AAAA,YAAYA,aAAa,eAAc;AAIvC,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,MAAMC,0BAA6C;OACpDJ,QAAQK,GAAG,CAACC,cAAc,GAAGH,aAAaI,MAAM,GAAG,EAAE;OACrDP,QAAQK,GAAG,CAACG,iBAAiB,GAAGP,gBAAgBM,MAAM,GAAG,EAAE;OAC3DP,QAAQK,GAAG,CAACI,kBAAkB,GAAGP,iBAAiBK,MAAM,GAAG,EAAE;CAClE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateImage.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateImage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAIlE,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"generateImage.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateImage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAIlE,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EACd,4BAIG;IACD,IAAI,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAClC,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAA;CAClC;;;EAiBP,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateRichText.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateRichText.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateRichText.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,GAAU,MAAM,MAAM,EAAE,UAAS,GAAQ,sBAoCrE,CAAA"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { openai } from '@ai-sdk/openai';
|
|
2
1
|
import { jsonSchema, streamObject } from 'ai';
|
|
2
|
+
import { openai } from './openai.js';
|
|
3
3
|
export const generateRichText = async (text, options = {})=>{
|
|
4
|
-
console.log('Running handler with prompts:', options.editorSchema)
|
|
4
|
+
// console.log('Running handler with prompts:', options.editorSchema)
|
|
5
5
|
const streamResult = await streamObject({
|
|
6
6
|
maxTokens: options.maxTokens || 5000,
|
|
7
7
|
model: openai(options.model, {
|
|
8
8
|
structuredOutputs: true
|
|
9
9
|
}),
|
|
10
|
-
onFinish: (result)=>{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
rawResponse: result.rawResponse,
|
|
14
|
-
result
|
|
15
|
-
});
|
|
16
|
-
},
|
|
10
|
+
// onFinish: (result) => {
|
|
11
|
+
// console.log('Finished generating rich text:', { options, rawResponse: result.rawResponse, result })
|
|
12
|
+
// },
|
|
17
13
|
prompt: text,
|
|
18
14
|
schema: jsonSchema(options.editorSchema),
|
|
19
15
|
system: `${options.system}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import { jsonSchema, streamObject } from 'ai'\n\nimport { openai } from './openai.js'\n\nexport const generateRichText = async (text: string, options: any = {}) => {\n // console.log('Running handler with prompts:', options.editorSchema)\n const streamResult = await streamObject({\n maxTokens: options.maxTokens || 5000,\n model: openai(options.model, {\n structuredOutputs: true,\n }),\n // onFinish: (result) => {\n // console.log('Finished generating rich text:', { options, rawResponse: result.rawResponse, result })\n // },\n prompt: text,\n schema: jsonSchema(options.editorSchema),\n system: `${options.system}\n\nRULES:\n- Generate original and unique content based on the given topic.\n- Strictly adhere to the specified layout and formatting instructions.\n- Utilize the provided rich text editor tools for appropriate formatting.\n- Ensure the output follows the structure of the sample output object.\n- Produce valid JSON with no undefined or null values.\n\nLAYOUT INSTRUCTIONS:\n${options.layout}\n\nRICH TEXT EDITOR TOOLS:\n- Use appropriate formatting tools such as bold, italic, or underline for emphasis where needed.\n- Apply correct heading levels (h1, h2, h3) for hierarchical structure.\n- Utilize bullet points or numbered lists as required by the layout.\n\nADDITIONAL GUIDELINES:\n- Ensure coherence and logical flow between all sections.\n- Maintain a consistent tone and style throughout the content.\n- Use clear and concise language appropriate for the target audience.\n`,\n })\n return streamResult.toTextStreamResponse()\n}\n"],"names":["jsonSchema","streamObject","openai","generateRichText","text","options","streamResult","maxTokens","model","structuredOutputs","prompt","schema","editorSchema","system","layout","toTextStreamResponse"],"mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,QAAQ,KAAI;AAE7C,SAASC,MAAM,QAAQ,cAAa;AAEpC,OAAO,MAAMC,mBAAmB,OAAOC,MAAcC,UAAe,CAAC,CAAC;IACpE,qEAAqE;IACrE,MAAMC,eAAe,MAAML,aAAa;QACtCM,WAAWF,QAAQE,SAAS,IAAI;QAChCC,OAAON,OAAOG,QAAQG,KAAK,EAAE;YAC3BC,mBAAmB;QACrB;QACA,0BAA0B;QAC1B,wGAAwG;QACxG,KAAK;QACLC,QAAQN;QACRO,QAAQX,WAAWK,QAAQO,YAAY;QACvCC,QAAQ,GAAGR,QAAQQ,MAAM,CAAC;;;;;;;;;;AAU9B,EAAER,QAAQS,MAAM,CAAC;;;;;;;;;;;AAWjB,CAAC;IACC;IACA,OAAOR,aAAaS,oBAAoB;AAC1C,EAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SpeechCreateParams } from 'openai/resources/audio/speech';
|
|
2
2
|
type OpenAITextToSpeechOptions = Exclude<SpeechCreateParams, 'input'>;
|
|
3
3
|
export declare const generateVoice: (text: string, options: OpenAITextToSpeechOptions) => Promise<{
|
|
4
|
-
buffer: Buffer<
|
|
4
|
+
buffer: Buffer<ArrayBuffer>;
|
|
5
5
|
}>;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=generateVoice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateVoice.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateVoice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAIvE,KAAK,yBAAyB,GAAG,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAA;AAErE,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"generateVoice.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/generateVoice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAIvE,KAAK,yBAAyB,GAAG,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAA;AAErE,eAAO,MAAM,aAAa,GAAU,MAAM,MAAM,EAAE,SAAS,yBAAyB;;EAiBnF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAYzD,eAAO,MAAM,YAAY,EAAE,gBAsM1B,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { openai } from '@ai-sdk/openai';
|
|
2
1
|
import { streamText } from 'ai';
|
|
3
2
|
import { defaultSystemPrompt } from '../../prompts.js';
|
|
4
3
|
import { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js';
|
|
5
4
|
import { generateImage } from './generateImage.js';
|
|
6
5
|
import { generateRichText } from './generateRichText.js';
|
|
7
6
|
import { generateVoice } from './generateVoice.js';
|
|
7
|
+
import { openai } from './openai.js';
|
|
8
8
|
const MODEL_KEY = 'Oai';
|
|
9
9
|
//TODO: Simplify this file by moving the handlers to separate files and remove duplicate code
|
|
10
10
|
export const OpenAIConfig = {
|
|
@@ -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 { defaultSystemPrompt } from '../../prompts.js'\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\n\nconst MODEL_KEY = 'Oai'\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: `${MODEL_KEY}-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: `${MODEL_KEY}-text-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-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: `${MODEL_KEY}-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: `${MODEL_KEY}-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: `${MODEL_KEY}-object-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-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 label: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["openai","streamText","defaultSystemPrompt","generateFileNameByPrompt","generateImage","generateRichText","generateVoice","MODEL_KEY","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,mBAAmB,QAAQ,mBAAkB;AACtD,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,aAAa,QAAQ,qBAAoB;AAElD,MAAMC,YAAY;AAElB,6FAA6F;AAC7F,OAAO,MAAMC,eAAiC;IAC5CC,QAAQ;QACN;YACEC,IAAI,GAAGH,UAAU,KAAK,CAAC;YACvBI,MAAM;YACNC,QAAQ;gBAAC;gBAAQ;aAAW;YAC5BC,SAAS,OACPC,QACAC;gBAEA,MAAMC,mBAAmB,MAAMf,WAAW;oBACxCgB,OAAOjB,OAAOe,QAAQE,KAAK;oBAC3BH;oBACAI,QAAQH,QAAQG,MAAM,IAAIhB;gBAC5B;g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AAU,OAAO,CAAC;YACzBI,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBC,SAAS,CAACsB,MAAcpB;gBACtB,OAAOV,iBAAiB8B,MAAMpB;YAChC;YACAK,QAAQ;YACRC,UAAU;gBACRV,MAAM,GAAGJ,UAAU,gBAAgB,CAAC;gBACpCe,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK,GAAGlB,UAAU,OAAO,CAAC;oBACnD;gBACF;gBACAK,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAoB;oBACxE;iBACD;gBACDY,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 { streamText } from 'ai'\n\nimport type { GenerationConfig } from '../../../types.js'\n\nimport { defaultSystemPrompt } from '../../prompts.js'\nimport { generateFileNameByPrompt } from '../../utils/generateFileNameByPrompt.js'\nimport { generateImage } from './generateImage.js'\nimport { generateRichText } from './generateRichText.js'\nimport { generateVoice } from './generateVoice.js'\nimport { openai } from './openai.js'\n\nconst MODEL_KEY = 'Oai'\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: `${MODEL_KEY}-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: `${MODEL_KEY}-text-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-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: `${MODEL_KEY}-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: `${MODEL_KEY}-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: `${MODEL_KEY}-object-settings`,\n type: 'group',\n admin: {\n condition(data) {\n return data['model-id'] === `${MODEL_KEY}-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 label: 'OpenAI GPT Settings',\n },\n },\n ],\n provider: 'OpenAI',\n}\n"],"names":["streamText","defaultSystemPrompt","generateFileNameByPrompt","generateImage","generateRichText","generateVoice","openai","MODEL_KEY","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,UAAU,QAAQ,KAAI;AAI/B,SAASC,mBAAmB,QAAQ,mBAAkB;AACtD,SAASC,wBAAwB,QAAQ,0CAAy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BACPZ,SAAS;4BAAC;4BAAS;4BAAQ;4BAAS;4BAAQ;4BAAQ;yBAAU;oBAGhE;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAS;yBAAW;oBAChC;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAO;4BAAQ;4BAAO;4BAAQ;4BAAO;yBAAM;oBAGvD;oBACA;wBACEJ,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPU,KAAK;wBACLC,KAAK;oBACP;iBACD;gBACDX,OAAO;YACT;QACF;QACA;YACEjB,IAAI,GAAGH,UAAU,OAAO,CAAC;YACzBI,MAAM;YACNC,QAAQ;gBAAC;aAAW;YACpBC,SAAS,CAACsB,MAAcpB;gBACtB,OAAOX,iBAAiB+B,MAAMpB;YAChC;YACAK,QAAQ;YACRC,UAAU;gBACRV,MAAM,GAAGJ,UAAU,gBAAgB,CAAC;gBACpCe,MAAM;gBACNC,OAAO;oBACLC,WAAUC,IAAI;wBACZ,OAAOA,IAAI,CAAC,WAAW,KAAK,GAAGlB,UAAU,OAAO,CAAC;oBACnD;gBACF;gBACAK,QAAQ;oBACN;wBACED,MAAM;wBACNW,MAAM;wBACNI,cAAc;wBACdC,OAAO;wBACPZ,SAAS;4BAAC;4BAAU;4BAAe;4BAAe;yBAAoB;oBACxE;iBACD;gBACDY,OAAO;YACT;QACF;KACD;IACDY,UAAU;AACZ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/ai/models/openai/openai.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,yCAIjB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
2
|
+
// same to default openai with optional baseurl.
|
|
3
|
+
export const openai = createOpenAI({
|
|
4
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
5
|
+
baseURL: process.env.OPENAI_BASE_URL ?? 'https://api.openai.com/v1',
|
|
6
|
+
compatibility: 'strict'
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ai/models/openai/openai.ts"],"sourcesContent":["import { createOpenAI } from '@ai-sdk/openai'\n\n// same to default openai with optional baseurl.\nexport const openai = createOpenAI({\n apiKey: process.env.OPENAI_API_KEY,\n baseURL: process.env.OPENAI_BASE_URL ?? 'https://api.openai.com/v1',\n compatibility: 'strict',\n})\n"],"names":["createOpenAI","openai","apiKey","process","env","OPENAI_API_KEY","baseURL","OPENAI_BASE_URL","compatibility"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAgB;AAE7C,gDAAgD;AAChD,OAAO,MAAMC,SAASD,aAAa;IACjCE,QAAQC,QAAQC,GAAG,CAACC,cAAc;IAClCC,SAASH,QAAQC,GAAG,CAACG,eAAe,IAAI;IACxCC,eAAe;AACjB,GAAE"}
|
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,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;IAClD,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAA;CACjD,CAAA;AAGD,eAAO,MAAM,mBAAmB,uLAIlB,CAAA;AAEd,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ai/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,mBAAmB,GAAG;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;IAClD,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAA;CACjD,CAAA;AAGD,eAAO,MAAM,mBAAmB,uLAIlB,CAAA;AAEd,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW,GAAI;;;;;CAAiD;;;CA6G5E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicalJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"lexicalJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmW1B,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,mBAAgB,QAajD,CAAA"}
|
|
@@ -392,6 +392,13 @@ export const documentSchema = {
|
|
|
392
392
|
type: 'object',
|
|
393
393
|
additionalProperties: false,
|
|
394
394
|
properties: {
|
|
395
|
+
indent: {
|
|
396
|
+
type: 'number',
|
|
397
|
+
enum: [
|
|
398
|
+
0,
|
|
399
|
+
1
|
|
400
|
+
]
|
|
401
|
+
},
|
|
395
402
|
type: {
|
|
396
403
|
type: 'string',
|
|
397
404
|
enum: [
|
|
@@ -413,6 +420,7 @@ export const documentSchema = {
|
|
|
413
420
|
}
|
|
414
421
|
},
|
|
415
422
|
required: [
|
|
423
|
+
'indent',
|
|
416
424
|
'type',
|
|
417
425
|
'children'
|
|
418
426
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"sourcesContent":["export const documentSchema = {\n type: 'object',\n $schema: 'http://json-schema.org/draft-07/schema#',\n additionalProperties: false,\n definitions: {\n // Text Node (Leaf Node)\n TextNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['text'] },\n detail: {\n type: 'number',\n description: 'Text detail flags',\n enum: [\n 0, // No details\n 1, // IS_DIRECTIONLESS\n 2, // IS_UNMERGEABLE\n 3, // IS_DIRECTIONLESS + IS_UNMERGEABLE\n ],\n examples: [\n { description: 'No special details', value: 0 },\n { description: 'Directionless', value: 1 },\n { description: 'Unmergeable', value: 2 },\n { description: 'Directionless + Unmergeable', value: 3 },\n ],\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: {\n type: 'number',\n description: `Format flags for text:\n 0 = No format\n 1 = Bold\n 2 = Italic\n 3 = Bold + Italic (1|2)\n 4 = Strikethrough\n 8 = Underline\n 9 = Bold + Underline (1|8)\n 16 = Code\n 32 = Subscript\n 64 = Superscript\n 128 = Highlight\n \n Formats can be combined using binary OR (|).\n Example combinations:\n - Bold + Italic = 1|2 = 3\n - Bold + Underline = 1|8 = 9\n - Italic + Underline = 2|8 = 10\n - Bold + Italic + Underline = 1|2|8 = 11`,\n },\n indent: { type: 'number' },\n mode: {\n type: 'number',\n description: 'Text mode flags',\n enum: [\n 0, // Normal\n 1, // Token\n 2, // Segmented\n ],\n examples: [\n { description: 'Normal text', value: 0 },\n { description: 'Token text', value: 1 },\n { description: 'Segmented text', value: 2 },\n ],\n },\n style: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n text: { type: 'string' },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'text',\n 'format',\n 'style',\n 'mode',\n 'detail',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Cell Node\n TableCellNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablecell'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n colSpan: { type: 'number' },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n headerState: { type: 'number' },\n indent: { type: 'number' },\n version: { type: 'number' },\n width: {\n type: ['null'],\n enum: [null],\n },\n },\n required: [\n 'type',\n 'children',\n 'headerState',\n 'colSpan',\n 'width',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Row Node\n TableRowNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablerow'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableCellNode',\n },\n },\n height: { type: 'number' },\n },\n required: ['type', 'children', 'height'],\n },\n // Styled Table Node\n TableNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['table'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableRowNode',\n },\n },\n },\n required: ['type', 'children'],\n },\n // Heading Node\n HeadingNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['heading'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/TextNode' }, { $ref: '#/definitions/LinkNode' }],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n tag: { type: 'string', enum: ['h1', 'h2', 'h3'] },\n version: { type: 'number' },\n },\n required: ['type', 'tag', 'children', 'direction', 'indent', 'version'],\n },\n // Paragraph Node\n ParagraphNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['paragraph'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/CodeNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: { type: 'string', enum: ['start', 'center', 'right'] },\n indent: { type: 'number' },\n textFormat: { type: 'number' },\n textStyle: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'children',\n 'direction',\n 'format',\n 'indent',\n 'textFormat',\n 'textStyle',\n 'version',\n ],\n },\n // Link Node\n LinkNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['link'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n url: { type: 'string' },\n },\n required: ['type', 'url', 'children'],\n },\n // List Item Node\n ListItemNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['listitem'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/ParagraphNode' }, { $ref: '#/definitions/ListNode' }],\n },\n },\n },\n required: ['type', 'children'],\n },\n // List Node\n ListNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['list'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/ListItemNode',\n },\n },\n listType: { type: 'string', enum: ['bullet', 'number'] },\n },\n required: ['type', 'listType', 'children'],\n },\n // Quote Node\n QuoteNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['quote'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/TextNode' }, { $ref: '#/definitions/ParagraphNode' }],\n },\n },\n },\n required: ['type', 'children'],\n },\n // Code Node\n CodeNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['code'] },\n code: { type: 'string' },\n language: { type: 'string' },\n },\n required: ['type', 'code', 'language'],\n },\n // Horizontal Rule Node\n HorizontalRuleNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['horizontalrule'] },\n },\n required: ['type'],\n },\n // Image Node\n ImageNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['image'] },\n alt: { type: 'string' },\n caption: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n src: { type: 'string' },\n },\n required: ['type', 'src', 'alt', 'caption'],\n },\n // Root Node\n RootNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['root'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/HeadingNode' },\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/ListNode' },\n { $ref: '#/definitions/QuoteNode' },\n { $ref: '#/definitions/CodeNode' },\n { $ref: '#/definitions/HorizontalRuleNode' },\n { $ref: '#/definitions/ImageNode' },\n { $ref: '#/definitions/TableNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n version: { type: 'number' },\n },\n required: ['type', 'children', 'direction', 'indent', 'version'],\n },\n },\n properties: {\n root: {\n $ref: '#/definitions/RootNode',\n },\n },\n required: ['root'],\n}\n\nexport const lexicalJsonSchema = (customNodes = []) => {\n const schema = JSON.parse(JSON.stringify(documentSchema))\n\n // Add custom nodes to the Node definition\n if (customNodes.length > 0) {\n customNodes.forEach((customNode, index) => {\n const customNodeName = `CustomNode${index + 1}`\n schema.definitions[customNodeName] = customNode\n schema.definitions.Node.oneOf.push({ $ref: `#/definitions/${customNodeName}` })\n })\n }\n\n return schema\n}\n"],"names":["documentSchema","type","$schema","additionalProperties","definitions","TextNode","properties","enum","detail","description","examples","value","direction","format","indent","mode","style","text","version","required","TableCellNode","children","items","$ref","colSpan","headerState","width","TableRowNode","height","TableNode","HeadingNode","anyOf","tag","ParagraphNode","textFormat","textStyle","LinkNode","url","ListItemNode","ListNode","listType","QuoteNode","CodeNode","code","language","HorizontalRuleNode","ImageNode","alt","caption","src","RootNode","root","lexicalJsonSchema","customNodes","schema","JSON","parse","stringify","length","forEach","customNode","index","customNodeName","Node","oneOf","push"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB;IAC5BC,MAAM;IACNC,SAAS;IACTC,sBAAsB;IACtBC,aAAa;QACX,wBAAwB;QACxBC,UAAU;YACRJ,MAAM;YACNE,sBAAsB;YACtBG,YAAY;gBACVL,MAAM;oBAAEA,MAAM;oBAAUM,MAAM;wBAAC;qBAAO;gBAAC;gBACvCC,QAAQ;oBACNP,MAAM;oBACNQ,aAAa;oBACbF,MAAM;wBACJ;wBACA;wBACA;wBACA;qBACD;oBACDG,UAAU;wBACR;4BAAED,aAAa;4BAAsBE,OAAO;wBAAE;wBAC9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SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACzD;IAEzC,0CAA0C;IAC1C,IAAIqD,YAAYK,MAAM,GAAG,GAAG;QAC1BL,YAAYM,OAAO,CAAC,CAACC,YAAYC;YAC/B,MAAMC,iBAAiB,CAAC,UAAU,EAAED,QAAQ,GAAG;YAC/CP,OAAOlD,WAAW,CAAC0D,eAAe,GAAGF;YACrCN,OAAOlD,WAAW,CAAC2D,IAAI,CAACC,KAAK,CAACC,IAAI,CAAC;gBAAE1C,MAAM,CAAC,cAAc,EAAEuC,gBAAgB;YAAC;QAC/E;IACF;IAEA,OAAOR;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/ai/schemas/lexicalJsonSchema.ts"],"sourcesContent":["export const documentSchema = {\n type: 'object',\n $schema: 'http://json-schema.org/draft-07/schema#',\n additionalProperties: false,\n definitions: {\n // Text Node (Leaf Node)\n TextNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['text'] },\n detail: {\n type: 'number',\n description: 'Text detail flags',\n enum: [\n 0, // No details\n 1, // IS_DIRECTIONLESS\n 2, // IS_UNMERGEABLE\n 3, // IS_DIRECTIONLESS + IS_UNMERGEABLE\n ],\n examples: [\n { description: 'No special details', value: 0 },\n { description: 'Directionless', value: 1 },\n { description: 'Unmergeable', value: 2 },\n { description: 'Directionless + Unmergeable', value: 3 },\n ],\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: {\n type: 'number',\n description: `Format flags for text:\n 0 = No format\n 1 = Bold\n 2 = Italic\n 3 = Bold + Italic (1|2)\n 4 = Strikethrough\n 8 = Underline\n 9 = Bold + Underline (1|8)\n 16 = Code\n 32 = Subscript\n 64 = Superscript\n 128 = Highlight\n \n Formats can be combined using binary OR (|).\n Example combinations:\n - Bold + Italic = 1|2 = 3\n - Bold + Underline = 1|8 = 9\n - Italic + Underline = 2|8 = 10\n - Bold + Italic + Underline = 1|2|8 = 11`,\n },\n indent: { type: 'number' },\n mode: {\n type: 'number',\n description: 'Text mode flags',\n enum: [\n 0, // Normal\n 1, // Token\n 2, // Segmented\n ],\n examples: [\n { description: 'Normal text', value: 0 },\n { description: 'Token text', value: 1 },\n { description: 'Segmented text', value: 2 },\n ],\n },\n style: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n text: { type: 'string' },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'text',\n 'format',\n 'style',\n 'mode',\n 'detail',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Cell Node\n TableCellNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablecell'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n colSpan: { type: 'number' },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n headerState: { type: 'number' },\n indent: { type: 'number' },\n version: { type: 'number' },\n width: {\n type: ['null'],\n enum: [null],\n },\n },\n required: [\n 'type',\n 'children',\n 'headerState',\n 'colSpan',\n 'width',\n 'direction',\n 'indent',\n 'version',\n ],\n },\n // Styled Table Row Node\n TableRowNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['tablerow'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableCellNode',\n },\n },\n height: { type: 'number' },\n },\n required: ['type', 'children', 'height'],\n },\n // Styled Table Node\n TableNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['table'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TableRowNode',\n },\n },\n },\n required: ['type', 'children'],\n },\n // Heading Node\n HeadingNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['heading'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/TextNode' }, { $ref: '#/definitions/LinkNode' }],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n tag: { type: 'string', enum: ['h1', 'h2', 'h3'] },\n version: { type: 'number' },\n },\n required: ['type', 'tag', 'children', 'direction', 'indent', 'version'],\n },\n // Paragraph Node\n ParagraphNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['paragraph'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/CodeNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n format: { type: 'string', enum: ['start', 'center', 'right'] },\n indent: { type: 'number' },\n textFormat: { type: 'number' },\n textStyle: {\n type: 'string',\n description: 'CSS style string (e.g., \"color: red; font-size: 12px;\")',\n },\n version: { type: 'number' },\n },\n required: [\n 'type',\n 'children',\n 'direction',\n 'format',\n 'indent',\n 'textFormat',\n 'textStyle',\n 'version',\n ],\n },\n // Link Node\n LinkNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['link'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n url: { type: 'string' },\n },\n required: ['type', 'url', 'children'],\n },\n // List Item Node\n ListItemNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n indent: { type: 'number', enum: [0, 1] },\n type: { type: 'string', enum: ['listitem'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/ParagraphNode' }, { $ref: '#/definitions/ListNode' }],\n },\n },\n },\n required: ['indent', 'type', 'children'],\n },\n // List Node\n ListNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['list'] },\n children: {\n type: 'array',\n items: {\n $ref: '#/definitions/ListItemNode',\n },\n },\n listType: { type: 'string', enum: ['bullet', 'number'] },\n },\n required: ['type', 'listType', 'children'],\n },\n // Quote Node\n QuoteNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['quote'] },\n children: {\n type: 'array',\n items: {\n anyOf: [{ $ref: '#/definitions/TextNode' }, { $ref: '#/definitions/ParagraphNode' }],\n },\n },\n },\n required: ['type', 'children'],\n },\n // Code Node\n CodeNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['code'] },\n code: { type: 'string' },\n language: { type: 'string' },\n },\n required: ['type', 'code', 'language'],\n },\n // Horizontal Rule Node\n HorizontalRuleNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['horizontalrule'] },\n },\n required: ['type'],\n },\n // Image Node\n ImageNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['image'] },\n alt: { type: 'string' },\n caption: {\n type: 'array',\n items: {\n $ref: '#/definitions/TextNode',\n },\n },\n src: { type: 'string' },\n },\n required: ['type', 'src', 'alt', 'caption'],\n },\n // Root Node\n RootNode: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', enum: ['root'] },\n children: {\n type: 'array',\n items: {\n anyOf: [\n { $ref: '#/definitions/TextNode' },\n { $ref: '#/definitions/HeadingNode' },\n { $ref: '#/definitions/ParagraphNode' },\n { $ref: '#/definitions/LinkNode' },\n { $ref: '#/definitions/ListNode' },\n { $ref: '#/definitions/QuoteNode' },\n { $ref: '#/definitions/CodeNode' },\n { $ref: '#/definitions/HorizontalRuleNode' },\n { $ref: '#/definitions/ImageNode' },\n { $ref: '#/definitions/TableNode' },\n ],\n },\n },\n direction: {\n type: ['string', 'null'],\n enum: ['ltr', null],\n },\n indent: { type: 'number' },\n version: { type: 'number' },\n },\n required: ['type', 'children', 'direction', 'indent', 'version'],\n },\n },\n properties: {\n root: {\n $ref: '#/definitions/RootNode',\n },\n },\n required: ['root'],\n}\n\nexport const lexicalJsonSchema = (customNodes = []) => {\n const schema = JSON.parse(JSON.stringify(documentSchema))\n\n // Add custom nodes to the Node definition\n if (customNodes.length > 0) {\n customNodes.forEach((customNode, index) => {\n const customNodeName = `CustomNode${index + 1}`\n schema.definitions[customNodeName] = customNode\n schema.definitions.Node.oneOf.push({ $ref: `#/definitions/${customNodeName}` })\n })\n }\n\n return schema\n}\n"],"names":["documentSchema","type","$schema","additionalProperties","definitions","TextNode","properties","enum","detail","description","examples","value","direction","format","indent","mode","style","text","version","required","TableCellNode","children","items","$ref","colSpan","headerState","width","TableRowNode","height","TableNode","HeadingNode","anyOf","tag","ParagraphNode","textFormat","textStyle","LinkNode","url","ListItemNode","ListNode","listType","QuoteNode","CodeNode","code","language","HorizontalRuleNode","ImageNode","alt","caption","src","RootNode","root","lexicalJsonSchema","customNodes","schema","JSON","parse","stringify","length","forEach","customNode","index","customNodeName","Node","oneOf","push"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB;IAC5BC,MAAM;IACNC,SAAS;IACTC,sBAAsB;IACtBC,aAAa;QACX,wBAAwB;QACxBC,UAAU;YACRJ,MAAM;YACNE,sBAAsB;YACtBG,YAAY;gBACVL,MAAM;oBAAEA,MAAM;oBAAUM,MAAM;wBAAC;qBAAO;gBAAC;gBACvCC,QAAQ;oBACNP,MAAM;oBACNQ,aAAa;oBACbF,MAAM;wBACJ;wBACA;wBACA;wBACA;qBACD;oBACDG,UAAU;wBACR;4BAAED,aAAa;4BAAsBE,OAAO;wBAAE;wBAC9C;4BAAEF,aAAa;4BAAiBE,OAAO;wBAAE;wBACzC;4BAAEF,aAAa;4BAAeE,OAAO;wBAAE;wBACvC;4BAAEF,aAAa;4BAA+BE,OAAO;wBAAE;qBACxD;gBACH;gBACAC,WAAW;oBACTX,MAAM;wBAAC;wBAAU;qBAAO;oBACxBM,MAAM;wBAAC;wBAAO;qBAAK;gBACrB;gBACAM,QAAQ;oBACNZ,MAAM;oBACNQ,aAAa,CAAC;;;;;;;;;;;;;;;;;;4CAkBoB,CAAC;gBACrC;gBACAK,QAAQ;oBAAEb,MAAM;gBAAS;gBACzBc,MAAM;oBACJd,MAAM;oBACNQ,aAAa;oBACbF,MAAM;wB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EAAEuC,gBAAgB;YAAC;QAC/E;IACF;IAEA,OAAOR;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemGenerate.d.ts","sourceRoot":"","sources":["../../../src/ai/utils/systemGenerate.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"systemGenerate.d.ts","sourceRoot":"","sources":["../../../src/ai/utils/systemGenerate.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,GACzB,MAAM;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACxC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,oBA0BrE,CAAA"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { anthropic } from '@ai-sdk/anthropic';
|
|
2
|
-
import { openai } from '@ai-sdk/openai';
|
|
3
2
|
import { generateText } from 'ai';
|
|
4
3
|
import { PLUGIN_DEFAULT_ANTHROPIC_MODEL, PLUGIN_DEFAULT_OPENAI_MODEL } from '../../defaults.js';
|
|
5
|
-
|
|
4
|
+
import { openai } from '../models/openai/openai.js';
|
|
5
|
+
export const systemGenerate = async (data, generateTextFn)=>{
|
|
6
6
|
const { prompt, system } = data;
|
|
7
|
+
if (generateTextFn) {
|
|
8
|
+
return generateTextFn(prompt, system);
|
|
9
|
+
}
|
|
7
10
|
let model = null;
|
|
11
|
+
// If the generateTextFn is not provided, still need OPENAI_API_KEY or ANTHROPIC_API_KEY to initialize
|
|
8
12
|
if (process.env.OPENAI_API_KEY) {
|
|
9
13
|
model = openai(PLUGIN_DEFAULT_OPENAI_MODEL);
|
|
10
14
|
} else if (process.env.ANTHROPIC_API_KEY) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/utils/systemGenerate.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/ai/utils/systemGenerate.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { generateText } from 'ai'\n\nimport { PLUGIN_DEFAULT_ANTHROPIC_MODEL, PLUGIN_DEFAULT_OPENAI_MODEL } from '../../defaults.js'\nimport { openai } from '../models/openai/openai.js'\n\nexport const systemGenerate = async (\n data: { prompt: string; system: string },\n generateTextFn?: (prompt: string, system: string) => Promise<string>,\n) => {\n const { prompt, system } = data\n\n if (generateTextFn) {\n return generateTextFn(prompt, system)\n }\n\n let model = null\n\n // If the generateTextFn is not provided, still need OPENAI_API_KEY or ANTHROPIC_API_KEY to initialize\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","generateText","PLUGIN_DEFAULT_ANTHROPIC_MODEL","PLUGIN_DEFAULT_OPENAI_MODEL","openai","systemGenerate","data","generateTextFn","prompt","system","model","process","env","OPENAI_API_KEY","ANTHROPIC_API_KEY","Error","text"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,YAAY,QAAQ,KAAI;AAEjC,SAASC,8BAA8B,EAAEC,2BAA2B,QAAQ,oBAAmB;AAC/F,SAASC,MAAM,QAAQ,6BAA4B;AAEnD,OAAO,MAAMC,iBAAiB,OAC5BC,MACAC;IAEA,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGH;IAE3B,IAAIC,gBAAgB;QAClB,OAAOA,eAAeC,QAAQC;IAChC;IAEA,IAAIC,QAAQ;IAEZ,sGAAsG;IACtG,IAAIC,QAAQC,GAAG,CAACC,cAAc,EAAE;QAC9BH,QAAQN,OAAOD;IACjB,OAAO,IAAIQ,QAAQC,GAAG,CAACE,iBAAiB,EAAE;QACxCJ,QAAQV,UAAUE;IACpB,OAAO;QACL,MAAM,IAAIa,MAAM;IAClB;IAEA,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMf,aAAa;QAClCS;QACAF;QACAC;IACF;IAEA,OAAOO;AACT,EAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { CollectionConfig } from 'payload';
|
|
2
|
-
|
|
2
|
+
import type { PluginConfig } from 'src/types.js';
|
|
3
|
+
export declare const instructionsCollection: (pluginConfig: PluginConfig, options?: Partial<CollectionConfig>) => CollectionConfig;
|
|
3
4
|
//# sourceMappingURL=Instructions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instructions.d.ts","sourceRoot":"","sources":["../../src/collections/Instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"Instructions.d.ts","sourceRoot":"","sources":["../../src/collections/Instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAiChD,eAAO,MAAM,sBAAsB,GACjC,cAAc,YAAY,EAC1B,UAAU,OAAO,CAAC,gBAAgB,CAAC,KAElC,gBAuKA,CAAA"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getGenerationModels } from '../utilities/getGenerationModels.js';
|
|
2
2
|
import { PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js';
|
|
3
|
-
const groupSettings =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, []);
|
|
9
|
-
const modelOptions =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
3
|
+
const groupSettings = (pluginConfig)=>getGenerationModels(pluginConfig).reduce((fields, model)=>{
|
|
4
|
+
if (model.settings) {
|
|
5
|
+
fields.push(model.settings);
|
|
6
|
+
}
|
|
7
|
+
return fields;
|
|
8
|
+
}, []);
|
|
9
|
+
const modelOptions = (pluginConfig)=>getGenerationModels(pluginConfig).map((model)=>{
|
|
10
|
+
return {
|
|
11
|
+
fields: model.fields,
|
|
12
|
+
label: model.name,
|
|
13
|
+
value: model.id
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
16
|
const defaultAccessConfig = {
|
|
17
17
|
create: ()=>true,
|
|
18
18
|
read: ()=>true,
|
|
@@ -22,7 +22,7 @@ const defaultAdminConfig = {
|
|
|
22
22
|
group: 'Plugins',
|
|
23
23
|
hidden: true
|
|
24
24
|
};
|
|
25
|
-
export const instructionsCollection = (options)=>({
|
|
25
|
+
export const instructionsCollection = (pluginConfig, options)=>({
|
|
26
26
|
slug: PLUGIN_INSTRUCTIONS_TABLE,
|
|
27
27
|
access: {
|
|
28
28
|
...defaultAccessConfig,
|
|
@@ -38,7 +38,7 @@ export const instructionsCollection = (options)=>({
|
|
|
38
38
|
name: 'schema-path',
|
|
39
39
|
type: 'text',
|
|
40
40
|
admin: {
|
|
41
|
-
|
|
41
|
+
description: "Please don’t change this unless you're sure of what you're doing"
|
|
42
42
|
},
|
|
43
43
|
unique: true
|
|
44
44
|
},
|
|
@@ -46,7 +46,7 @@ export const instructionsCollection = (options)=>({
|
|
|
46
46
|
name: 'field-type',
|
|
47
47
|
type: 'select',
|
|
48
48
|
admin: {
|
|
49
|
-
|
|
49
|
+
description: "Please don’t change this unless you're sure of what you're doing"
|
|
50
50
|
},
|
|
51
51
|
defaultValue: 'text',
|
|
52
52
|
label: 'Field type',
|
|
@@ -87,14 +87,14 @@ export const instructionsCollection = (options)=>({
|
|
|
87
87
|
Field: {
|
|
88
88
|
clientProps: {
|
|
89
89
|
filterByField: 'field-type',
|
|
90
|
-
options: modelOptions
|
|
90
|
+
options: modelOptions(pluginConfig)
|
|
91
91
|
},
|
|
92
92
|
path: '@ai-stack/payloadcms/fields#SelectField'
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
label: 'Model',
|
|
97
|
-
options: modelOptions.map((option)=>{
|
|
97
|
+
options: modelOptions(pluginConfig).map((option)=>{
|
|
98
98
|
return {
|
|
99
99
|
label: option.label,
|
|
100
100
|
value: option.value
|
|
@@ -106,6 +106,8 @@ export const instructionsCollection = (options)=>({
|
|
|
106
106
|
type: 'tabs',
|
|
107
107
|
tabs: [
|
|
108
108
|
{
|
|
109
|
+
// TODO: Add some info about the field to guide user
|
|
110
|
+
// TODO: Add some info about the field to guide user
|
|
109
111
|
description: 'The Prompt field allows you to define dynamic templates using placeholders (e.g., {{ fieldName }}) to customize output based on your data fields.',
|
|
110
112
|
fields: [
|
|
111
113
|
{
|
|
@@ -114,7 +116,8 @@ export const instructionsCollection = (options)=>({
|
|
|
114
116
|
admin: {
|
|
115
117
|
components: {
|
|
116
118
|
Field: '@ai-stack/payloadcms/fields#PromptEditorField'
|
|
117
|
-
}
|
|
119
|
+
},
|
|
120
|
+
description: "Click 'Compose' to run this custom prompt and generate content"
|
|
118
121
|
},
|
|
119
122
|
label: ''
|
|
120
123
|
}
|
|
@@ -190,7 +193,7 @@ informative and accurate but also captivating and beautifully structured.`,
|
|
|
190
193
|
}
|
|
191
194
|
]
|
|
192
195
|
},
|
|
193
|
-
...groupSettings
|
|
196
|
+
...groupSettings(pluginConfig)
|
|
194
197
|
],
|
|
195
198
|
labels: {
|
|
196
199
|
plural: 'Compose Settings',
|