@riotprompt/riotprompt 0.0.7 → 0.0.8

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/builder.d.ts CHANGED
@@ -4,22 +4,10 @@ import { Prompt } from './riotprompt';
4
4
  declare const OptionSchema: z.ZodObject<{
5
5
  logger: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
6
6
  basePath: z.ZodString;
7
- overridePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
7
+ overridePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
8
8
  overrides: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
9
- parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>>;
10
- }, "strip", z.ZodTypeAny, {
11
- parameters: Record<string, string | number | boolean | (string | number | boolean)[]>;
12
- overrides: boolean;
13
- basePath: string;
14
- overridePaths: string[];
15
- logger?: any;
16
- }, {
17
- basePath: string;
18
- parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
19
- logger?: any;
20
- overrides?: boolean | undefined;
21
- overridePaths?: string[] | undefined;
22
- }>;
9
+ parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
10
+ }, z.core.$strip>;
23
11
  export type Options = z.infer<typeof OptionSchema>;
24
12
  export type OptionsParam = Required<Pick<Options, 'basePath'>> & Partial<Omit<Options, 'basePath'>>;
25
13
  export interface Instance {
@@ -5,78 +5,48 @@ import { Section } from './items/section';
5
5
  import { Weighted } from './items/weighted';
6
6
  import { Prompt } from './prompt';
7
7
  import * as Chat from "./chat";
8
- export declare const SectionSeparatorSchema: z.ZodEnum<["tag", "markdown"]>;
9
- export declare const SectionTitlePropertySchema: z.ZodEnum<["title", "name"]>;
8
+ export declare const SectionSeparatorSchema: z.ZodEnum<{
9
+ tag: "tag";
10
+ markdown: "markdown";
11
+ }>;
12
+ export declare const SectionTitlePropertySchema: z.ZodEnum<{
13
+ title: "title";
14
+ name: "name";
15
+ }>;
10
16
  export type SectionSeparator = z.infer<typeof SectionSeparatorSchema>;
11
17
  export type SectionTitleProperty = z.infer<typeof SectionTitlePropertySchema>;
12
18
  export declare const FormatOptionsSchema: z.ZodObject<{
13
- sectionSeparator: z.ZodEnum<["tag", "markdown"]>;
19
+ sectionSeparator: z.ZodEnum<{
20
+ tag: "tag";
21
+ markdown: "markdown";
22
+ }>;
14
23
  sectionIndentation: z.ZodBoolean;
15
- sectionTitleProperty: z.ZodEnum<["title", "name"]>;
24
+ sectionTitleProperty: z.ZodEnum<{
25
+ title: "title";
26
+ name: "name";
27
+ }>;
16
28
  sectionTitlePrefix: z.ZodOptional<z.ZodString>;
17
29
  sectionTitleSeparator: z.ZodOptional<z.ZodString>;
18
30
  sectionDepth: z.ZodDefault<z.ZodNumber>;
19
- }, "strip", z.ZodTypeAny, {
20
- sectionSeparator: "tag" | "markdown";
21
- sectionIndentation: boolean;
22
- sectionTitleProperty: "title" | "name";
23
- sectionDepth: number;
24
- sectionTitlePrefix?: string | undefined;
25
- sectionTitleSeparator?: string | undefined;
26
- }, {
27
- sectionSeparator: "tag" | "markdown";
28
- sectionIndentation: boolean;
29
- sectionTitleProperty: "title" | "name";
30
- sectionTitlePrefix?: string | undefined;
31
- sectionTitleSeparator?: string | undefined;
32
- sectionDepth?: number | undefined;
33
- }>;
31
+ }, z.core.$strip>;
34
32
  export type FormatOptions = z.infer<typeof FormatOptionsSchema>;
35
33
  export declare const OptionSchema: z.ZodObject<{
36
34
  logger: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
37
35
  formatOptions: z.ZodDefault<z.ZodOptional<z.ZodObject<{
38
- sectionSeparator: z.ZodOptional<z.ZodEnum<["tag", "markdown"]>>;
36
+ sectionSeparator: z.ZodOptional<z.ZodEnum<{
37
+ tag: "tag";
38
+ markdown: "markdown";
39
+ }>>;
39
40
  sectionIndentation: z.ZodOptional<z.ZodBoolean>;
40
- sectionTitleProperty: z.ZodOptional<z.ZodEnum<["title", "name"]>>;
41
+ sectionTitleProperty: z.ZodOptional<z.ZodEnum<{
42
+ title: "title";
43
+ name: "name";
44
+ }>>;
41
45
  sectionTitlePrefix: z.ZodOptional<z.ZodOptional<z.ZodString>>;
42
46
  sectionTitleSeparator: z.ZodOptional<z.ZodOptional<z.ZodString>>;
43
47
  sectionDepth: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
44
- }, "strip", z.ZodTypeAny, {
45
- sectionSeparator?: "tag" | "markdown" | undefined;
46
- sectionIndentation?: boolean | undefined;
47
- sectionTitleProperty?: "title" | "name" | undefined;
48
- sectionTitlePrefix?: string | undefined;
49
- sectionTitleSeparator?: string | undefined;
50
- sectionDepth?: number | undefined;
51
- }, {
52
- sectionSeparator?: "tag" | "markdown" | undefined;
53
- sectionIndentation?: boolean | undefined;
54
- sectionTitleProperty?: "title" | "name" | undefined;
55
- sectionTitlePrefix?: string | undefined;
56
- sectionTitleSeparator?: string | undefined;
57
- sectionDepth?: number | undefined;
58
- }>>>;
59
- }, "strip", z.ZodTypeAny, {
60
- formatOptions: {
61
- sectionSeparator?: "tag" | "markdown" | undefined;
62
- sectionIndentation?: boolean | undefined;
63
- sectionTitleProperty?: "title" | "name" | undefined;
64
- sectionTitlePrefix?: string | undefined;
65
- sectionTitleSeparator?: string | undefined;
66
- sectionDepth?: number | undefined;
67
- };
68
- logger?: any;
69
- }, {
70
- logger?: any;
71
- formatOptions?: {
72
- sectionSeparator?: "tag" | "markdown" | undefined;
73
- sectionIndentation?: boolean | undefined;
74
- sectionTitleProperty?: "title" | "name" | undefined;
75
- sectionTitlePrefix?: string | undefined;
76
- sectionTitleSeparator?: string | undefined;
77
- sectionDepth?: number | undefined;
78
- } | undefined;
79
- }>;
48
+ }, z.core.$strip>>>;
49
+ }, z.core.$strip>;
80
50
  export type Options = z.infer<typeof OptionSchema>;
81
51
  export type OptionsParam = Partial<Options>;
82
52
  export interface Instance {
package/dist/formatter.js CHANGED
@@ -18,7 +18,7 @@ const FormatOptionsSchema = z.object({
18
18
  sectionTitleProperty: SectionTitlePropertySchema,
19
19
  sectionTitlePrefix: z.string().optional(),
20
20
  sectionTitleSeparator: z.string().optional(),
21
- sectionDepth: z.number().default(1)
21
+ sectionDepth: z.number().default(0)
22
22
  });
23
23
  const OptionSchema = z.object({
24
24
  logger: z.any().optional().default(DEFAULT_LOGGER),
@@ -79,7 +79,7 @@ const create = (formatterOptions)=>{
79
79
  var _section_title, _section_title1;
80
80
  return `<${(_section_title = section.title) !== null && _section_title !== void 0 ? _section_title : "section"}>\n${formattedItems}\n</${(_section_title1 = section.title) !== null && _section_title1 !== void 0 ? _section_title1 : "section"}>`;
81
81
  } else {
82
- // Default depth to 1 if not provided, resulting in H2 (##) matching the test case.
82
+ // Use the current section depth for heading level
83
83
  const headingLevel = currentSectionDepth;
84
84
  const hashes = '#'.repeat(headingLevel);
85
85
  logger.silly(`\t\tHeading level: ${headingLevel}`);
@@ -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(1),\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 // Default depth to 1 if not provided, resulting in H2 (##) matching the test case.\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,EAAsB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CAAC,CAAC3B,OAAAA,GAAAA;gBACtByB,WAAAA,CAAYG,UAAU,CAAC9B,aAAAA,CAAcC,KAAAA,EAAOC,OAAAA,CAAAA,CAAAA;AAChD,YAAA,CAAA,CAAA;AACJ,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 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,EAA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,KAAAA,EAAOC,OAAAA,CAAAA,CAAAA;AAChD,YAAA,CAAA,CAAA;AACJ,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,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export declare const ParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>;
2
+ export declare const ParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
3
3
  export type Parameters = z.infer<typeof ParametersSchema>;
4
4
  export declare const create: (parameters: Parameters) => Parameters;
5
5
  export declare const apply: (text: string, parameters?: Parameters) => string;
@@ -20,18 +20,8 @@ export declare const SectionOptionsSchema: z.ZodObject<{
20
20
  title: z.ZodOptional<z.ZodString>;
21
21
  weight: z.ZodOptional<z.ZodNumber>;
22
22
  itemWeight: z.ZodOptional<z.ZodNumber>;
23
- parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>>;
24
- }, "strip", z.ZodTypeAny, {
25
- parameters: Record<string, string | number | boolean | (string | number | boolean)[]>;
26
- weight?: number | undefined;
27
- title?: string | undefined;
28
- itemWeight?: number | undefined;
29
- }, {
30
- weight?: number | undefined;
31
- parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
32
- title?: string | undefined;
33
- itemWeight?: number | undefined;
34
- }>;
23
+ parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
24
+ }, z.core.$strip>;
35
25
  export type SectionOptions = z.infer<typeof SectionOptionsSchema>;
36
26
  export declare const isSection: (object: any) => boolean;
37
27
  export declare const convertToSection: (object: any, options?: Partial<SectionOptions>) => Section<Weighted>;
@@ -2,23 +2,11 @@ import { z } from 'zod';
2
2
  export declare const WeightedSchema: z.ZodObject<{
3
3
  text: z.ZodString;
4
4
  weight: z.ZodOptional<z.ZodNumber>;
5
- }, "strip", z.ZodTypeAny, {
6
- text: string;
7
- weight?: number | undefined;
8
- }, {
9
- text: string;
10
- weight?: number | undefined;
11
- }>;
5
+ }, z.core.$strip>;
12
6
  export type Weighted = z.infer<typeof WeightedSchema>;
13
7
  export declare const WeightedOptionsSchema: z.ZodObject<{
14
8
  weight: z.ZodOptional<z.ZodNumber>;
15
- parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>;
16
- }, "strip", z.ZodTypeAny, {
17
- weight?: number | undefined;
18
- parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
19
- }, {
20
- weight?: number | undefined;
21
- parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
22
- }>;
9
+ parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>;
10
+ }, z.core.$strip>;
23
11
  export type WeightedOptions = z.infer<typeof WeightedOptionsSchema>;
24
12
  export declare const create: <T extends Weighted>(text: string, options?: Partial<WeightedOptions>) => T;
package/dist/loader.d.ts CHANGED
@@ -3,17 +3,9 @@ import { SectionOptions } from './items/section';
3
3
  import { Section, Weighted } from './riotprompt';
4
4
  declare const OptionsSchema: z.ZodObject<{
5
5
  logger: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
6
- ignorePatterns: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
7
- parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>>;
8
- }, "strip", z.ZodTypeAny, {
9
- parameters: Record<string, string | number | boolean | (string | number | boolean)[]>;
10
- ignorePatterns: string[];
11
- logger?: any;
12
- }, {
13
- parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
14
- logger?: any;
15
- ignorePatterns?: string[] | undefined;
16
- }>;
6
+ ignorePatterns: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
7
+ parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
8
+ }, z.core.$strip>;
17
9
  export type Options = z.infer<typeof OptionsSchema>;
18
10
  export type OptionsParam = Partial<Options>;
19
11
  export interface Instance {
@@ -3,20 +3,10 @@ import { SectionOptions } from './items/section';
3
3
  import { Section, Weighted } from './riotprompt';
4
4
  declare const OptionsSchema: z.ZodObject<{
5
5
  logger: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
6
- configDirs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
6
+ configDirs: z.ZodDefault<z.ZodArray<z.ZodString>>;
7
7
  overrides: z.ZodDefault<z.ZodBoolean>;
8
- parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>>;
9
- }, "strip", z.ZodTypeAny, {
10
- parameters: Record<string, string | number | boolean | (string | number | boolean)[]>;
11
- configDirs: string[];
12
- overrides: boolean;
13
- logger?: any;
14
- }, {
15
- parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
16
- logger?: any;
17
- configDirs?: string[] | undefined;
18
- overrides?: boolean | undefined;
19
- }>;
8
+ parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
9
+ }, z.core.$strip>;
20
10
  export type Options = z.infer<typeof OptionsSchema>;
21
11
  export type OptionsParam = Partial<Options>;
22
12
  export interface Instance {
package/dist/parser.d.ts CHANGED
@@ -3,14 +3,8 @@ import { Section, SectionOptions } from './items/section';
3
3
  import { Weighted } from './items/weighted';
4
4
  declare const OptionsSchema: z.ZodObject<{
5
5
  logger: z.ZodDefault<z.ZodOptional<z.ZodAny>>;
6
- parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>>;
7
- }, "strip", z.ZodTypeAny, {
8
- parameters: Record<string, string | number | boolean | (string | number | boolean)[]>;
9
- logger?: any;
10
- }, {
11
- parameters?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
12
- logger?: any;
13
- }>;
6
+ parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
7
+ }, z.core.$strip>;
14
8
  export type Options = z.infer<typeof OptionsSchema>;
15
9
  export type OptionsParam = Partial<Options>;
16
10
  export interface Instance {