@promptbook/node 0.61.0-25 → 0.61.0-26

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.
@@ -1,6 +1,6 @@
1
1
  import { spaceTrim } from 'spacetrim';
2
2
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPipelineMermaidOptions';
3
- import { extractParametersFromPromptTemplate } from '../conversion/utils/extractParametersFromPromptTemplate';
3
+ import { extractParameterNamesFromPromptTemplate } from '../conversion/utils/extractParameterNamesFromPromptTemplate';
4
4
  import { extractVariables } from '../conversion/utils/extractVariables';
5
5
  import { renameParameter } from '../conversion/utils/renameParameter';
6
6
  import { titleToName } from '../conversion/utils/titleToName';
@@ -15,7 +15,7 @@ import { countParagraphs } from '../utils/expectation-counters/countParagraphs';
15
15
  import { countSentences, splitIntoSentences } from '../utils/expectation-counters/countSentences';
16
16
  import { countWords } from '../utils/expectation-counters/countWords';
17
17
  import { CountUtils } from '../utils/expectation-counters/index';
18
- import { extractParameters } from '../utils/extractParameters';
18
+ import { extractParameterNames } from '../utils/extractParameterNames';
19
19
  import { DIACRITIC_VARIANTS_LETTERS } from '../utils/normalization/DIACRITIC_VARIANTS_LETTERS';
20
20
  import type { IKeywords, string_keyword } from '../utils/normalization/IKeywords';
21
21
  import { capitalize } from '../utils/normalization/capitalize';
@@ -55,7 +55,7 @@ import { isValidUrl } from '../utils/validators/url/isValidUrl';
55
55
  import { isValidUuid } from '../utils/validators/uuid/isValidUuid';
56
56
  import { PROMPTBOOK_VERSION } from '../version';
57
57
  export { forEachAsync, PROMPTBOOK_VERSION };
58
- export { extractParameters, extractVariables, replaceParameters, spaceTrim };
58
+ export { extractParameterNames, extractVariables, replaceParameters, spaceTrim };
59
59
  export { $currentDate, $randomSeed, extractBlock, // <- [🌻] + maybe export through `@promptbook/markdown-utils`
60
60
  isHostnameOnPrivateNetwork, isUrlOnPrivateNetwork, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, parseNumber, // <- [🌻]
61
61
  removeEmojis, removeQuotes, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
@@ -70,7 +70,7 @@ export declare const normalizeTo: {
70
70
  };
71
71
  export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, titleToName, };
72
72
  export type { string_camelCase, string_kebab_case, string_PascalCase, string_SCREAMING_CASE, string_snake_case };
73
- export { extractParametersFromPromptTemplate, renameParameter, renderPromptbookMermaid };
73
+ export { extractParameterNamesFromPromptTemplate, renameParameter, renderPromptbookMermaid };
74
74
  export { difference, intersection, union };
75
75
  /**
76
76
  * Note: [🕙] It does not make sence to have simple lower / UPPER case normalization
@@ -7,7 +7,7 @@ import type { string_parameter_name } from '../../types/typeAliases';
7
7
  * @returns the set of parameter names
8
8
  * @throws {ParsingError} if the script is invalid
9
9
  */
10
- export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'blockType' | 'content' | 'preparedContent' | 'jokerParameterNames'>): Set<string_parameter_name>;
10
+ export declare function extractParameterNamesFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'blockType' | 'content' | 'preparedContent' | 'jokerParameterNames'>): Set<string_parameter_name>;
11
11
  /**
12
12
  * TODO: [🔣] If script require contentLanguage
13
13
  */
@@ -81,7 +81,7 @@ export type PipelineJson = {
81
81
  /**
82
82
  * TODO: [🍙] Make some standart order of json properties
83
83
  * TODO: [🧠] Maybe wrap all {parameterNames} in brackets for example { "resultingParameterName": "{foo}" }
84
- * Note: There was a proposal for multiple types of promptbook objects 78816ff33e2705ee1a187aa2eb8affd976d4ea1a
84
+ * Note: [💼] There was a proposal for multiple types of promptbook objects 78816ff33e2705ee1a187aa2eb8affd976d4ea1a
85
85
  * But then immediately reverted back to the single type
86
86
  * With knowledge as part of the promptbook and collection just as a collection of promptbooks
87
87
  */
@@ -6,7 +6,7 @@ import type { string_template } from '../types/typeAliases';
6
6
  * @param template the template with parameters in {curly} braces
7
7
  * @returns the list of parameter names
8
8
  */
9
- export declare function extractParameters(template: string_template): Set<string_parameter_name>;
9
+ export declare function extractParameterNames(template: string_template): Set<string_parameter_name>;
10
10
  /**
11
11
  * TODO: !!!!! Rename to extractParameterNames
12
- */
12
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.61.0-25",
3
+ "version": "0.61.0-26",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -51,7 +51,7 @@
51
51
  }
52
52
  ],
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.61.0-25"
54
+ "@promptbook/core": "0.61.0-26"
55
55
  },
56
56
  "main": "./umd/index.umd.js",
57
57
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -659,7 +659,7 @@
659
659
  });
660
660
  }
661
661
 
662
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
662
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-25",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-25",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-25",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-25",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-25",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-25",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-25",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-25",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
663
663
 
664
664
  /**
665
665
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -862,52 +862,63 @@
862
862
  */
863
863
  function validatePipeline(pipeline) {
864
864
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
865
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
865
+ var e_1, _a, e_2, _b, e_3, _c;
866
+ var pipelineIdentification = (function () {
867
+ // Note: This is a 😐 implementation of [🚞]
868
+ var _ = [];
869
+ if (pipeline.sourceFile !== undefined) {
870
+ _.push("File: ".concat(pipeline.sourceFile));
871
+ }
872
+ if (pipeline.pipelineUrl !== undefined) {
873
+ _.push("Url: ".concat(pipeline.pipelineUrl));
874
+ }
875
+ return _.join('\n');
876
+ })();
866
877
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
867
878
  // <- Note: [🚲]
868
- throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\""));
879
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
869
880
  }
870
881
  if (!isValidPromptbookVersion(pipeline.promptbookVersion)) {
871
882
  // <- Note: [🚲]
872
- throw new PipelineLogicError("Invalid promptbook Version \"".concat(pipeline.pipelineUrl, "\""));
883
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
873
884
  }
874
885
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
875
886
  if (!Array.isArray(pipeline.parameters)) {
876
887
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
877
- throw new ParsingError(spaceTrim.spaceTrim("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.parameters expected to be an array, but got ".concat(typeof pipeline.parameters, "\n ")));
888
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Promptbook is valid JSON but with wrong structure\n\n `promptbook.parameters` expected to be an array, but got ".concat(typeof pipeline.parameters, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
878
889
  }
879
890
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
880
891
  if (!Array.isArray(pipeline.promptTemplates)) {
881
892
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
882
- throw new ParsingError(spaceTrim.spaceTrim("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.promptTemplates expected to be an array, but got ".concat(typeof pipeline.promptTemplates, "\n ")));
893
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Promptbook is valid JSON but with wrong structure\n\n `promptbook.promptTemplates` expected to be an array, but got ".concat(typeof pipeline.promptTemplates, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
883
894
  }
884
895
  var _loop_1 = function (parameter) {
885
896
  if (parameter.isInput && parameter.isOutput) {
886
- throw new PipelineLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
897
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
887
898
  }
888
899
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
889
900
  if (!parameter.isInput &&
890
901
  !parameter.isOutput &&
891
902
  !pipeline.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
892
- throw new PipelineLogicError(spaceTrim.spaceTrim("\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ")));
903
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
893
904
  }
894
905
  // Note: Testing that parameter is either input or result of some template
895
906
  if (!parameter.isInput &&
896
907
  !pipeline.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
897
- throw new PipelineLogicError(spaceTrim.spaceTrim("\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ")));
908
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
898
909
  }
899
910
  };
900
911
  try {
901
912
  // Note: Check each parameter individually
902
- for (var _f = __values(pipeline.parameters), _g = _f.next(); !_g.done; _g = _f.next()) {
903
- var parameter = _g.value;
913
+ for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
914
+ var parameter = _e.value;
904
915
  _loop_1(parameter);
905
916
  }
906
917
  }
907
918
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
908
919
  finally {
909
920
  try {
910
- if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
921
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
911
922
  }
912
923
  finally { if (e_1) throw e_1.error; }
913
924
  }
@@ -919,70 +930,80 @@
919
930
  var name = _a.name;
920
931
  return name;
921
932
  }));
922
- try {
923
- // Note: Checking each template individually
924
- for (var _h = __values(pipeline.promptTemplates), _j = _h.next(); !_j.done; _j = _h.next()) {
925
- var template = _j.value;
926
- if (definedParameters.has(template.resultingParameterName)) {
927
- throw new PipelineLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
933
+ var _loop_2 = function (template) {
934
+ var e_4, _h, e_5, _j;
935
+ if (definedParameters.has(template.resultingParameterName)) {
936
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
937
+ }
938
+ if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
939
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
940
+ }
941
+ definedParameters.add(template.resultingParameterName);
942
+ if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
943
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`").concat(/* <- TODO: Dynamic listing of command examples */ '', "\n\n ").concat(block(pipelineIdentification), "\n "); }));
944
+ }
945
+ if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
946
+ if (!template.expectFormat &&
947
+ !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
948
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
928
949
  }
929
- if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
930
- throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name"));
950
+ var _loop_4 = function (joker) {
951
+ if (!template.dependentParameterNames.includes(joker)) {
952
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
953
+ }
954
+ };
955
+ try {
956
+ for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
957
+ var joker = _l.value;
958
+ _loop_4(joker);
959
+ }
931
960
  }
932
- definedParameters.add(template.resultingParameterName);
933
- if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
934
- throw new PipelineLogicError(spaceTrim.spaceTrim("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
961
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
962
+ finally {
963
+ try {
964
+ if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
965
+ }
966
+ finally { if (e_4) throw e_4.error; }
935
967
  }
936
- if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
937
- if (!template.expectFormat &&
938
- !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
939
- throw new PipelineLogicError("Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined"));
968
+ }
969
+ if (template.expectations) {
970
+ var _loop_5 = function (unit, min, max) {
971
+ if (min !== undefined && max !== undefined && min > max) {
972
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
940
973
  }
941
- try {
942
- for (var _k = (e_3 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
943
- var joker = _l.value;
944
- if (!template.dependentParameterNames.includes(joker)) {
945
- throw new PipelineLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
946
- }
947
- }
974
+ if (min !== undefined && min < 0) {
975
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Min expectation of ".concat(unit, " must be zero or positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
948
976
  }
949
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
950
- finally {
951
- try {
952
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
953
- }
954
- finally { if (e_3) throw e_3.error; }
977
+ if (max !== undefined && max <= 0) {
978
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Max expectation of ".concat(unit, " must be positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
979
+ }
980
+ };
981
+ try {
982
+ for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
983
+ var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
984
+ _loop_5(unit, min, max);
955
985
  }
956
986
  }
957
- if (template.expectations) {
987
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
988
+ finally {
958
989
  try {
959
- for (var _m = (e_4 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
960
- var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
961
- if (min !== undefined && max !== undefined && min > max) {
962
- throw new PipelineLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
963
- }
964
- if (min !== undefined && min < 0) {
965
- throw new PipelineLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
966
- }
967
- if (max !== undefined && max <= 0) {
968
- throw new PipelineLogicError("Max expectation of ".concat(unit, " must be positive"));
969
- }
970
- }
971
- }
972
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
973
- finally {
974
- try {
975
- if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
976
- }
977
- finally { if (e_4) throw e_4.error; }
990
+ if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
978
991
  }
992
+ finally { if (e_5) throw e_5.error; }
979
993
  }
980
994
  }
995
+ };
996
+ try {
997
+ // Note: Checking each template individually
998
+ for (var _f = __values(pipeline.promptTemplates), _g = _f.next(); !_g.done; _g = _f.next()) {
999
+ var template = _g.value;
1000
+ _loop_2(template);
1001
+ }
981
1002
  }
982
1003
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
983
1004
  finally {
984
1005
  try {
985
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
1006
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
986
1007
  }
987
1008
  finally { if (e_2) throw e_2.error; }
988
1009
  }
@@ -1003,20 +1024,20 @@
1003
1024
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), [reservedParameterName], false);
1004
1025
  }
1005
1026
  }
1006
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1027
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1007
1028
  finally {
1008
1029
  try {
1009
- if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (_e = RESERVED_PARAMETER_NAMES_1.return)) _e.call(RESERVED_PARAMETER_NAMES_1);
1030
+ if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (_c = RESERVED_PARAMETER_NAMES_1.return)) _c.call(RESERVED_PARAMETER_NAMES_1);
1010
1031
  }
1011
- finally { if (e_5) throw e_5.error; }
1032
+ finally { if (e_3) throw e_3.error; }
1012
1033
  }
1013
1034
  var unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
1014
1035
  // <- TODO: [🧠][🥜]
1015
1036
  var loopLimit = LOOP_LIMIT;
1016
- var _loop_2 = function () {
1037
+ var _loop_3 = function () {
1017
1038
  if (loopLimit-- < 0) {
1018
1039
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1019
- throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
1040
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
1020
1041
  }
1021
1042
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1022
1043
  return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
@@ -1031,7 +1052,7 @@
1031
1052
  .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1032
1053
  .join(' and '));
1033
1054
  })
1034
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n "); }));
1055
+ .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1035
1056
  }
1036
1057
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1037
1058
  var resultingParameterName = _a.resultingParameterName;
@@ -1040,7 +1061,7 @@
1040
1061
  unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
1041
1062
  };
1042
1063
  while (unresovedTemplates.length > 0) {
1043
- _loop_2();
1064
+ _loop_3();
1044
1065
  }
1045
1066
  return pipeline;
1046
1067
  }
@@ -1099,7 +1120,7 @@
1099
1120
  * @param template the template with parameters in {curly} braces
1100
1121
  * @returns the list of parameter names
1101
1122
  */
1102
- function extractParameters(template) {
1123
+ function extractParameterNames(template) {
1103
1124
  var e_1, _a;
1104
1125
  var matches = template.matchAll(/{\w+}/g);
1105
1126
  var parameterNames = new Set();
@@ -1132,7 +1153,7 @@
1132
1153
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
1133
1154
  promptTemplates = promptTemplates.map(function (promptTemplate) {
1134
1155
  var dependentParameterNames = promptTemplate.dependentParameterNames;
1135
- var parameterNames = extractParameters(promptTemplate.preparedContent || '');
1156
+ var parameterNames = extractParameterNames(promptTemplate.preparedContent || '');
1136
1157
  dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
1137
1158
  var promptTemplateUnprepared = __assign(__assign({}, promptTemplate), { dependentParameterNames: dependentParameterNames });
1138
1159
  delete promptTemplateUnprepared.preparedContent;
@@ -1689,12 +1710,12 @@
1689
1710
  * @returns the set of parameter names
1690
1711
  * @throws {ParsingError} if the script is invalid
1691
1712
  */
1692
- function extractParametersFromPromptTemplate(promptTemplate) {
1713
+ function extractParameterNamesFromPromptTemplate(promptTemplate) {
1693
1714
  var e_1, _a, e_2, _b, e_3, _c;
1694
1715
  var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
1695
1716
  var parameterNames = new Set();
1696
1717
  try {
1697
- for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameters(title)), false), __read(extractParameters(description || '')), false), __read(extractParameters(content)), false), __read(extractParameters(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
1718
+ 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()) {
1698
1719
  var parameterName = _e.value;
1699
1720
  parameterNames.add(parameterName);
1700
1721
  }
@@ -2255,7 +2276,7 @@
2255
2276
  /**
2256
2277
  * The version of the Promptbook library
2257
2278
  */
2258
- var PROMPTBOOK_VERSION = '0.61.0-24';
2279
+ var PROMPTBOOK_VERSION = '0.61.0-25';
2259
2280
  // TODO: !!!! List here all the versions and annotate + put into script
2260
2281
 
2261
2282
  /**
@@ -2494,7 +2515,7 @@
2494
2515
  _u.sent();
2495
2516
  _u.label = 2;
2496
2517
  case 2:
2497
- usedParameterNames = extractParametersFromPromptTemplate(currentTemplate);
2518
+ usedParameterNames = extractParameterNamesFromPromptTemplate(currentTemplate);
2498
2519
  dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
2499
2520
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
2500
2521
  throw new UnexpectedError(spaceTrim.spaceTrim("\n Dependent parameters are not consistent used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames).join(', '), "\n\n Used parameters:\n ").concat(Array.from(usedParameterNames).join(', '), "\n\n ")));
@@ -2880,14 +2901,7 @@
2880
2901
  ) {
2881
2902
  // TODO: [🧠] Maybe put other blockTypes into report
2882
2903
  executionReport.promptExecutions.push({
2883
- prompt: {
2884
- title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */,
2885
- content: prompt.content,
2886
- modelRequirements: prompt.modelRequirements,
2887
- expectations: prompt.expectations,
2888
- expectFormat: prompt.expectFormat,
2889
- // <- Note: Do want to pass ONLY wanted information to the report
2890
- },
2904
+ prompt: __assign(__assign({ '!!! All information': null }, prompt), { '!!! Wanted information': null, title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */, content: prompt.content, modelRequirements: prompt.modelRequirements, expectations: prompt.expectations, expectFormat: prompt.expectFormat }),
2891
2905
  result: result || undefined,
2892
2906
  error: expectError || undefined,
2893
2907
  });
@@ -4367,11 +4381,8 @@
4367
4381
  /**
4368
4382
  * Name of the command
4369
4383
  */
4370
- name: 'VERSION',
4371
- /*
4372
- Note: [📇] No need to put here "PROMPTBOOK" alias here
4373
- aliasNames: ['PROMPTBOOK_VERSION'],
4374
- */
4384
+ name: 'PROMPTBOOK_VERSION',
4385
+ aliasNames: ['PTBK_VERSION', 'PTBK_V', 'PTBKV'],
4375
4386
  /**
4376
4387
  * BOILERPLATE command can be used in:
4377
4388
  */
@@ -4387,7 +4398,7 @@
4387
4398
  /**
4388
4399
  * Example usages of the PROMPTBOOK_VERSION command
4389
4400
  */
4390
- examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "VERSION ".concat(PROMPTBOOK_VERSION)],
4401
+ examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "PTBKV ".concat(PROMPTBOOK_VERSION)],
4391
4402
  /**
4392
4403
  * Parses the PROMPTBOOK_VERSION command
4393
4404
  */
@@ -4421,8 +4432,9 @@
4421
4432
  * Name of the command
4422
4433
  */
4423
4434
  name: 'URL',
4435
+ aliasNames: ['PIPELINE_URL'],
4424
4436
  /*
4425
- Note: [🛵] No need for alias name because it is already preprocessed
4437
+ Note: [🛵] No need for this alias name because it is already preprocessed
4426
4438
  aliasNames: ['HTTPS'],
4427
4439
  */
4428
4440
  /**
@@ -4441,6 +4453,7 @@
4441
4453
  * Example usages of the URL command
4442
4454
  */
4443
4455
  examples: [
4456
+ 'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
4444
4457
  'URL https://promptbook.studio/library/write-cv.ptbk.md',
4445
4458
  'https://promptbook.studio/library/write-cv.ptbk.md',
4446
4459
  ],
@@ -4679,10 +4692,6 @@
4679
4692
  .split(' ')
4680
4693
  .map(function (part) { return part.trim(); })
4681
4694
  .filter(function (item) { return item !== ''; })
4682
- // Note: [📇]:
4683
- .filter(function (item) { return !/^PTBK$/i.test(item); })
4684
- .filter(function (item) { return !/^PIPELINE$/i.test(item); })
4685
- .filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
4686
4695
  .map(removeMarkdownFormatting)
4687
4696
  .map(function (item) { return item.trim(); });
4688
4697
  if (items.length === 0 || items[0] === '') {
@@ -5397,7 +5406,7 @@
5397
5406
  if (templateModelRequirements.modelVariant === undefined) {
5398
5407
  templateModelRequirements.modelVariant = 'CHAT';
5399
5408
  }
5400
- templateJson.dependentParameterNames = Array.from(extractParametersFromPromptTemplate(templateJson));
5409
+ templateJson.dependentParameterNames = Array.from(extractParameterNamesFromPromptTemplate(templateJson));
5401
5410
  // TODO: [🍧][❔] Remove this condition - modelRequirements should be put here via BLOCK command not removed when PROMPT_TEMPLATE
5402
5411
  if (templateJson.blockType !== 'PROMPT_TEMPLATE') {
5403
5412
  delete templateJson.modelRequirements;