@riotprompt/riotprompt 0.0.13 → 0.0.15
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 +18 -15
- package/dist/chat.d.ts +2 -0
- package/dist/chat.js +2 -0
- package/dist/chat.js.map +1 -1
- package/dist/cli.cjs +118 -20
- package/dist/execution/anthropic.js +27 -3
- package/dist/execution/anthropic.js.map +1 -1
- package/dist/execution/gemini.js +45 -1
- package/dist/execution/gemini.js.map +1 -1
- package/dist/execution/openai.js +2 -1
- package/dist/execution/openai.js.map +1 -1
- package/dist/formatter.js +42 -14
- package/dist/formatter.js.map +1 -1
- package/dist/prompt.d.ts +19 -1
- package/dist/prompt.js +11 -2
- package/dist/prompt.js.map +1 -1
- package/dist/recipes.d.ts +108 -0
- package/dist/recipes.js +195 -30
- package/dist/recipes.js.map +1 -1
- package/dist/riotprompt.cjs +323 -51
- package/dist/riotprompt.cjs.map +1 -1
- package/guide/architecture.md +33 -22
- package/guide/index.md +25 -25
- package/guide/usage.md +96 -39
- package/package.json +3 -2
package/dist/formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sources":["../src/formatter.ts"],"sourcesContent":["import { Instruction } from \"riotprompt\";\nimport { z } from \"zod\";\nimport * as Chat from \"./chat\";\nimport { getPersonaRole, Message, Model } from \"./chat\";\nimport { DEFAULT_FORMAT_OPTIONS } from \"./constants\";\nimport { Section } from \"./items/section\";\nimport { Weighted } from \"./items/weighted\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Prompt } from \"./prompt\";\nimport { clean, stringifyJSON } from \"./util/general\";\n\nexport const SectionSeparatorSchema = z.enum([\"tag\", \"markdown\"]);\nexport const SectionTitlePropertySchema = z.enum([\"title\", \"name\"]);\n\nexport type SectionSeparator = z.infer<typeof SectionSeparatorSchema>;\nexport type SectionTitleProperty = z.infer<typeof SectionTitlePropertySchema>;\n\n\nexport const FormatOptionsSchema = z.object({\n sectionSeparator: SectionSeparatorSchema,\n sectionIndentation: z.boolean(),\n sectionTitleProperty: SectionTitlePropertySchema,\n sectionTitlePrefix: z.string().optional(),\n sectionTitleSeparator: z.string().optional(),\n sectionDepth: z.number().default(0),\n});\n\nexport type FormatOptions = z.infer<typeof FormatOptionsSchema>;\n\n\nexport const OptionSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n formatOptions: FormatOptionsSchema.partial().optional().default(DEFAULT_FORMAT_OPTIONS),\n});\n\nexport type Options = z.infer<typeof OptionSchema>;\n\nexport type OptionsParam = Partial<Options>;\n\nexport interface Instance {\n formatPersona: (model: Model, persona: Section<Instruction>) => Message;\n format: <T extends Weighted>(weightedText: T | Section<T>, sectionDepth?: number) => string;\n formatArray: <T extends Weighted>(items: (T | Section<T>)[], sectionDepth?: number) => string;\n formatPrompt: (model: Model, prompt: Prompt) => Chat.Request;\n}\n\n// Type guard to check if an object is a Section\nfunction isSection<T extends Weighted>(obj: T | Section<T>): obj is Section<T> {\n return obj && typeof obj === 'object' && 'items' in obj && Array.isArray((obj as Section<T>).items);\n}\n\n// Type guard to check if an object is a Section\nfunction isWeighted<T extends Weighted>(obj: T | Section<T>): obj is T {\n return obj && typeof obj === 'object' && 'text' in obj;\n}\n\n\nexport const create = (formatterOptions?: OptionsParam): Instance => {\n const options: Required<Options> = OptionSchema.parse(formatterOptions || {}) as Required<Options>;\n\n const logger = wrapLogger(options.logger, 'Formatter');\n\n let formatOptions: FormatOptions = DEFAULT_FORMAT_OPTIONS;\n if (options?.formatOptions) {\n formatOptions = {\n ...formatOptions,\n ...clean(options.formatOptions),\n };\n }\n\n const formatPersona = (model: Model, persona: Section<Instruction>): Message => {\n logger.silly(`Formatting persona`);\n if (persona) {\n const formattedPersona = formatSection(persona);\n\n return {\n role: getPersonaRole(model),\n content: `${formattedPersona}`,\n }\n } else {\n throw new Error(\"Persona is required\");\n }\n }\n\n const format = <T extends Weighted>(\n item: T | Section<T>,\n sectionDepth?: number,\n ): string => {\n logger.silly(`Formatting ${isSection(item) ? \"section\" : \"item\"} Item: %s`, stringifyJSON(item));\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n logger.silly(`\\t\\tCurrent section depth: ${currentSectionDepth}`);\n\n let result: string = \"\";\n if (isSection(item)) {\n result = formatSection(item, currentSectionDepth + 1);\n } else if (isWeighted(item)) {\n result = item.text;\n } else {\n //If the item is neither a section nor a weighted item, it is empty.\n result = '';\n }\n return result;\n }\n\n const formatSection = <T extends Weighted>(section: Section<T>, sectionDepth?: number): string => {\n logger.silly(`Formatting section`);\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n logger.silly(`\\t\\tCurrent section depth: ${currentSectionDepth}`);\n\n if (section) {\n const formattedItems = section.items.map(item => format(item, currentSectionDepth)).join(\"\\n\\n\");\n\n if (formatOptions.sectionSeparator === \"tag\") {\n return `<${section.title ?? \"section\"}>\\n${formattedItems}\\n</${section.title ?? \"section\"}>`;\n } else {\n // Use the current section depth for heading level\n const headingLevel = currentSectionDepth;\n const hashes = '#'.repeat(headingLevel);\n logger.silly(`\\t\\tHeading level: ${headingLevel}`);\n logger.silly(`\\t\\tSection title: ${section.title}`);\n return `${hashes} ${formatOptions.sectionTitlePrefix ? `${formatOptions.sectionTitlePrefix} ${formatOptions.sectionTitleSeparator} ` : \"\"}${section.title}\\n\\n${formattedItems}`;\n }\n } else {\n return '';\n }\n }\n\n // Helper function to format arrays of items or sections\n const formatArray = <T extends Weighted>(\n items: (T | Section<T>)[],\n sectionDepth?: number\n ): string => {\n logger.silly(`Formatting array`);\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n return items.map(item => format(item, currentSectionDepth)).join(\"\\n\\n\");\n }\n\n const formatPrompt = (model: Model, prompt: Prompt): Chat.Request => {\n logger.silly('Formatting prompt');\n const chatRequest: Chat.Request = Chat.createRequest(model);\n\n if (prompt.persona) {\n [prompt.persona].forEach((persona: Section<Instruction>) => {\n chatRequest.addMessage(formatPersona(model, persona));\n });\n }\n\n let formattedAreas: string = formatSection(prompt.instructions) + '\\n\\n';\n\n if (prompt.contents) {\n formattedAreas += formatSection(prompt.contents) + '\\n\\n';\n }\n\n if (prompt.contexts) {\n formattedAreas += formatSection(prompt.contexts) + '\\n\\n';\n }\n\n chatRequest.addMessage({\n role: \"user\",\n content: formattedAreas,\n });\n\n return chatRequest;\n }\n\n return {\n formatPersona,\n format,\n formatPrompt,\n formatArray,\n }\n}\n"],"names":["SectionSeparatorSchema","z","enum","SectionTitlePropertySchema","FormatOptionsSchema","object","sectionSeparator","sectionIndentation","boolean","sectionTitleProperty","sectionTitlePrefix","string","optional","sectionTitleSeparator","sectionDepth","number","default","OptionSchema","logger","any","DEFAULT_LOGGER","formatOptions","partial","DEFAULT_FORMAT_OPTIONS","isSection","obj","Array","isArray","items","isWeighted","create","formatterOptions","options","parse","wrapLogger","clean","formatPersona","model","persona","silly","formattedPersona","formatSection","role","getPersonaRole","content","Error","format","item","stringifyJSON","currentSectionDepth","result","text","section","formattedItems","map","join","title","headingLevel","hashes","repeat","formatArray","formatPrompt","prompt","chatRequest","Chat","forEach","addMessage","formattedAreas","instructions","contents","contexts"],"mappings":";;;;;;AAWO,MAAMA,sBAAAA,GAAyBC,CAAAA,CAAEC,IAAI,CAAC;AAAC,IAAA,KAAA;AAAO,IAAA;CAAW;AACzD,MAAMC,0BAAAA,GAA6BF,CAAAA,CAAEC,IAAI,CAAC;AAAC,IAAA,OAAA;AAAS,IAAA;CAAO;AAM3D,MAAME,mBAAAA,GAAsBH,CAAAA,CAAEI,MAAM,CAAC;IACxCC,gBAAAA,EAAkBN,sBAAAA;AAClBO,IAAAA,kBAAAA,EAAoBN,EAAEO,OAAO,EAAA;IAC7BC,oBAAAA,EAAsBN,0BAAAA;IACtBO,kBAAAA,EAAoBT,CAAAA,CAAEU,MAAM,EAAA,CAAGC,QAAQ,EAAA;IACvCC,qBAAAA,EAAuBZ,CAAAA,CAAEU,MAAM,E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J,QAAA;AAEA,QAAA,IAAI6B,cAAAA,GAAyB1B,aAAAA,CAAcqB,MAAAA,CAAOM,YAAY,CAAA,GAAI,MAAA;QAElE,IAAIN,MAAAA,CAAOO,QAAQ,EAAE;YACjBF,cAAAA,IAAkB1B,aAAAA,CAAcqB,MAAAA,CAAOO,QAAQ,CAAA,GAAI,MAAA;AACvD,QAAA;QAEA,IAAIP,MAAAA,CAAOQ,QAAQ,EAAE;YACjBH,cAAAA,IAAkB1B,aAAAA,CAAcqB,MAAAA,CAAOQ,QAAQ,CAAA,GAAI,MAAA;AACvD,QAAA;AAEAP,QAAAA,WAAAA,CAAYG,UAAU,CAAC;YACnBxB,IAAAA,EAAM,MAAA;YACNE,OAAAA,EAASuB;AACb,SAAA,CAAA;QAEA,OAAOJ,WAAAA;AACX,IAAA,CAAA;IAEA,OAAO;AACH3B,QAAAA,aAAAA;AACAU,QAAAA,MAAAA;AACAe,QAAAA,YAAAA;AACAD,QAAAA;AACJ,KAAA;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"formatter.js","sources":["../src/formatter.ts"],"sourcesContent":["import { Instruction } from \"riotprompt\";\nimport { z } from \"zod\";\nimport * as Chat from \"./chat\";\nimport { getPersonaRole, Message, Model } from \"./chat\";\nimport { DEFAULT_FORMAT_OPTIONS } from \"./constants\";\nimport { Section } from \"./items/section\";\nimport { Weighted } from \"./items/weighted\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Prompt } from \"./prompt\";\nimport { clean, stringifyJSON } from \"./util/general\";\n\nexport const SectionSeparatorSchema = z.enum([\"tag\", \"markdown\"]);\nexport const SectionTitlePropertySchema = z.enum([\"title\", \"name\"]);\n\nexport type SectionSeparator = z.infer<typeof SectionSeparatorSchema>;\nexport type SectionTitleProperty = z.infer<typeof SectionTitlePropertySchema>;\n\n\nexport const FormatOptionsSchema = z.object({\n sectionSeparator: SectionSeparatorSchema,\n sectionIndentation: z.boolean(),\n sectionTitleProperty: SectionTitlePropertySchema,\n sectionTitlePrefix: z.string().optional(),\n sectionTitleSeparator: z.string().optional(),\n sectionDepth: z.number().default(0),\n});\n\nexport type FormatOptions = z.infer<typeof FormatOptionsSchema>;\n\n\nexport const OptionSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n formatOptions: FormatOptionsSchema.partial().optional().default(DEFAULT_FORMAT_OPTIONS),\n});\n\nexport type Options = z.infer<typeof OptionSchema>;\n\nexport type OptionsParam = Partial<Options>;\n\nexport interface Instance {\n formatPersona: (model: Model, persona: Section<Instruction>) => Message;\n format: <T extends Weighted>(weightedText: T | Section<T>, sectionDepth?: number) => string;\n formatArray: <T extends Weighted>(items: (T | Section<T>)[], sectionDepth?: number) => string;\n formatPrompt: (model: Model, prompt: Prompt) => Chat.Request;\n}\n\n// Type guard to check if an object is a Section\nfunction isSection<T extends Weighted>(obj: T | Section<T>): obj is Section<T> {\n return obj && typeof obj === 'object' && 'items' in obj && Array.isArray((obj as Section<T>).items);\n}\n\n// Type guard to check if an object is a Section\nfunction isWeighted<T extends Weighted>(obj: T | Section<T>): obj is T {\n return obj && typeof obj === 'object' && 'text' in obj;\n}\n\n\nexport const create = (formatterOptions?: OptionsParam): Instance => {\n const options: Required<Options> = OptionSchema.parse(formatterOptions || {}) as Required<Options>;\n\n const logger = wrapLogger(options.logger, 'Formatter');\n\n let formatOptions: FormatOptions = DEFAULT_FORMAT_OPTIONS;\n if (options?.formatOptions) {\n formatOptions = {\n ...formatOptions,\n ...clean(options.formatOptions),\n };\n }\n\n const formatPersona = (model: Model, persona: Section<Instruction>): Message => {\n logger.silly(`Formatting persona`);\n if (persona) {\n const formattedPersona = formatSection(persona);\n\n return {\n role: getPersonaRole(model),\n content: `${formattedPersona}`,\n }\n } else {\n throw new Error(\"Persona is required\");\n }\n }\n\n const format = <T extends Weighted>(\n item: T | Section<T>,\n sectionDepth?: number,\n ): string => {\n logger.silly(`Formatting ${isSection(item) ? \"section\" : \"item\"} Item: %s`, stringifyJSON(item));\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n logger.silly(`\\t\\tCurrent section depth: ${currentSectionDepth}`);\n\n let result: string = \"\";\n if (isSection(item)) {\n result = formatSection(item, currentSectionDepth + 1);\n } else if (isWeighted(item)) {\n result = item.text;\n } else {\n //If the item is neither a section nor a weighted item, it is empty.\n result = '';\n }\n return result;\n }\n\n const formatSection = <T extends Weighted>(section: Section<T>, sectionDepth?: number): string => {\n logger.silly(`Formatting section`);\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n logger.silly(`\\t\\tCurrent section depth: ${currentSectionDepth}`);\n\n if (section) {\n const formattedItems = section.items.map(item => format(item, currentSectionDepth)).join(\"\\n\\n\");\n\n if (formatOptions.sectionSeparator === \"tag\") {\n return `<${section.title ?? \"section\"}>\\n${formattedItems}\\n</${section.title ?? \"section\"}>`;\n } else {\n // Use the current section depth for heading level\n const headingLevel = currentSectionDepth;\n const hashes = '#'.repeat(headingLevel);\n logger.silly(`\\t\\tHeading level: ${headingLevel}`);\n logger.silly(`\\t\\tSection title: ${section.title}`);\n return `${hashes} ${formatOptions.sectionTitlePrefix ? `${formatOptions.sectionTitlePrefix} ${formatOptions.sectionTitleSeparator} ` : \"\"}${section.title}\\n\\n${formattedItems}`;\n }\n } else {\n return '';\n }\n }\n\n // Helper function to format arrays of items or sections\n const formatArray = <T extends Weighted>(\n items: (T | Section<T>)[],\n sectionDepth?: number\n ): string => {\n logger.silly(`Formatting array`);\n const currentSectionDepth = sectionDepth ?? formatOptions.sectionDepth;\n return items.map(item => format(item, currentSectionDepth)).join(\"\\n\\n\");\n }\n\n const formatPrompt = (model: Model, prompt: Prompt): Chat.Request => {\n logger.silly('Formatting prompt');\n const chatRequest: Chat.Request = Chat.createRequest(model);\n\n // --- System/Role Message Construction ---\n // Collect sections that belong in the system/developer prompt (Persona, Tone, Constraints, etc.)\n const systemSections: Section<Instruction>[] = [];\n if (prompt.persona) systemSections.push(prompt.persona);\n if (prompt.tone) systemSections.push(prompt.tone);\n if (prompt.constraints) systemSections.push(prompt.constraints);\n if (prompt.safeguards) systemSections.push(prompt.safeguards);\n if (prompt.responseFormat) systemSections.push(prompt.responseFormat);\n\n if (systemSections.length > 0) {\n // Combine all system sections into one system message content\n const systemContent = systemSections\n .map(section => formatSection(section))\n .join('\\n\\n');\n \n chatRequest.addMessage({\n role: getPersonaRole(model),\n content: systemContent\n });\n }\n\n // --- User/Task Message Construction ---\n // Logical flow: Context -> Examples -> Instructions -> Content -> Reasoning -> Recap\n // This structure guides the model through the context and examples before presenting the core task\n const userSections: (Section<any> | undefined)[] = [\n prompt.contexts,\n prompt.examples,\n prompt.instructions,\n prompt.contents,\n prompt.reasoning,\n prompt.recap\n ];\n\n let formattedUserContent = \"\";\n \n for (const section of userSections) {\n if (section) {\n formattedUserContent += formatSection(section) + '\\n\\n';\n }\n }\n\n // Ensure we always have a user message, or if we have content to send\n if (formattedUserContent.trim().length > 0 || systemSections.length === 0) {\n chatRequest.addMessage({\n role: \"user\",\n content: formattedUserContent.trim() || \" \", // Empty user message if needed (though usually not ideal)\n });\n }\n\n if (prompt.schema) {\n chatRequest.responseFormat = prompt.schema;\n }\n\n if (prompt.validator) {\n chatRequest.validator = prompt.validator;\n }\n\n return chatRequest;\n }\n\n return {\n formatPersona,\n format,\n formatPrompt,\n formatArray,\n }\n}\n"],"names":["SectionSeparatorSchema","z","enum","SectionTitlePropertySchema","FormatOptionsSchema","object","sectionSeparator","sectionIndentation","boolean","sectionTitleProperty","sectionTitlePrefix","string","optional","sectionTitleSeparator","sectionDepth","number","default","OptionSchema","logger","any","DEFAULT_LOGGER","formatOptions","partial","DEFAULT_FORMAT_OPTIONS","isSection","obj","Array","isArray","items","isWeighted","create","formatterOptions","options","parse","wrapLogger","clean","formatPersona","model","persona","silly","formattedPersona","formatSection","role","getPersonaRole","content","Error","format","item","stringifyJSON","currentSectionDepth","result","text","section","formattedItems","map","join","title","headingLevel","hashes","repeat","formatArray","formatPrompt","prompt","chatRequest","Chat","systemSections","push","tone","constraints","safeguards","responseFormat","length","systemContent","addMessage","userSections","contexts","examples","instructions","contents","reasoning","recap","formattedUserContent","trim","schema","validator"],"mappings":";;;;;;AAWO,MAAMA,sBAAAA,GAAyBC,CAAAA,CAAEC,IAAI,CAAC;AAAC,IAAA,KAAA;AAAO,IAAA;CAAW;AACzD,MAAMC,0BAAAA,GAA6BF,CAAAA,CAAEC,IAAI,CAAC;AAAC,IAAA,OAAA;AAAS,IAAA;CAAO;AAM3D,MAAME,mBAAAA,GAAsBH,CAAAA,CAAEI,MAAM,CAAC;IACxCC,gBAAAA,EAAkBN,sBAAAA;AAClBO,IAAAA,kBAAAA,EAAoBN,EAAEO,OAAO,EAAA;IAC7BC,oBAAAA,EAAsBN,0BAAAA;IACtBO,kBAAAA,EAAoBT,CAAAA,CAAEU,MAAM,EAAA,CAAGC,QAAQ,EAAA;IACvCC,qBAAAA,EAAuBZ,CAAAA,CAAEU,MAAM,EAAA,CAAGC,QAAQ,EAAA;AAC1CE,IAAAA,YAAAA,EAAcb,CAAAA,CAAEc,MAAM,EAAA,CAAGC,OAAO,CAAC,CAAA;AACrC,CAAA;AAKO,MAAMC,YAAAA,GAAehB,CAAAA,CAAEI,MAAM,CAAC;AACjCa,IAAAA,MAAAA,EAAQjB,EAAEkB,GAAG,EAAA,CAAGP,QAAQ,EAAA,CAAGI,OAAO,CAACI,cAAAA,CAAAA;AACnCC,IAAAA,aAAAA,EAAejB,oBAAoBkB,OAAO,EAAA,CAAGV,QAAQ,EAAA,CAAGI,OAAO,CAACO,sBAAAA;AACpE,CAAA;AAaA;AACA,SAASC,UAA8BC,GAAmB,EAAA;IACtD,OAAOA,GAAAA,IAAO,OAAOA,GAAAA,KAAQ,QAAA,IAAY,OAAA,IAAWA,GAAAA,IAAOC,KAAAA,CAAMC,OAAO,CAAC,GAACF,CAAmBG,KAAK,CAAA;AACtG;AAEA;AACA,SAASC,WAA+BJ,GAAmB,EAAA;AACvD,IAAA,OAAOA,GAAAA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CAAOc,QAAQ;AACfd,YAAAA,MAAAA,CAAOe,YAAY;AACnBf,YAAAA,MAAAA,CAAOgB,QAAQ;AACfhB,YAAAA,MAAAA,CAAOiB,SAAS;AAChBjB,YAAAA,MAAAA,CAAOkB;AACV,SAAA;AAED,QAAA,IAAIC,oBAAAA,GAAuB,EAAA;QAE3B,KAAK,MAAM7B,WAAWsB,YAAAA,CAAc;AAChC,YAAA,IAAItB,OAAAA,EAAS;AACT6B,gBAAAA,oBAAAA,IAAwBxC,cAAcW,OAAAA,CAAAA,GAAW,MAAA;AACrD,YAAA;AACJ,QAAA;;QAGA,IAAI6B,oBAAAA,CAAqBC,IAAI,EAAA,CAAGX,MAAM,GAAG,CAAA,IAAKN,cAAAA,CAAeM,MAAM,KAAK,CAAA,EAAG;AACvER,YAAAA,WAAAA,CAAYU,UAAU,CAAC;gBACnB/B,IAAAA,EAAM,MAAA;gBACNE,OAAAA,EAASqC,oBAAAA,CAAqBC,IAAI,EAAA,IAAM;AAC5C,aAAA,CAAA;AACJ,QAAA;QAEA,IAAIpB,MAAAA,CAAOqB,MAAM,EAAE;YACfpB,WAAAA,CAAYO,cAAc,GAAGR,MAAAA,CAAOqB,MAAM;AAC9C,QAAA;QAEA,IAAIrB,MAAAA,CAAOsB,SAAS,EAAE;YAClBrB,WAAAA,CAAYqB,SAAS,GAAGtB,MAAAA,CAAOsB,SAAS;AAC5C,QAAA;QAEA,OAAOrB,WAAAA;AACX,IAAA,CAAA;IAEA,OAAO;AACH3B,QAAAA,aAAAA;AACAU,QAAAA,MAAAA;AACAe,QAAAA,YAAAA;AACAD,QAAAA;AACJ,KAAA;AACJ;;;;"}
|
package/dist/prompt.d.ts
CHANGED
|
@@ -7,10 +7,28 @@ export interface Prompt {
|
|
|
7
7
|
instructions: Section<Instruction>;
|
|
8
8
|
contents?: Section<Content>;
|
|
9
9
|
contexts?: Section<Context>;
|
|
10
|
+
constraints?: Section<Instruction>;
|
|
11
|
+
tone?: Section<Instruction>;
|
|
12
|
+
examples?: Section<Content>;
|
|
13
|
+
reasoning?: Section<Instruction>;
|
|
14
|
+
responseFormat?: Section<Instruction>;
|
|
15
|
+
recap?: Section<Instruction>;
|
|
16
|
+
safeguards?: Section<Instruction>;
|
|
17
|
+
schema?: any;
|
|
18
|
+
validator?: any;
|
|
10
19
|
}
|
|
11
|
-
export declare const create: ({ persona, instructions, contents, contexts, }: {
|
|
20
|
+
export declare const create: ({ persona, instructions, contents, contexts, constraints, tone, examples, reasoning, responseFormat, recap, safeguards, schema, validator, }: {
|
|
12
21
|
persona?: Section<Instruction>;
|
|
13
22
|
instructions: Section<Instruction>;
|
|
14
23
|
contents?: Section<Content>;
|
|
15
24
|
contexts?: Section<Context>;
|
|
25
|
+
constraints?: Section<Instruction>;
|
|
26
|
+
tone?: Section<Instruction>;
|
|
27
|
+
examples?: Section<Content>;
|
|
28
|
+
reasoning?: Section<Instruction>;
|
|
29
|
+
responseFormat?: Section<Instruction>;
|
|
30
|
+
recap?: Section<Instruction>;
|
|
31
|
+
safeguards?: Section<Instruction>;
|
|
32
|
+
schema?: any;
|
|
33
|
+
validator?: any;
|
|
16
34
|
}) => Prompt;
|
package/dist/prompt.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
const create = ({ persona, instructions, contents, contexts })=>{
|
|
1
|
+
const create = ({ persona, instructions, contents, contexts, constraints, tone, examples, reasoning, responseFormat, recap, safeguards, schema, validator })=>{
|
|
2
2
|
return {
|
|
3
3
|
persona,
|
|
4
4
|
instructions,
|
|
5
5
|
contents,
|
|
6
|
-
contexts
|
|
6
|
+
contexts,
|
|
7
|
+
constraints,
|
|
8
|
+
tone,
|
|
9
|
+
examples,
|
|
10
|
+
reasoning,
|
|
11
|
+
responseFormat,
|
|
12
|
+
recap,
|
|
13
|
+
safeguards,
|
|
14
|
+
schema,
|
|
15
|
+
validator
|
|
7
16
|
};
|
|
8
17
|
};
|
|
9
18
|
|
package/dist/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sources":["../src/prompt.ts"],"sourcesContent":["import { Content } from \"./items/content\";\nimport { Context } from \"./items/context\";\nimport { Instruction } from \"./items/instruction\";\nimport { Section } from \"./items/section\";\n\nexport interface Prompt {\n persona?: Section<Instruction>;\n instructions: Section<Instruction>;\n contents?: Section<Content>;\n contexts?: Section<Context>;\n}\n\nexport const create = ({\n persona,\n instructions,\n contents,\n contexts,\n}: {\n persona?: Section<Instruction>,\n instructions: Section<Instruction>,\n contents?: Section<Content>,\n contexts?: Section<Context
|
|
1
|
+
{"version":3,"file":"prompt.js","sources":["../src/prompt.ts"],"sourcesContent":["import { Content } from \"./items/content\";\nimport { Context } from \"./items/context\";\nimport { Instruction } from \"./items/instruction\";\nimport { Section } from \"./items/section\";\n\nexport interface Prompt {\n persona?: Section<Instruction>;\n instructions: Section<Instruction>;\n contents?: Section<Content>;\n contexts?: Section<Context>;\n \n // Extended sections for advanced prompting\n constraints?: Section<Instruction>;\n tone?: Section<Instruction>;\n examples?: Section<Content>;\n reasoning?: Section<Instruction>;\n responseFormat?: Section<Instruction>;\n recap?: Section<Instruction>;\n safeguards?: Section<Instruction>;\n schema?: any; // JSON Schema for the provider\n validator?: any; // Zod schema for validation\n}\n\nexport const create = ({\n persona,\n instructions,\n contents,\n contexts,\n constraints,\n tone,\n examples,\n reasoning,\n responseFormat,\n recap,\n safeguards,\n schema,\n validator,\n}: {\n persona?: Section<Instruction>,\n instructions: Section<Instruction>,\n contents?: Section<Content>,\n contexts?: Section<Context>,\n constraints?: Section<Instruction>,\n tone?: Section<Instruction>,\n examples?: Section<Content>,\n reasoning?: Section<Instruction>,\n responseFormat?: Section<Instruction>,\n recap?: Section<Instruction>,\n safeguards?: Section<Instruction>,\n schema?: any,\n validator?: any,\n}): Prompt => {\n\n return {\n persona,\n instructions,\n contents,\n contexts,\n constraints,\n tone,\n examples,\n reasoning,\n responseFormat,\n recap,\n safeguards,\n schema,\n validator,\n }\n}"],"names":["create","persona","instructions","contents","contexts","constraints","tone","examples","reasoning","responseFormat","recap","safeguards","schema","validator"],"mappings":"AAuBO,MAAMA,MAAAA,GAAS,CAAC,EACnBC,OAAO,EACPC,YAAY,EACZC,QAAQ,EACRC,QAAQ,EACRC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,SAAS,EACTC,cAAc,EACdC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,SAAS,EAeZ,GAAA;IAEG,OAAO;AACHZ,QAAAA,OAAAA;AACAC,QAAAA,YAAAA;AACAC,QAAAA,QAAAA;AACAC,QAAAA,QAAAA;AACAC,QAAAA,WAAAA;AACAC,QAAAA,IAAAA;AACAC,QAAAA,QAAAA;AACAC,QAAAA,SAAAA;AACAC,QAAAA,cAAAA;AACAC,QAAAA,KAAAA;AACAC,QAAAA,UAAAA;AACAC,QAAAA,MAAAA;AACAC,QAAAA;AACJ,KAAA;AACJ;;;;"}
|
package/dist/recipes.d.ts
CHANGED
|
@@ -76,6 +76,98 @@ declare const RecipeConfigSchema: z.ZodObject<{
|
|
|
76
76
|
title: z.ZodOptional<z.ZodString>;
|
|
77
77
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
78
78
|
}, z.core.$strip>]>>>>;
|
|
79
|
+
constraints: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
80
|
+
content: z.ZodString;
|
|
81
|
+
title: z.ZodOptional<z.ZodString>;
|
|
82
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
+
path: z.ZodString;
|
|
85
|
+
title: z.ZodOptional<z.ZodString>;
|
|
86
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
88
|
+
directories: z.ZodArray<z.ZodString>;
|
|
89
|
+
title: z.ZodOptional<z.ZodString>;
|
|
90
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
}, z.core.$strip>]>>>>;
|
|
92
|
+
tone: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
93
|
+
content: z.ZodString;
|
|
94
|
+
title: z.ZodOptional<z.ZodString>;
|
|
95
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
97
|
+
path: z.ZodString;
|
|
98
|
+
title: z.ZodOptional<z.ZodString>;
|
|
99
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
101
|
+
directories: z.ZodArray<z.ZodString>;
|
|
102
|
+
title: z.ZodOptional<z.ZodString>;
|
|
103
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
104
|
+
}, z.core.$strip>]>>>>;
|
|
105
|
+
examples: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
106
|
+
content: z.ZodString;
|
|
107
|
+
title: z.ZodOptional<z.ZodString>;
|
|
108
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
110
|
+
path: z.ZodString;
|
|
111
|
+
title: z.ZodOptional<z.ZodString>;
|
|
112
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
114
|
+
directories: z.ZodArray<z.ZodString>;
|
|
115
|
+
title: z.ZodOptional<z.ZodString>;
|
|
116
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
117
|
+
}, z.core.$strip>]>>>>;
|
|
118
|
+
reasoning: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
119
|
+
content: z.ZodString;
|
|
120
|
+
title: z.ZodOptional<z.ZodString>;
|
|
121
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
123
|
+
path: z.ZodString;
|
|
124
|
+
title: z.ZodOptional<z.ZodString>;
|
|
125
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
126
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
127
|
+
directories: z.ZodArray<z.ZodString>;
|
|
128
|
+
title: z.ZodOptional<z.ZodString>;
|
|
129
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
}, z.core.$strip>]>>>>;
|
|
131
|
+
responseFormat: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
132
|
+
content: z.ZodString;
|
|
133
|
+
title: z.ZodOptional<z.ZodString>;
|
|
134
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
136
|
+
path: z.ZodString;
|
|
137
|
+
title: z.ZodOptional<z.ZodString>;
|
|
138
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
directories: z.ZodArray<z.ZodString>;
|
|
141
|
+
title: z.ZodOptional<z.ZodString>;
|
|
142
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strip>]>>>>;
|
|
144
|
+
recap: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
145
|
+
content: z.ZodString;
|
|
146
|
+
title: z.ZodOptional<z.ZodString>;
|
|
147
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
148
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
149
|
+
path: z.ZodString;
|
|
150
|
+
title: z.ZodOptional<z.ZodString>;
|
|
151
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
153
|
+
directories: z.ZodArray<z.ZodString>;
|
|
154
|
+
title: z.ZodOptional<z.ZodString>;
|
|
155
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
}, z.core.$strip>]>>>>;
|
|
157
|
+
safeguards: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
158
|
+
content: z.ZodString;
|
|
159
|
+
title: z.ZodOptional<z.ZodString>;
|
|
160
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
162
|
+
path: z.ZodString;
|
|
163
|
+
title: z.ZodOptional<z.ZodString>;
|
|
164
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
166
|
+
directories: z.ZodArray<z.ZodString>;
|
|
167
|
+
title: z.ZodOptional<z.ZodString>;
|
|
168
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
}, z.core.$strip>]>>>>;
|
|
170
|
+
schema: z.ZodOptional<z.ZodAny>;
|
|
79
171
|
extends: z.ZodOptional<z.ZodString>;
|
|
80
172
|
template: z.ZodOptional<z.ZodString>;
|
|
81
173
|
tools: z.ZodOptional<z.ZodAny>;
|
|
@@ -110,6 +202,14 @@ export interface TemplateConfig {
|
|
|
110
202
|
instructions?: ContentItem[];
|
|
111
203
|
content?: ContentItem[];
|
|
112
204
|
context?: ContentItem[];
|
|
205
|
+
constraints?: ContentItem[];
|
|
206
|
+
tone?: ContentItem[];
|
|
207
|
+
examples?: ContentItem[];
|
|
208
|
+
reasoning?: ContentItem[];
|
|
209
|
+
responseFormat?: ContentItem[];
|
|
210
|
+
recap?: ContentItem[];
|
|
211
|
+
safeguards?: ContentItem[];
|
|
212
|
+
schema?: string | Record<string, any> | z.ZodType<any>;
|
|
113
213
|
tools?: Tool[] | ToolRegistry;
|
|
114
214
|
toolGuidance?: Partial<ToolGuidanceConfig> | 'auto' | 'minimal' | 'detailed';
|
|
115
215
|
}
|
|
@@ -154,6 +254,14 @@ export declare const recipe: (basePath: string) => {
|
|
|
154
254
|
instructions: (...instructions: ContentItem[]) => /*elided*/ any;
|
|
155
255
|
content: (...content: ContentItem[]) => /*elided*/ any;
|
|
156
256
|
context: (...context: ContentItem[]) => /*elided*/ any;
|
|
257
|
+
constraints: (...constraints: ContentItem[]) => /*elided*/ any;
|
|
258
|
+
tone: (...tone: ContentItem[]) => /*elided*/ any;
|
|
259
|
+
examples: (...examples: ContentItem[]) => /*elided*/ any;
|
|
260
|
+
reasoning: (...reasoning: ContentItem[]) => /*elided*/ any;
|
|
261
|
+
responseFormat: (...responseFormat: ContentItem[]) => /*elided*/ any;
|
|
262
|
+
recap: (...recap: ContentItem[]) => /*elided*/ any;
|
|
263
|
+
safeguards: (...safeguards: ContentItem[]) => /*elided*/ any;
|
|
264
|
+
schema: (schema: string | Record<string, any> | z.ZodType<any>) => /*elided*/ any;
|
|
157
265
|
parameters: (parameters: any) => /*elided*/ any;
|
|
158
266
|
overrides: (enabled: boolean) => /*elided*/ any;
|
|
159
267
|
overridePaths: (paths: string[]) => /*elided*/ any;
|
package/dist/recipes.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import path__default from 'path';
|
|
2
|
+
import fs__default from 'fs/promises';
|
|
2
3
|
import { z } from 'zod';
|
|
4
|
+
import zodToJsonSchema from 'zod-to-json-schema';
|
|
3
5
|
import { ConversationBuilder } from './conversation.js';
|
|
4
6
|
import { ParametersSchema } from './items/parameters.js';
|
|
5
7
|
import { DEFAULT_LOGGER, wrapLogger } from './logger.js';
|
|
@@ -51,6 +53,15 @@ const RecipeConfigSchema = z.object({
|
|
|
51
53
|
instructions: z.array(ContentItemSchema).optional().default([]),
|
|
52
54
|
content: z.array(ContentItemSchema).optional().default([]),
|
|
53
55
|
context: z.array(ContentItemSchema).optional().default([]),
|
|
56
|
+
// Advanced prompting sections
|
|
57
|
+
constraints: z.array(ContentItemSchema).optional().default([]),
|
|
58
|
+
tone: z.array(ContentItemSchema).optional().default([]),
|
|
59
|
+
examples: z.array(ContentItemSchema).optional().default([]),
|
|
60
|
+
reasoning: z.array(ContentItemSchema).optional().default([]),
|
|
61
|
+
responseFormat: z.array(ContentItemSchema).optional().default([]),
|
|
62
|
+
recap: z.array(ContentItemSchema).optional().default([]),
|
|
63
|
+
safeguards: z.array(ContentItemSchema).optional().default([]),
|
|
64
|
+
schema: z.any().optional(),
|
|
54
65
|
// Templates and inheritance
|
|
55
66
|
extends: z.string().optional(),
|
|
56
67
|
template: z.string().optional(),
|
|
@@ -216,6 +227,13 @@ const cook = async (config)=>{
|
|
|
216
227
|
instructions: [],
|
|
217
228
|
content: [],
|
|
218
229
|
context: [],
|
|
230
|
+
constraints: [],
|
|
231
|
+
tone: [],
|
|
232
|
+
examples: [],
|
|
233
|
+
reasoning: [],
|
|
234
|
+
responseFormat: [],
|
|
235
|
+
recap: [],
|
|
236
|
+
safeguards: [],
|
|
219
237
|
...config
|
|
220
238
|
});
|
|
221
239
|
// Handle template inheritance
|
|
@@ -239,7 +257,36 @@ const cook = async (config)=>{
|
|
|
239
257
|
context: [
|
|
240
258
|
...template.context || [],
|
|
241
259
|
...validatedConfig.context || []
|
|
242
|
-
]
|
|
260
|
+
],
|
|
261
|
+
constraints: [
|
|
262
|
+
...template.constraints || [],
|
|
263
|
+
...validatedConfig.constraints || []
|
|
264
|
+
],
|
|
265
|
+
tone: [
|
|
266
|
+
...template.tone || [],
|
|
267
|
+
...validatedConfig.tone || []
|
|
268
|
+
],
|
|
269
|
+
examples: [
|
|
270
|
+
...template.examples || [],
|
|
271
|
+
...validatedConfig.examples || []
|
|
272
|
+
],
|
|
273
|
+
reasoning: [
|
|
274
|
+
...template.reasoning || [],
|
|
275
|
+
...validatedConfig.reasoning || []
|
|
276
|
+
],
|
|
277
|
+
responseFormat: [
|
|
278
|
+
...template.responseFormat || [],
|
|
279
|
+
...validatedConfig.responseFormat || []
|
|
280
|
+
],
|
|
281
|
+
recap: [
|
|
282
|
+
...template.recap || [],
|
|
283
|
+
...validatedConfig.recap || []
|
|
284
|
+
],
|
|
285
|
+
safeguards: [
|
|
286
|
+
...template.safeguards || [],
|
|
287
|
+
...validatedConfig.safeguards || []
|
|
288
|
+
],
|
|
289
|
+
schema: validatedConfig.schema || template.schema
|
|
243
290
|
};
|
|
244
291
|
}
|
|
245
292
|
}
|
|
@@ -271,6 +318,39 @@ const cook = async (config)=>{
|
|
|
271
318
|
const contextSection = create$3({
|
|
272
319
|
title: "Context"
|
|
273
320
|
});
|
|
321
|
+
// Advanced sections
|
|
322
|
+
const constraintSection = create$3({
|
|
323
|
+
title: "Constraints"
|
|
324
|
+
});
|
|
325
|
+
const toneSection = create$3({
|
|
326
|
+
title: "Tone"
|
|
327
|
+
});
|
|
328
|
+
const exampleSection = create$3({
|
|
329
|
+
title: "Examples"
|
|
330
|
+
});
|
|
331
|
+
const reasoningSection = create$3({
|
|
332
|
+
title: "Reasoning"
|
|
333
|
+
});
|
|
334
|
+
const responseFormatSection = create$3({
|
|
335
|
+
title: "Response Format"
|
|
336
|
+
});
|
|
337
|
+
const recapSection = create$3({
|
|
338
|
+
title: "Recap"
|
|
339
|
+
});
|
|
340
|
+
const safeguardSection = create$3({
|
|
341
|
+
title: "Safeguards"
|
|
342
|
+
});
|
|
343
|
+
// Helper for processing list items
|
|
344
|
+
const processList = async (items, section, type)=>{
|
|
345
|
+
for (const item of items){
|
|
346
|
+
await processContentItem(item, section, type, {
|
|
347
|
+
basePath: finalConfig.basePath,
|
|
348
|
+
parser: parser$1,
|
|
349
|
+
override: override$1,
|
|
350
|
+
loader: loader$1,
|
|
351
|
+
parameters: finalConfig.parameters});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
274
354
|
// Process persona
|
|
275
355
|
if (finalConfig.persona) {
|
|
276
356
|
await processContentItem(finalConfig.persona, personaSection, 'persona', {
|
|
@@ -280,15 +360,18 @@ const cook = async (config)=>{
|
|
|
280
360
|
loader: loader$1,
|
|
281
361
|
parameters: finalConfig.parameters});
|
|
282
362
|
}
|
|
283
|
-
// Process
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
363
|
+
// Process standard sections
|
|
364
|
+
await processList(finalConfig.instructions || [], instructionSection, 'instruction');
|
|
365
|
+
await processList(finalConfig.content || [], contentSection, 'content');
|
|
366
|
+
await processList(finalConfig.context || [], contextSection, 'context');
|
|
367
|
+
// Process advanced sections
|
|
368
|
+
await processList(finalConfig.constraints || [], constraintSection, 'instruction');
|
|
369
|
+
await processList(finalConfig.tone || [], toneSection, 'instruction');
|
|
370
|
+
await processList(finalConfig.examples || [], exampleSection, 'content');
|
|
371
|
+
await processList(finalConfig.reasoning || [], reasoningSection, 'instruction');
|
|
372
|
+
await processList(finalConfig.responseFormat || [], responseFormatSection, 'instruction');
|
|
373
|
+
await processList(finalConfig.recap || [], recapSection, 'instruction');
|
|
374
|
+
await processList(finalConfig.safeguards || [], safeguardSection, 'instruction');
|
|
292
375
|
// Generate tool guidance if tools are provided
|
|
293
376
|
if (finalConfig.tools) {
|
|
294
377
|
const tools = Array.isArray(finalConfig.tools) ? finalConfig.tools : finalConfig.tools.getAll();
|
|
@@ -302,30 +385,59 @@ const cook = async (config)=>{
|
|
|
302
385
|
instructionSection.add(toolSection);
|
|
303
386
|
}
|
|
304
387
|
}
|
|
305
|
-
// Process
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
388
|
+
// Process schema
|
|
389
|
+
let schema = finalConfig.schema;
|
|
390
|
+
let validator = undefined;
|
|
391
|
+
if (schema instanceof z.ZodType) {
|
|
392
|
+
var _jsonSchema_definitions;
|
|
393
|
+
// It's a Zod schema!
|
|
394
|
+
validator = schema;
|
|
395
|
+
const jsonSchema = zodToJsonSchema(schema, "response");
|
|
396
|
+
// Wrap in OpenAI Structured Output format
|
|
397
|
+
// zod-to-json-schema returns { "$schema": "...", "definitions": { "response": { ... } }, "$ref": "#/definitions/response" }
|
|
398
|
+
// We need to extract the schema part.
|
|
399
|
+
// Simpler usage for OpenAI: just get the schema object.
|
|
400
|
+
// Actually, zod-to-json-schema produces a full JSON schema object.
|
|
401
|
+
// OpenAI expects: { type: "json_schema", json_schema: { name: "...", schema: ... } }
|
|
402
|
+
// Let's create a clean schema object
|
|
403
|
+
// NOTE: OpenAI requires strict: true and additionalProperties: false
|
|
404
|
+
// zod-to-json-schema generally produces compatible schemas but strictness might need tweaking if required by OpenAI.
|
|
405
|
+
// For now, let's assume "response" as the name.
|
|
406
|
+
// We'll define a simpler conversion if possible, or trust the user to configure Zod strictly if they want strict mode.
|
|
407
|
+
// Extract the definition if it exists
|
|
408
|
+
const actualSchema = ((_jsonSchema_definitions = jsonSchema.definitions) === null || _jsonSchema_definitions === void 0 ? void 0 : _jsonSchema_definitions.response) || jsonSchema;
|
|
409
|
+
schema = {
|
|
410
|
+
type: "json_schema",
|
|
411
|
+
json_schema: {
|
|
412
|
+
name: "response",
|
|
413
|
+
schema: actualSchema,
|
|
414
|
+
strict: true // Try to enable strict mode for OpenAI
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
} else if (typeof schema === 'string') {
|
|
418
|
+
const schemaPath = path__default.resolve(finalConfig.basePath, schema);
|
|
419
|
+
try {
|
|
420
|
+
const schemaContent = await fs__default.readFile(schemaPath, 'utf-8');
|
|
421
|
+
schema = JSON.parse(schemaContent);
|
|
422
|
+
} catch (e) {
|
|
423
|
+
throw new Error(`Failed to load schema from ${schemaPath}: ${e.message}`);
|
|
424
|
+
}
|
|
322
425
|
}
|
|
323
426
|
// Build and return prompt
|
|
324
427
|
return create$4({
|
|
325
|
-
persona: personaSection,
|
|
428
|
+
persona: personaSection.items.length > 0 ? personaSection : undefined,
|
|
326
429
|
instructions: instructionSection,
|
|
327
|
-
contents: contentSection,
|
|
328
|
-
contexts: contextSection
|
|
430
|
+
contents: contentSection.items.length > 0 ? contentSection : undefined,
|
|
431
|
+
contexts: contextSection.items.length > 0 ? contextSection : undefined,
|
|
432
|
+
constraints: constraintSection.items.length > 0 ? constraintSection : undefined,
|
|
433
|
+
tone: toneSection.items.length > 0 ? toneSection : undefined,
|
|
434
|
+
examples: exampleSection.items.length > 0 ? exampleSection : undefined,
|
|
435
|
+
reasoning: reasoningSection.items.length > 0 ? reasoningSection : undefined,
|
|
436
|
+
responseFormat: responseFormatSection.items.length > 0 ? responseFormatSection : undefined,
|
|
437
|
+
recap: recapSection.items.length > 0 ? recapSection : undefined,
|
|
438
|
+
safeguards: safeguardSection.items.length > 0 ? safeguardSection : undefined,
|
|
439
|
+
schema,
|
|
440
|
+
validator
|
|
329
441
|
});
|
|
330
442
|
};
|
|
331
443
|
const processContentItem = async (item, section, type, ctx)=>{
|
|
@@ -403,6 +515,59 @@ const recipe = (basePath)=>{
|
|
|
403
515
|
];
|
|
404
516
|
return builder;
|
|
405
517
|
},
|
|
518
|
+
constraints: (...constraints)=>{
|
|
519
|
+
config.constraints = [
|
|
520
|
+
...config.constraints || [],
|
|
521
|
+
...constraints
|
|
522
|
+
];
|
|
523
|
+
return builder;
|
|
524
|
+
},
|
|
525
|
+
tone: (...tone)=>{
|
|
526
|
+
config.tone = [
|
|
527
|
+
...config.tone || [],
|
|
528
|
+
...tone
|
|
529
|
+
];
|
|
530
|
+
return builder;
|
|
531
|
+
},
|
|
532
|
+
examples: (...examples)=>{
|
|
533
|
+
config.examples = [
|
|
534
|
+
...config.examples || [],
|
|
535
|
+
...examples
|
|
536
|
+
];
|
|
537
|
+
return builder;
|
|
538
|
+
},
|
|
539
|
+
reasoning: (...reasoning)=>{
|
|
540
|
+
config.reasoning = [
|
|
541
|
+
...config.reasoning || [],
|
|
542
|
+
...reasoning
|
|
543
|
+
];
|
|
544
|
+
return builder;
|
|
545
|
+
},
|
|
546
|
+
responseFormat: (...responseFormat)=>{
|
|
547
|
+
config.responseFormat = [
|
|
548
|
+
...config.responseFormat || [],
|
|
549
|
+
...responseFormat
|
|
550
|
+
];
|
|
551
|
+
return builder;
|
|
552
|
+
},
|
|
553
|
+
recap: (...recap)=>{
|
|
554
|
+
config.recap = [
|
|
555
|
+
...config.recap || [],
|
|
556
|
+
...recap
|
|
557
|
+
];
|
|
558
|
+
return builder;
|
|
559
|
+
},
|
|
560
|
+
safeguards: (...safeguards)=>{
|
|
561
|
+
config.safeguards = [
|
|
562
|
+
...config.safeguards || [],
|
|
563
|
+
...safeguards
|
|
564
|
+
];
|
|
565
|
+
return builder;
|
|
566
|
+
},
|
|
567
|
+
schema: (schema)=>{
|
|
568
|
+
config.schema = schema;
|
|
569
|
+
return builder;
|
|
570
|
+
},
|
|
406
571
|
parameters: (parameters)=>{
|
|
407
572
|
config.parameters = {
|
|
408
573
|
...config.parameters,
|