@ai-stack/payloadcms 3.2.20-beta → 3.2.22-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/dist/ai/models/anthropic/index.js +9 -15
- package/dist/ai/models/anthropic/index.js.map +1 -1
- package/dist/ai/models/generateObject.d.ts +11 -0
- package/dist/ai/models/generateObject.js +22 -0
- package/dist/ai/models/generateObject.js.map +1 -0
- package/dist/ai/models/openai/index.js +19 -17
- package/dist/ai/models/openai/index.js.map +1 -1
- package/dist/collections/Instructions.js +2 -0
- package/dist/collections/Instructions.js.map +1 -1
- package/dist/endpoints/index.js +55 -6
- package/dist/endpoints/index.js.map +1 -1
- package/dist/fields/ComposeField/ComposeField.js +5 -3
- package/dist/fields/ComposeField/ComposeField.js.map +1 -1
- package/dist/fields/ComposeField/ComposeField.jsx +32 -0
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.js +1 -1
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.js.map +1 -1
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.jsx +24 -0
- package/dist/fields/LexicalEditor/feature.client.jsx +21 -0
- package/dist/fields/PromptEditorField/PromptEditorField.jsx +42 -0
- package/dist/fields/SelectField/SelectField.jsx +38 -0
- package/dist/providers/FieldProvider/FieldProvider.d.ts +7 -4
- package/dist/providers/FieldProvider/FieldProvider.js +7 -6
- package/dist/providers/FieldProvider/FieldProvider.js.map +1 -1
- package/dist/providers/FieldProvider/FieldProvider.jsx +27 -0
- package/dist/providers/FieldProvider/useFieldProps.d.ts +1 -1
- package/dist/providers/FieldProvider/useFieldProps.js +2 -2
- package/dist/providers/FieldProvider/useFieldProps.js.map +1 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.jsx +45 -0
- package/dist/types.d.ts +4 -4
- package/dist/types.js.map +1 -1
- package/dist/ui/Compose/Compose.js +12 -81
- package/dist/ui/Compose/Compose.js.map +1 -1
- package/dist/ui/Compose/Compose.jsx +141 -0
- package/dist/ui/Compose/UndoRedoActions.jsx +34 -0
- package/dist/ui/Compose/compose.module.css +99 -12
- package/dist/ui/Compose/hooks/menu/Item.jsx +15 -0
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js +1 -2
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/TranslateMenu.jsx +58 -0
- package/dist/ui/Compose/hooks/menu/items.jsx +10 -0
- package/dist/ui/Compose/hooks/menu/useMenu.js +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.jsx +89 -0
- package/dist/ui/Compose/hooks/useActiveFieldTracking.d.ts +5 -0
- package/dist/ui/Compose/hooks/useActiveFieldTracking.js +225 -0
- package/dist/ui/Compose/hooks/useActiveFieldTracking.js.map +1 -0
- package/dist/ui/Compose/hooks/useGenerate.js +46 -79
- package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
- package/dist/ui/Icons/Icons.jsx +78 -0
- package/dist/ui/Icons/LottieAnimation.jsx +64 -0
- package/dist/utilities/extractPromptAttachments.d.ts +2 -2
- package/dist/utilities/extractPromptAttachments.js.map +1 -1
- package/dist/utilities/fieldToJsonSchema.d.ts +37 -0
- package/dist/utilities/fieldToJsonSchema.js +274 -0
- package/dist/utilities/fieldToJsonSchema.js.map +1 -0
- package/dist/utilities/getFieldBySchemaPath.d.ts +12 -1
- package/dist/utilities/getFieldBySchemaPath.js +63 -29
- package/dist/utilities/getFieldBySchemaPath.js.map +1 -1
- package/package.json +2 -1
- package/dist/ai/models/anthropic/generateRichText.d.ts +0 -1
- package/dist/ai/models/anthropic/generateRichText.js +0 -36
- package/dist/ai/models/anthropic/generateRichText.js.map +0 -1
- package/dist/ai/models/openai/generateRichText.d.ts +0 -1
- package/dist/ai/models/openai/generateRichText.js +0 -37
- package/dist/ai/models/openai/generateRichText.js.map +0 -1
|
@@ -1,45 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a Payload field definition by a full schemaPath like:
|
|
3
|
+
* "{collectionSlug}.fieldA.subFieldB.blockSlug.innerField"
|
|
4
|
+
*
|
|
5
|
+
* Notes:
|
|
6
|
+
* - Tabs are a UI construct and are not part of schemaPath (fields inside tabs are at the same level).
|
|
7
|
+
* - Blocks include the block slug as part of the path (we must consume it between the block field and its inner fields).
|
|
8
|
+
* - Rows are skipped by this plugin's schema path mapping; support added defensively.
|
|
9
|
+
*/ export const getFieldBySchemaPath = (collectionConfig, schemaPath)=>{
|
|
10
|
+
if (!collectionConfig || !schemaPath) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const parts = schemaPath.split('.');
|
|
14
|
+
if (!parts.length) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
// Strip the collection slug prefix if present
|
|
18
|
+
const [collectionSlug, ...rest] = parts;
|
|
19
|
+
const pathParts = collectionSlug === collectionConfig.slug ? rest.filter(Boolean) : parts.filter(Boolean);
|
|
20
|
+
if (!pathParts.length) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const findInFields = (fields, segments)=>{
|
|
24
|
+
if (!segments.length) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const [current, ...remaining] = segments;
|
|
28
|
+
// First, try to match a field by name
|
|
5
29
|
for (const field of fields){
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
30
|
+
// Tabs do not contribute to path segments; search inside all tabs with the same segments
|
|
31
|
+
if (field.tabs) {
|
|
32
|
+
const tabs = field.tabs;
|
|
33
|
+
for (const tab of tabs){
|
|
34
|
+
const foundInTab = tab.fields && tab.fields.length ? findInFields(tab.fields, segments) : null;
|
|
35
|
+
if (foundInTab) {
|
|
36
|
+
return foundInTab;
|
|
37
|
+
}
|
|
13
38
|
}
|
|
14
39
|
}
|
|
15
|
-
if (field.
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
40
|
+
if (field.name === current) {
|
|
41
|
+
// If this is the last segment, we found the target field
|
|
42
|
+
if (remaining.length === 0) {
|
|
43
|
+
return field;
|
|
19
44
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return result;
|
|
45
|
+
// Recurse into composite field types
|
|
46
|
+
if (field.fields && Array.isArray(field.fields)) {
|
|
47
|
+
const found = findInFields(field.fields, remaining);
|
|
48
|
+
if (found) {
|
|
49
|
+
return found;
|
|
26
50
|
}
|
|
27
51
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
if (field.blocks && Array.isArray(field.blocks)) {
|
|
53
|
+
// Next segment should be a block slug, then continue into block fields
|
|
54
|
+
if (!remaining.length) {
|
|
55
|
+
return field;
|
|
56
|
+
} // path stops at block container (unlikely for our mapping)
|
|
57
|
+
const [blockSlug, ...afterBlock] = remaining;
|
|
58
|
+
const blocks = field.blocks;
|
|
59
|
+
const block = blocks.find((b)=>b.slug === blockSlug);
|
|
60
|
+
if (block) {
|
|
61
|
+
const found = findInFields(block.fields, afterBlock);
|
|
62
|
+
if (found) {
|
|
63
|
+
return found;
|
|
35
64
|
}
|
|
36
65
|
}
|
|
37
66
|
}
|
|
38
67
|
}
|
|
39
68
|
}
|
|
69
|
+
// Not found at this level
|
|
40
70
|
return null;
|
|
41
71
|
};
|
|
42
|
-
|
|
72
|
+
const rootFields = collectionConfig.fields;
|
|
73
|
+
if (!rootFields || !Array.isArray(rootFields)) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return findInFields(rootFields, pathParts);
|
|
43
77
|
};
|
|
44
78
|
|
|
45
79
|
//# sourceMappingURL=getFieldBySchemaPath.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getFieldBySchemaPath.ts"],"sourcesContent":["import type { ClientCollectionConfig, CollectionConfig, Field } from 'payload'\n\nexport const getFieldBySchemaPath = (\n collectionConfig:
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getFieldBySchemaPath.ts"],"sourcesContent":["import type { ClientCollectionConfig, CollectionConfig, Field } from 'payload'\n\ntype AnyCollectionConfig = ClientCollectionConfig | CollectionConfig\n\n/**\n * Resolve a Payload field definition by a full schemaPath like:\n * \"{collectionSlug}.fieldA.subFieldB.blockSlug.innerField\"\n *\n * Notes:\n * - Tabs are a UI construct and are not part of schemaPath (fields inside tabs are at the same level).\n * - Blocks include the block slug as part of the path (we must consume it between the block field and its inner fields).\n * - Rows are skipped by this plugin's schema path mapping; support added defensively.\n */\nexport const getFieldBySchemaPath = (\n collectionConfig: AnyCollectionConfig,\n schemaPath: string,\n): Field | null => {\n if (!collectionConfig || !schemaPath) {\n return null\n }\n\n const parts = schemaPath.split('.')\n if (!parts.length) {\n return null\n }\n\n // Strip the collection slug prefix if present\n const [collectionSlug, ...rest] = parts\n const pathParts =\n collectionSlug === collectionConfig.slug ? rest.filter(Boolean) : parts.filter(Boolean)\n\n if (!pathParts.length) {\n return null\n }\n\n const findInFields = (fields: Field[], segments: string[]): Field | null => {\n if (!segments.length) {\n return null\n }\n\n const [current, ...remaining] = segments\n\n // First, try to match a field by name\n for (const field of fields) {\n // Tabs do not contribute to path segments; search inside all tabs with the same segments\n if ((field as any).tabs) {\n const tabs = (field as any).tabs as Array<{ fields?: Field[] }>\n for (const tab of tabs) {\n const foundInTab =\n tab.fields && tab.fields.length ? findInFields(tab.fields, segments) : null\n if (foundInTab) {\n return foundInTab\n }\n }\n }\n\n if ((field as any).name === current) {\n // If this is the last segment, we found the target field\n if (remaining.length === 0) {\n return field\n }\n\n // Recurse into composite field types\n if ((field as any).fields && Array.isArray((field as any).fields)) {\n const found = findInFields((field as any).fields, remaining)\n if (found) {\n return found\n }\n }\n\n if ((field as any).blocks && Array.isArray((field as any).blocks)) {\n // Next segment should be a block slug, then continue into block fields\n if (!remaining.length) {\n return field\n } // path stops at block container (unlikely for our mapping)\n const [blockSlug, ...afterBlock] = remaining\n const blocks = (field as any).blocks as Array<{ fields: Field[]; slug: string }>\n const block = blocks.find((b) => b.slug === blockSlug)\n if (block) {\n const found = findInFields(block.fields, afterBlock)\n if (found) {\n return found\n }\n }\n }\n }\n }\n\n // Not found at this level\n return null\n }\n\n const rootFields = (collectionConfig as any).fields as Field[] | undefined\n if (!rootFields || !Array.isArray(rootFields)) {\n return null\n }\n\n return findInFields(rootFields, pathParts)\n}\n"],"names":["getFieldBySchemaPath","collectionConfig","schemaPath","parts","split","length","collectionSlug","rest","pathParts","slug","filter","Boolean","findInFields","fields","segments","current","remaining","field","tabs","tab","foundInTab","name","Array","isArray","found","blocks","blockSlug","afterBlock","block","find","b","rootFields"],"mappings":"AAIA;;;;;;;;CAQC,GACD,OAAO,MAAMA,uBAAuB,CAClCC,kBACAC;IAEA,IAAI,CAACD,oBAAoB,CAACC,YAAY;QACpC,OAAO;IACT;IAEA,MAAMC,QAAQD,WAAWE,KAAK,CAAC;IAC/B,IAAI,CAACD,MAAME,MAAM,EAAE;QACjB,OAAO;IACT;IAEA,8CAA8C;IAC9C,MAAM,CAACC,gBAAgB,GAAGC,KAAK,GAAGJ;IAClC,MAAMK,YACJF,mBAAmBL,iBAAiBQ,IAAI,GAAGF,KAAKG,MAAM,CAACC,WAAWR,MAAMO,MAAM,CAACC;IAEjF,IAAI,CAACH,UAAUH,MAAM,EAAE;QACrB,OAAO;IACT;IAEA,MAAMO,eAAe,CAACC,QAAiBC;QACrC,IAAI,CAACA,SAAST,MAAM,EAAE;YACpB,OAAO;QACT;QAEA,MAAM,CAACU,SAAS,GAAGC,UAAU,GAAGF;QAEhC,sCAAsC;QACtC,KAAK,MAAMG,SAASJ,OAAQ;YAC1B,yFAAyF;YACzF,IAAI,AAACI,MAAcC,IAAI,EAAE;gBACvB,MAAMA,OAAO,AAACD,MAAcC,IAAI;gBAChC,KAAK,MAAMC,OAAOD,KAAM;oBACtB,MAAME,aACJD,IAAIN,MAAM,IAAIM,IAAIN,MAAM,CAACR,MAAM,GAAGO,aAAaO,IAAIN,MAAM,EAAEC,YAAY;oBACzE,IAAIM,YAAY;wBACd,OAAOA;oBACT;gBACF;YACF;YAEA,IAAI,AAACH,MAAcI,IAAI,KAAKN,SAAS;gBACnC,yDAAyD;gBACzD,IAAIC,UAAUX,MAAM,KAAK,GAAG;oBAC1B,OAAOY;gBACT;gBAEA,qCAAqC;gBACrC,IAAI,AAACA,MAAcJ,MAAM,IAAIS,MAAMC,OAAO,CAAC,AAACN,MAAcJ,MAAM,GAAG;oBACjE,MAAMW,QAAQZ,aAAa,AAACK,MAAcJ,MAAM,EAAEG;oBAClD,IAAIQ,OAAO;wBACT,OAAOA;oBACT;gBACF;gBAEA,IAAI,AAACP,MAAcQ,MAAM,IAAIH,MAAMC,OAAO,CAAC,AAACN,MAAcQ,MAAM,GAAG;oBACjE,uEAAuE;oBACvE,IAAI,CAACT,UAAUX,MAAM,EAAE;wBACrB,OAAOY;oBACT,EAAE,2DAA2D;oBAC7D,MAAM,CAACS,WAAW,GAAGC,WAAW,GAAGX;oBACnC,MAAMS,SAAS,AAACR,MAAcQ,MAAM;oBACpC,MAAMG,QAAQH,OAAOI,IAAI,CAAC,CAACC,IAAMA,EAAErB,IAAI,KAAKiB;oBAC5C,IAAIE,OAAO;wBACT,MAAMJ,QAAQZ,aAAagB,MAAMf,MAAM,EAAEc;wBACzC,IAAIH,OAAO;4BACT,OAAOA;wBACT;oBACF;gBACF;YACF;QACF;QAEA,0BAA0B;QAC1B,OAAO;IACT;IAEA,MAAMO,aAAa,AAAC9B,iBAAyBY,MAAM;IACnD,IAAI,CAACkB,cAAc,CAACT,MAAMC,OAAO,CAACQ,aAAa;QAC7C,OAAO;IACT;IAEA,OAAOnB,aAAamB,YAAYvB;AAClC,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-stack/payloadcms",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.22-beta",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bugs": "https://github.com/ashbuilds/payload-ai/issues",
|
|
6
6
|
"repository": "https://github.com/ashbuilds/payload-ai",
|
|
@@ -127,6 +127,7 @@
|
|
|
127
127
|
"@ai-sdk/react": "^2.0.39",
|
|
128
128
|
"@ai-sdk/ui-utils": "^1.2.10",
|
|
129
129
|
"@anthropic-ai/sdk": "^0.62.0",
|
|
130
|
+
"@fal-ai/client": "^1.7.0",
|
|
130
131
|
"ai": "^5.0.39",
|
|
131
132
|
"ajv": "^8.17.1",
|
|
132
133
|
"elevenlabs": "^0.8.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const generateRichText: (text: string, options: any) => Response;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { anthropic } from '@ai-sdk/anthropic';
|
|
2
|
-
import { jsonSchema, streamObject } from 'ai';
|
|
3
|
-
import { extractPromptAttachments } from "../../../utilities/extractPromptAttachments.js";
|
|
4
|
-
export const generateRichText = (text, options)=>{
|
|
5
|
-
const streamResult = streamObject({
|
|
6
|
-
maxOutputTokens: options.maxTokens || 5000,
|
|
7
|
-
model: anthropic(options.model),
|
|
8
|
-
onError: (error)=>{
|
|
9
|
-
console.error(`generateRichText: `, error);
|
|
10
|
-
},
|
|
11
|
-
prompt: options.extractAttachments ? extractPromptAttachments(text) : text,
|
|
12
|
-
schema: jsonSchema(options.editorSchema),
|
|
13
|
-
system: `${options.system}
|
|
14
|
-
|
|
15
|
-
RULES:
|
|
16
|
-
- Generate original and unique content based on the given topic.
|
|
17
|
-
- Strictly adhere to the specified layout and formatting instructions.
|
|
18
|
-
- Utilize the provided rich text editor tools for appropriate formatting.
|
|
19
|
-
- Ensure the output follows the structure of the sample output object.
|
|
20
|
-
- Produce valid JSON with no undefined or null values.
|
|
21
|
-
---
|
|
22
|
-
LAYOUT INSTRUCTIONS:
|
|
23
|
-
${options.layout}
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
ADDITIONAL GUIDELINES:
|
|
27
|
-
- Ensure coherence and logical flow between all sections.
|
|
28
|
-
- Maintain a consistent tone and style throughout the content.
|
|
29
|
-
- Use clear and concise language appropriate for the target audience.
|
|
30
|
-
`,
|
|
31
|
-
temperature: options.temperature || 0.7
|
|
32
|
-
});
|
|
33
|
-
return streamResult.toTextStreamResponse();
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=generateRichText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { jsonSchema, streamObject } from 'ai'\n\nimport {extractPromptAttachments} from \"../../../utilities/extractPromptAttachments.js\";\n\nexport const generateRichText = (text: string, options: any) => {\n const streamResult = streamObject({\n maxOutputTokens: options.maxTokens || 5000,\n model: anthropic(options.model),\n onError: (error) => {\n console.error(`generateRichText: `, error)\n },\n prompt: options.extractAttachments ? extractPromptAttachments(text) : 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\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 temperature: options.temperature || 0.7,\n })\n\n return streamResult.toTextStreamResponse()\n}\n"],"names":["anthropic","jsonSchema","streamObject","extractPromptAttachments","generateRichText","text","options","streamResult","maxOutputTokens","maxTokens","model","onError","error","console","prompt","extractAttachments","schema","editorSchema","system","layout","temperature","toTextStreamResponse"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,UAAU,EAAEC,YAAY,QAAQ,KAAI;AAE7C,SAAQC,wBAAwB,QAAO,iDAAiD;AAExF,OAAO,MAAMC,mBAAmB,CAACC,MAAcC;IAC7C,MAAMC,eAAeL,aAAa;QAChCM,iBAAiBF,QAAQG,SAAS,IAAI;QACtCC,OAAOV,UAAUM,QAAQI,KAAK;QAC9BC,SAAS,CAACC;YACRC,QAAQD,KAAK,CAAC,CAAC,kBAAkB,CAAC,EAAEA;QACtC;QACAE,QAAQR,QAAQS,kBAAkB,GAAGZ,yBAAyBE,QAAQA;QACtEW,QAAQf,WAAWK,QAAQW,YAAY;QACvCC,QAAQ,GAAGZ,QAAQY,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEZ,QAAQa,MAAM,CAAC;;;;;;;AAOjB,CAAC;QACGC,aAAad,QAAQc,WAAW,IAAI;IACtC;IAEA,OAAOb,aAAac,oBAAoB;AAC1C,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const generateRichText: (text: string, options?: any) => Response;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { jsonSchema, streamObject } from 'ai';
|
|
2
|
-
import { extractPromptAttachments } from "../../../utilities/extractPromptAttachments.js";
|
|
3
|
-
import { openai } from './openai.js';
|
|
4
|
-
export const generateRichText = (text, options = {})=>{
|
|
5
|
-
console.log("options.layout ", options.layout);
|
|
6
|
-
const streamResult = streamObject({
|
|
7
|
-
maxOutputTokens: options.maxTokens || 5000,
|
|
8
|
-
model: openai(options.model),
|
|
9
|
-
onError: (error)=>{
|
|
10
|
-
console.error(`generateRichText: `, error);
|
|
11
|
-
},
|
|
12
|
-
prompt: options.extractAttachments ? extractPromptAttachments(text) : text,
|
|
13
|
-
schema: jsonSchema(options.editorSchema),
|
|
14
|
-
system: `${options.system}
|
|
15
|
-
|
|
16
|
-
RULES:
|
|
17
|
-
- Generate original and unique content based on the given topic.
|
|
18
|
-
- Strictly adhere to the specified layout and formatting instructions.
|
|
19
|
-
- Utilize the provided rich text editor tools for appropriate formatting.
|
|
20
|
-
- Ensure the output follows the structure of the sample output object.
|
|
21
|
-
- Produce valid JSON with no undefined or null values.
|
|
22
|
-
---
|
|
23
|
-
LAYOUT INSTRUCTIONS:
|
|
24
|
-
${options.layout}
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
ADDITIONAL GUIDELINES:
|
|
28
|
-
- Ensure coherence and logical flow between all sections.
|
|
29
|
-
- Maintain a consistent tone and style throughout the content.
|
|
30
|
-
- Use clear and concise language appropriate for the target audience.
|
|
31
|
-
`,
|
|
32
|
-
temperature: options.temperature || 0.7
|
|
33
|
-
});
|
|
34
|
-
return streamResult.toTextStreamResponse();
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=generateRichText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import { jsonSchema, streamObject } from 'ai'\n\nimport {extractPromptAttachments} from \"../../../utilities/extractPromptAttachments.js\";\nimport { openai } from './openai.js'\n\n\nexport const generateRichText = (text: string, options: any = {}) => {\n console.log(\"options.layout \", options.layout)\n const streamResult = streamObject({\n maxOutputTokens: options.maxTokens || 5000,\n model: openai(options.model),\n onError: (error) => {\n console.error(`generateRichText: `, error)\n },\n prompt: options.extractAttachments ? extractPromptAttachments(text) : 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\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 temperature: options.temperature || 0.7,\n })\n return streamResult.toTextStreamResponse()\n}\n"],"names":["jsonSchema","streamObject","extractPromptAttachments","openai","generateRichText","text","options","console","log","layout","streamResult","maxOutputTokens","maxTokens","model","onError","error","prompt","extractAttachments","schema","editorSchema","system","temperature","toTextStreamResponse"],"mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,QAAQ,KAAI;AAE7C,SAAQC,wBAAwB,QAAO,iDAAiD;AACxF,SAASC,MAAM,QAAQ,cAAa;AAGpC,OAAO,MAAMC,mBAAmB,CAACC,MAAcC,UAAe,CAAC,CAAC;IAC9DC,QAAQC,GAAG,CAAC,mBAAmBF,QAAQG,MAAM;IAC7C,MAAMC,eAAeT,aAAa;QAChCU,iBAAiBL,QAAQM,SAAS,IAAI;QACtCC,OAAOV,OAAOG,QAAQO,KAAK;QAC3BC,SAAS,CAACC;YACRR,QAAQQ,KAAK,CAAC,CAAC,kBAAkB,CAAC,EAAEA;QACtC;QACAC,QAAQV,QAAQW,kBAAkB,GAAGf,yBAAyBG,QAAQA;QACtEa,QAAQlB,WAAWM,QAAQa,YAAY;QACvCC,QAAQ,GAAGd,QAAQc,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEd,QAAQG,MAAM,CAAC;;;;;;;AAOjB,CAAC;QACGY,aAAaf,QAAQe,WAAW,IAAI;IACtC;IACA,OAAOX,aAAaY,oBAAoB;AAC1C,EAAC"}
|