@promptbook/utils 0.67.9 → 0.68.0-1

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.
Files changed (82) hide show
  1. package/README.md +2 -2
  2. package/esm/index.es.js +44 -41
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +7 -16
  5. package/esm/typings/src/_packages/core.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +20 -24
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  8. package/esm/typings/src/commands/BLOCK/BlockTypes.d.ts +1 -1
  9. package/esm/typings/src/commands/BLOCK/blockCommandParser.d.ts +2 -2
  10. package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +14 -6
  11. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -2
  12. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +9 -0
  13. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +14 -0
  14. package/esm/typings/src/commands/{EXPECT/ExpectFormatCommand.d.ts → FORMAT/FormatCommand.d.ts} +2 -2
  15. package/esm/typings/src/commands/FORMAT/formatCommand.test.d.ts +1 -0
  16. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +9 -0
  17. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +2 -2
  18. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +2 -2
  19. package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -2
  20. package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +2 -2
  21. package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +2 -2
  22. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +2 -2
  23. package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +2 -2
  24. package/esm/typings/src/commands/URL/urlCommandParser.d.ts +2 -2
  25. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +2 -2
  26. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +2 -2
  27. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +6 -4
  28. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  29. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +137 -30
  30. package/esm/typings/src/commands/index.d.ts +1 -1
  31. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
  32. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -1
  33. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
  34. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -2
  35. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +14 -0
  36. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.test.d.ts +1 -0
  37. package/esm/typings/src/conversion/utils/extractVariables.d.ts +1 -1
  38. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  39. package/esm/typings/src/errors/{ParsingError.d.ts → ParseError.d.ts} +5 -2
  40. package/esm/typings/src/errors/index.d.ts +2 -2
  41. package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +5 -0
  42. package/esm/typings/src/execution/PromptResult.d.ts +2 -0
  43. package/esm/typings/src/execution/PromptResultUsage.d.ts +1 -1
  44. package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -1
  45. package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
  46. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -1
  47. package/esm/typings/src/postprocessing/utils/extractBlock.d.ts +2 -2
  48. package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +3 -3
  49. package/esm/typings/src/prepare/prepareTemplates.d.ts +3 -4
  50. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -1
  51. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -1
  52. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +1 -1
  53. package/esm/typings/src/types/ModelRequirements.d.ts +2 -0
  54. package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +13 -0
  55. package/esm/typings/src/types/PipelineJson/Expectations.d.ts +1 -1
  56. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +1 -1
  57. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  58. package/esm/typings/src/types/PipelineJson/{PromptTemplateParameterJson.d.ts → ParameterJson.d.ts} +2 -2
  59. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
  60. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +10 -5
  61. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  62. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +20 -9
  63. package/esm/typings/src/types/PipelineJson/{ScriptJson.d.ts → ScriptTemplateJson.d.ts} +4 -4
  64. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +3 -3
  65. package/esm/typings/src/types/PipelineJson/TemplateJson.d.ts +11 -0
  66. package/esm/typings/src/types/PipelineJson/{PromptTemplateJsonCommon.d.ts → TemplateJsonCommon.d.ts} +3 -4
  67. package/esm/typings/src/types/Prompt.d.ts +4 -2
  68. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -0
  69. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  70. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  71. package/esm/typings/src/utils/organization/___and___.d.ts +7 -0
  72. package/esm/typings/src/utils/organization/{___.d.ts → ___or___.d.ts} +1 -1
  73. package/esm/typings/src/utils/parseNumber.d.ts +1 -1
  74. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +1 -1
  75. package/package.json +1 -1
  76. package/umd/index.umd.js +44 -41
  77. package/umd/index.umd.js.map +1 -1
  78. package/esm/typings/src/commands/EXPECT/ExpectAmountCommand.d.ts +0 -17
  79. package/esm/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts +0 -14
  80. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +0 -27
  81. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +0 -14
  82. /package/esm/typings/src/{conversion/utils/extractParameterNamesFromPromptTemplate.test.d.ts → commands/FOREACH/foreachCommand.test.d.ts} +0 -0
@@ -1,15 +1,26 @@
1
- import type { ___ } from '../../utils/organization/___';
2
- import type { LlmTemplateJson } from './LlmTemplateJson';
3
- import type { PromptDialogJson } from './PromptDialogJson';
4
- import type { ScriptJson } from './ScriptJson';
5
- import type { SimpleTemplateJson } from './SimpleTemplateJson';
1
+ import type { ModelRequirements } from '../ModelRequirements';
2
+ import type { string_name } from '../typeAliases';
3
+ import type { TemplateJsonCommon } from './TemplateJsonCommon';
6
4
  /**
7
- * Describes one prompt template in the promptbook
5
+ * Template for prompt to LLM
8
6
  *
9
7
  * Note: [🚉] This is fully serializable as JSON
10
8
  */
11
- export type PromptTemplateJson = LlmTemplateJson | SimpleTemplateJson | ScriptJson | PromptDialogJson | ___ | ___ | ___ | ___;
9
+ export type PromptTemplateJson = TemplateJsonCommon & {
10
+ readonly blockType: 'PROMPT_TEMPLATE';
11
+ /**
12
+ * Name of the persona who will be responding to this prompt
13
+ */
14
+ readonly personaName?: string_name;
15
+ /**
16
+ * Requirements for the model
17
+ * - This is required only for blockType PROMPT_TEMPLATE
18
+ */
19
+ readonly modelRequirements?: Partial<ModelRequirements>;
20
+ };
12
21
  /**
13
- * TODO: [🧠][🥜] What is propper name for this - "Template", "Prompt template",...
14
- * TODO: [🧠][🥜] Reduce confusion of `PromptTemplateJson` vs (`LlmTemplateJson` which is 'PROMPT_TEMPLATE')
22
+ * TODO: [👙][🧠] Maybe add `knowledge`, `actions` and `instruments` to be available granularly for each template
23
+ * @see https://github.com/webgptorg/promptbook/discussions/79
24
+ * TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
25
+ * TODO: [🍙] Make some standard order of json properties
15
26
  */
@@ -1,13 +1,13 @@
1
1
  import type { ScriptLanguage } from '../ScriptLanguage';
2
- import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
2
+ import type { TemplateJsonCommon } from './TemplateJsonCommon';
3
3
  /**
4
4
  * Template for script execution
5
5
  *
6
6
  * Note: [🚉] This is fully serializable as JSON
7
7
  * @see https://github.com/webgptorg/promptbook/discussions/77
8
8
  */
9
- export type ScriptJson = PromptTemplateJsonCommon & {
10
- readonly blockType: 'SCRIPT';
9
+ export type ScriptTemplateJson = TemplateJsonCommon & {
10
+ readonly blockType: 'SCRIPT_TEMPLATE';
11
11
  /**
12
12
  * Language of the script
13
13
  * - This is required only for blockType SCRIPT
@@ -16,5 +16,5 @@ export type ScriptJson = PromptTemplateJsonCommon & {
16
16
  readonly contentLanguage?: ScriptLanguage;
17
17
  };
18
18
  /**
19
- * TODO: [🍙] Make some standart order of json properties
19
+ * TODO: [🍙] Make some standard order of json properties
20
20
  */
@@ -1,13 +1,13 @@
1
- import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
1
+ import type { TemplateJsonCommon } from './TemplateJsonCommon';
2
2
  /**
3
3
  * Template for simple concatenation of strings
4
4
  *
5
5
  * Note: [🚉] This is fully serializable as JSON
6
6
  * @see https://github.com/webgptorg/promptbook/discussions/17
7
7
  */
8
- export type SimpleTemplateJson = PromptTemplateJsonCommon & {
8
+ export type SimpleTemplateJson = TemplateJsonCommon & {
9
9
  readonly blockType: 'SIMPLE_TEMPLATE';
10
10
  };
11
11
  /**
12
- * TODO: [🍙] Make some standart order of json properties
12
+ * TODO: [🍙] Make some standard order of json properties
13
13
  */
@@ -0,0 +1,11 @@
1
+ import type { ___or___ } from '../../utils/organization/___or___';
2
+ import type { DialogTemplateJson } from './DialogTemplateJson';
3
+ import type { PromptTemplateJson } from './PromptTemplateJson';
4
+ import type { ScriptTemplateJson } from './ScriptTemplateJson';
5
+ import type { SimpleTemplateJson } from './SimpleTemplateJson';
6
+ /**
7
+ * Describes one (prompt) template in the promptbook
8
+ *
9
+ * Note: [🚉] This is fully serializable as JSON
10
+ */
11
+ export type TemplateJson = PromptTemplateJson | SimpleTemplateJson | ScriptTemplateJson | DialogTemplateJson | ___or___ | ___or___;
@@ -1,5 +1,5 @@
1
1
  import type { BlockType } from '../../commands/BLOCK/BlockTypes';
2
- import type { ExpectFormatCommand } from '../../commands/EXPECT/ExpectFormatCommand';
2
+ import type { FormatCommand } from '../../commands/FORMAT/FormatCommand';
3
3
  import type { string_javascript } from '../typeAliases';
4
4
  import type { string_markdown } from '../typeAliases';
5
5
  import type { string_markdown_text } from '../typeAliases';
@@ -12,7 +12,7 @@ import type { Expectations } from './Expectations';
12
12
  /**
13
13
  * Common properties of all prompt templates
14
14
  */
15
- export interface PromptTemplateJsonCommon {
15
+ export interface TemplateJsonCommon {
16
16
  /**
17
17
  * Name of the template
18
18
  * - It must be unique across the pipeline
@@ -83,14 +83,13 @@ export interface PromptTemplateJsonCommon {
83
83
  * @see https://github.com/webgptorg/promptbook/discussions/30
84
84
  * @deprecated [💝]
85
85
  */
86
- readonly expectFormat?: ExpectFormatCommand['format'];
86
+ readonly format?: FormatCommand['format'];
87
87
  /**
88
88
  * Name of the parameter that is the result of the prompt template
89
89
  */
90
90
  readonly resultingParameterName: string_name;
91
91
  }
92
92
  /**
93
- * TODO: [🧠][🥜]
94
93
  * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
95
94
  * TODO: [♈] Probbably move expectations from templates to parameters
96
95
  */
@@ -1,4 +1,4 @@
1
- import type { ExpectFormatCommand } from '../commands/EXPECT/ExpectFormatCommand';
1
+ import type { FormatCommand } from '../commands/FORMAT/FormatCommand';
2
2
  import type { ChatModelRequirements } from './ModelRequirements';
3
3
  import type { CompletionModelRequirements } from './ModelRequirements';
4
4
  import type { EmbeddingModelRequirements } from './ModelRequirements';
@@ -54,6 +54,8 @@ export type EmbeddingPrompt = CommonPrompt & {
54
54
  * Common properties for all prompt results
55
55
  *
56
56
  * Note: [🚉] This is fully serializable as JSON
57
+ *
58
+ * @private just abstract the common properties of the prompts
57
59
  */
58
60
  export type CommonPrompt = {
59
61
  /**
@@ -89,7 +91,7 @@ export type CommonPrompt = {
89
91
  * Note: Expectations are performed after all postprocessing steps
90
92
  * @deprecated [💝]
91
93
  */
92
- readonly expectFormat?: ExpectFormatCommand['format'];
94
+ readonly format?: FormatCommand['format'];
93
95
  /**
94
96
  * Unique identifier of the pipeline with specific template name as hash
95
97
  *
@@ -10,5 +10,6 @@ export declare function addAutoGeneratedSection(content: string_markdown, option
10
10
  readonly sectionContent: string_markdown;
11
11
  }): string_markdown;
12
12
  /**
13
+ * TODO: !!!!!! Somw way how to connect this with commands
13
14
  * TODO: [🏛] This can be part of markdown builder
14
15
  */
@@ -27,7 +27,7 @@ export type CodeBlock = {
27
27
  *
28
28
  * @param markdown any valid markdown
29
29
  * @returns code blocks with language and content
30
- * @throws {ParsingError} if block is not closed properly
30
+ * @throws {ParseError} if block is not closed properly
31
31
  * @public exported from `@promptbook/markdown-utils`
32
32
  */
33
33
  export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): Array<CodeBlock>;
@@ -3,7 +3,7 @@ import type { CodeBlock } from './extractAllBlocksFromMarkdown';
3
3
  /**
4
4
  * Extracts exactly ONE code block from markdown.
5
5
  *
6
- * - When there are multiple or no code blocks the function throws a `ParsingError`
6
+ * - When there are multiple or no code blocks the function throws a `ParseError`
7
7
  *
8
8
  * Note: There are multiple simmilar function:
9
9
  * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
@@ -14,7 +14,7 @@ import type { CodeBlock } from './extractAllBlocksFromMarkdown';
14
14
  * @param markdown any valid markdown
15
15
  * @returns code block with language and content
16
16
  * @public exported from `@promptbook/markdown-utils`
17
- * @throws {ParsingError} if there is not exactly one code block in the markdown
17
+ * @throws {ParseError} if there is not exactly one code block in the markdown
18
18
  */
19
19
  export declare function extractOneBlockFromMarkdown(markdown: string_markdown): CodeBlock;
20
20
  /***
@@ -0,0 +1,7 @@
1
+ import type { really_unknown } from './really_unknown';
2
+ /**
3
+ * Formatting helper to put void to keep longer version of prettier
4
+ *
5
+ * @private within the repository
6
+ */
7
+ export type ___and___ = really_unknown;
@@ -3,4 +3,4 @@
3
3
  *
4
4
  * @private within the repository
5
5
  */
6
- export type ___ = never;
6
+ export type ___or___ = never;
@@ -5,7 +5,7 @@
5
5
  * Note: it also works only with decimal numbers
6
6
  *
7
7
  * @returns parsed number
8
- * @throws {ParsingError} if the value is not a number
8
+ * @throws {ParseError} if the value is not a number
9
9
  *
10
10
  * @public exported from `@promptbook/utils`
11
11
  */
@@ -9,5 +9,5 @@ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
9
9
  */
10
10
  export declare function clonePipeline(pipeline: PipelineJson): PipelineJson;
11
11
  /**
12
- * TODO: [🍙] Make some standart order of json properties
12
+ * TODO: [🍙] Make some standard order of json properties
13
13
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/utils",
3
- "version": "0.67.9",
3
+ "version": "0.68.0-1",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -12,7 +12,7 @@
12
12
  /**
13
13
  * The version of the Promptbook library
14
14
  */
15
- var PROMPTBOOK_VERSION = '0.67.8';
15
+ var PROMPTBOOK_VERSION = '0.68.0-0';
16
16
  // TODO: !!!! List here all the versions and annotate + put into script
17
17
 
18
18
  /*! *****************************************************************************
@@ -585,7 +585,7 @@
585
585
  * @public exported from `@promptbook/utils`
586
586
  */
587
587
  function renderPromptbookMermaid(pipelineJson, options) {
588
- var _a = (options || {}).linkPromptTemplate, linkPromptTemplate = _a === void 0 ? function () { return null; } : _a;
588
+ var _a = (options || {}).linkTemplate, linkTemplate = _a === void 0 ? function () { return null; } : _a;
589
589
  var parameterNameToTemplateName = function (parameterName) {
590
590
  var parameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
591
591
  if (!parameter) {
@@ -594,13 +594,13 @@
594
594
  if (parameter.isInput) {
595
595
  return 'input';
596
596
  }
597
- var template = pipelineJson.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
597
+ var template = pipelineJson.templates.find(function (template) { return template.resultingParameterName === parameterName; });
598
598
  if (!template) {
599
599
  throw new Error("Could not find template for {".concat(parameterName, "}"));
600
600
  }
601
601
  return normalizeTo_camelCase('template-' + titleToName(template.title));
602
602
  };
603
- var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.promptTemplates
603
+ var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.templates
604
604
  .flatMap(function (_a) {
605
605
  var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
606
606
  return __spreadArray([
@@ -618,14 +618,14 @@
618
618
  var name = _a.name;
619
619
  return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
620
620
  })
621
- .join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.promptTemplates
622
- .map(function (promptTemplate) {
623
- var link = linkPromptTemplate(promptTemplate);
621
+ .join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.templates
622
+ .map(function (template) {
623
+ var link = linkTemplate(template);
624
624
  if (link === null) {
625
625
  return '';
626
626
  }
627
627
  var href = link.href, title = link.title;
628
- var templateName = parameterNameToTemplateName(promptTemplate.resultingParameterName);
628
+ var templateName = parameterNameToTemplateName(template.resultingParameterName);
629
629
  return "click ".concat(templateName, " href \"").concat(href, "\" \"").concat(title, "\";");
630
630
  })
631
631
  .filter(function (line) { return line !== ''; })
@@ -670,23 +670,26 @@
670
670
  *
671
671
  * @public exported from `@promptbook/core`
672
672
  */
673
- var ParsingError = /** @class */ (function (_super) {
674
- __extends(ParsingError, _super);
675
- function ParsingError(message) {
673
+ var ParseError = /** @class */ (function (_super) {
674
+ __extends(ParseError, _super);
675
+ function ParseError(message) {
676
676
  var _this = _super.call(this, message) || this;
677
- _this.name = 'ParsingError';
678
- Object.setPrototypeOf(_this, ParsingError.prototype);
677
+ _this.name = 'ParseError';
678
+ Object.setPrototypeOf(_this, ParseError.prototype);
679
679
  return _this;
680
680
  }
681
- return ParsingError;
681
+ return ParseError;
682
682
  }(Error));
683
+ /**
684
+ * TODO: Maybe split `ParseError` and `ApplyError`
685
+ */
683
686
 
684
687
  /**
685
688
  * Parses the given script and returns the list of all used variables that are not defined in the script
686
689
  *
687
690
  * @param script from which to extract the variables
688
691
  * @returns the list of variable names
689
- * @throws {ParsingError} if the script is invalid
692
+ * @throws {ParseError} if the script is invalid
690
693
  * @public exported from `@promptbook/utils`
691
694
  */
692
695
  function extractVariables(script) {
@@ -722,7 +725,7 @@
722
725
  if (!(error instanceof Error)) {
723
726
  throw error;
724
727
  }
725
- throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n "); }));
728
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n "); }));
726
729
  }
727
730
  return variables;
728
731
  }
@@ -733,14 +736,14 @@
733
736
  /**
734
737
  * Parses the prompt template and returns the set of all used parameters
735
738
  *
736
- * @param promptTemplate the template with used parameters
739
+ * @param template the template with used parameters
737
740
  * @returns the set of parameter names
738
- * @throws {ParsingError} if the script is invalid
741
+ * @throws {ParseError} if the script is invalid
739
742
  * @public exported from `@promptbook/utils`
740
743
  */
741
- function extractParameterNamesFromPromptTemplate(promptTemplate) {
744
+ function extractParameterNamesFromTemplate(template) {
742
745
  var e_1, _a, e_2, _b, e_3, _c;
743
- var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
746
+ var title = template.title, description = template.description, blockType = template.blockType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
744
747
  var parameterNames = new Set();
745
748
  try {
746
749
  for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
@@ -755,7 +758,7 @@
755
758
  }
756
759
  finally { if (e_1) throw e_1.error; }
757
760
  }
758
- if (blockType === 'SCRIPT') {
761
+ if (blockType === 'SCRIPT_TEMPLATE') {
759
762
  try {
760
763
  for (var _f = __values(extractVariables(content)), _g = _f.next(); !_g.done; _g = _f.next()) {
761
764
  var parameterName = _g.value;
@@ -820,7 +823,7 @@
820
823
  if (pipeline.parameters.some(function (parameter) { return parameter.name === newParameterName; })) {
821
824
  throw new PipelineLogicError("Can not replace {".concat(oldParameterName, "} to {").concat(newParameterName, "} because {").concat(newParameterName, "} is already used in the pipeline"));
822
825
  }
823
- var renamedPipeline = __assign(__assign({}, pipeline), { parameters: __spreadArray([], __read(pipeline.parameters), false), promptTemplates: __spreadArray([], __read(pipeline.promptTemplates), false) });
826
+ var renamedPipeline = __assign(__assign({}, pipeline), { parameters: __spreadArray([], __read(pipeline.parameters), false), templates: __spreadArray([], __read(pipeline.templates), false) });
824
827
  try {
825
828
  for (var _c = __values(renamedPipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
826
829
  var parameter = _d.value;
@@ -838,20 +841,20 @@
838
841
  finally { if (e_1) throw e_1.error; }
839
842
  }
840
843
  try {
841
- for (var _e = __values(renamedPipeline.promptTemplates), _f = _e.next(); !_f.done; _f = _e.next()) {
842
- var promptTemplate = _f.value;
843
- if (promptTemplate.resultingParameterName === oldParameterName) {
844
- promptTemplate.resultingParameterName = newParameterName;
844
+ for (var _e = __values(renamedPipeline.templates), _f = _e.next(); !_f.done; _f = _e.next()) {
845
+ var template = _f.value;
846
+ if (template.resultingParameterName === oldParameterName) {
847
+ template.resultingParameterName = newParameterName;
845
848
  }
846
- promptTemplate.dependentParameterNames = promptTemplate.dependentParameterNames.map(function (dependentParameterName) {
849
+ template.dependentParameterNames = template.dependentParameterNames.map(function (dependentParameterName) {
847
850
  return dependentParameterName === oldParameterName ? newParameterName : dependentParameterName;
848
851
  });
849
- promptTemplate.content = promptTemplate.content.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
850
- promptTemplate.title = promptTemplate.title.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
851
- promptTemplate.description =
852
- promptTemplate.description === undefined
852
+ template.content = template.content.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
853
+ template.title = template.title.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
854
+ template.description =
855
+ template.description === undefined
853
856
  ? undefined
854
- : promptTemplate.description.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
857
+ : template.description.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
855
858
  }
856
859
  }
857
860
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1007,7 +1010,7 @@
1007
1010
  LimitReachedError: LimitReachedError,
1008
1011
  NotFoundError: NotFoundError,
1009
1012
  NotYetImplementedError: NotYetImplementedError,
1010
- ParsingError: ParsingError,
1013
+ ParseError: ParseError,
1011
1014
  PipelineExecutionError: PipelineExecutionError,
1012
1015
  PipelineLogicError: PipelineLogicError,
1013
1016
  PipelineUrlError: PipelineUrlError,
@@ -1530,7 +1533,7 @@
1530
1533
  * Note: it also works only with decimal numbers
1531
1534
  *
1532
1535
  * @returns parsed number
1533
- * @throws {ParsingError} if the value is not a number
1536
+ * @throws {ParseError} if the value is not a number
1534
1537
  *
1535
1538
  * @public exported from `@promptbook/utils`
1536
1539
  */
@@ -1566,7 +1569,7 @@
1566
1569
  var numerator = parseNumber(numerator_);
1567
1570
  var denominator = parseNumber(denominator_);
1568
1571
  if (denominator === 0) {
1569
- throw new ParsingError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
1572
+ throw new ParseError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
1570
1573
  }
1571
1574
  return numerator / denominator;
1572
1575
  }
@@ -1578,11 +1581,11 @@
1578
1581
  return parseNumber(significand) * Math.pow(10, parseNumber(exponent));
1579
1582
  }
1580
1583
  if (!/^[0-9.]+$/.test(value) || value.split('.').length > 2) {
1581
- throw new ParsingError("Unable to parse number from \"".concat(originalValue, "\""));
1584
+ throw new ParseError("Unable to parse number from \"".concat(originalValue, "\""));
1582
1585
  }
1583
1586
  var num = parseFloat(value);
1584
1587
  if (isNaN(num)) {
1585
- throw new ParsingError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
1588
+ throw new ParseError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
1586
1589
  }
1587
1590
  return num;
1588
1591
  }
@@ -1935,7 +1938,7 @@
1935
1938
  */
1936
1939
  function clonePipeline(pipeline) {
1937
1940
  // Note: Not using spread operator (...) because @@@
1938
- var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, promptbookVersion = pipeline.promptbookVersion, description = pipeline.description, parameters = pipeline.parameters, promptTemplates = pipeline.promptTemplates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
1941
+ var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, promptbookVersion = pipeline.promptbookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
1939
1942
  return {
1940
1943
  pipelineUrl: pipelineUrl,
1941
1944
  sourceFile: sourceFile,
@@ -1943,7 +1946,7 @@
1943
1946
  promptbookVersion: promptbookVersion,
1944
1947
  description: description,
1945
1948
  parameters: parameters,
1946
- promptTemplates: promptTemplates,
1949
+ templates: templates,
1947
1950
  knowledgeSources: knowledgeSources,
1948
1951
  knowledgePieces: knowledgePieces,
1949
1952
  personas: personas,
@@ -1951,7 +1954,7 @@
1951
1954
  };
1952
1955
  }
1953
1956
  /**
1954
- * TODO: [🍙] Make some standart order of json properties
1957
+ * TODO: [🍙] Make some standard order of json properties
1955
1958
  */
1956
1959
 
1957
1960
  /**
@@ -2472,7 +2475,7 @@
2472
2475
  exports.deserializeError = deserializeError;
2473
2476
  exports.difference = difference;
2474
2477
  exports.extractParameterNames = extractParameterNames;
2475
- exports.extractParameterNamesFromPromptTemplate = extractParameterNamesFromPromptTemplate;
2478
+ exports.extractParameterNamesFromTemplate = extractParameterNamesFromTemplate;
2476
2479
  exports.extractVariables = extractVariables;
2477
2480
  exports.forEachAsync = forEachAsync;
2478
2481
  exports.intersection = intersection;