@promptbook/cli 0.61.0-24 → 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.
Files changed (24) hide show
  1. package/README.md +3 -3
  2. package/esm/index.es.js +179 -135
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/utils.index.d.ts +4 -4
  5. package/esm/typings/src/config.d.ts +5 -1
  6. package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.d.ts → extractParameterNamesFromPromptTemplate.d.ts} +1 -1
  7. package/esm/typings/src/execution/createPipelineExecutor.d.ts +2 -0
  8. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  9. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
  10. package/esm/typings/src/utils/{extractParameters.d.ts → extractParameterNames.d.ts} +4 -1
  11. package/package.json +2 -2
  12. package/umd/index.umd.js +179 -135
  13. package/umd/index.umd.js.map +1 -1
  14. package/umd/typings/src/_packages/utils.index.d.ts +4 -4
  15. package/umd/typings/src/config.d.ts +5 -1
  16. package/umd/typings/src/conversion/utils/{extractParametersFromPromptTemplate.d.ts → extractParameterNamesFromPromptTemplate.d.ts} +1 -1
  17. package/umd/typings/src/execution/createPipelineExecutor.d.ts +2 -0
  18. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  19. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
  20. package/umd/typings/src/utils/{extractParameters.d.ts → extractParameterNames.d.ts} +4 -1
  21. /package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts → extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
  22. /package/esm/typings/src/utils/{extractParameters.test.d.ts → extractParameterNames.test.d.ts} +0 -0
  23. /package/umd/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts → extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
  24. /package/umd/typings/src/utils/{extractParameters.test.d.ts → extractParameterNames.test.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -154,7 +154,7 @@
154
154
  /**
155
155
  * The version of the Promptbook library
156
156
  */
157
- var PROMPTBOOK_VERSION = '0.61.0-23';
157
+ var PROMPTBOOK_VERSION = '0.61.0-25';
158
158
  // TODO: !!!! List here all the versions and annotate + put into script
159
159
 
160
160
  /**
@@ -291,6 +291,7 @@
291
291
  * The names of the parameters that are reserved for special purposes
292
292
  */
293
293
  var RESERVED_PARAMETER_NAMES = deepFreeze([
294
+ 'content',
294
295
  'context',
295
296
  'knowledge',
296
297
  'samples',
@@ -303,6 +304,10 @@
303
304
  * @@@
304
305
  */
305
306
  var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
307
+ /**
308
+ * @@@
309
+ */
310
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
306
311
  /*
307
312
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
308
313
  */
@@ -746,7 +751,7 @@
746
751
  });
747
752
  }
748
753
 
749
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-23",parameters:[{name:"content",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> {content}",dependentParameterNames:["content"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-23",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-23",parameters:[{name:"content",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> {content}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-23",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-23",parameters:[{name:"content",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> {content}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-23",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-23",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-23",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"}];
754
+ 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"}];
750
755
 
751
756
  /**
752
757
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -949,52 +954,63 @@
949
954
  */
950
955
  function validatePipeline(pipeline) {
951
956
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
952
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
957
+ var e_1, _a, e_2, _b, e_3, _c;
958
+ var pipelineIdentification = (function () {
959
+ // Note: This is a 😐 implementation of [🚞]
960
+ var _ = [];
961
+ if (pipeline.sourceFile !== undefined) {
962
+ _.push("File: ".concat(pipeline.sourceFile));
963
+ }
964
+ if (pipeline.pipelineUrl !== undefined) {
965
+ _.push("Url: ".concat(pipeline.pipelineUrl));
966
+ }
967
+ return _.join('\n');
968
+ })();
953
969
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
954
970
  // <- Note: [🚲]
955
- throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\""));
971
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
956
972
  }
957
973
  if (!isValidPromptbookVersion(pipeline.promptbookVersion)) {
958
974
  // <- Note: [🚲]
959
- throw new PipelineLogicError("Invalid promptbook Version \"".concat(pipeline.pipelineUrl, "\""));
975
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
960
976
  }
961
977
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
962
978
  if (!Array.isArray(pipeline.parameters)) {
963
979
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
964
- 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 ")));
980
+ 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 "); }));
965
981
  }
966
982
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
967
983
  if (!Array.isArray(pipeline.promptTemplates)) {
968
984
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
969
- 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 ")));
985
+ 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 "); }));
970
986
  }
971
987
  var _loop_1 = function (parameter) {
972
988
  if (parameter.isInput && parameter.isOutput) {
973
- throw new PipelineLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
989
+ 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 "); }));
974
990
  }
975
991
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
976
992
  if (!parameter.isInput &&
977
993
  !parameter.isOutput &&
978
994
  !pipeline.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
979
- 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 ")));
995
+ 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 "); }));
980
996
  }
981
997
  // Note: Testing that parameter is either input or result of some template
982
998
  if (!parameter.isInput &&
983
999
  !pipeline.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
984
- 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 ")));
1000
+ 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 "); }));
985
1001
  }
986
1002
  };
987
1003
  try {
988
1004
  // Note: Check each parameter individually
989
- for (var _f = __values(pipeline.parameters), _g = _f.next(); !_g.done; _g = _f.next()) {
990
- var parameter = _g.value;
1005
+ for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
1006
+ var parameter = _e.value;
991
1007
  _loop_1(parameter);
992
1008
  }
993
1009
  }
994
1010
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
995
1011
  finally {
996
1012
  try {
997
- if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
1013
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
998
1014
  }
999
1015
  finally { if (e_1) throw e_1.error; }
1000
1016
  }
@@ -1006,70 +1022,80 @@
1006
1022
  var name = _a.name;
1007
1023
  return name;
1008
1024
  }));
1009
- try {
1010
- // Note: Checking each template individually
1011
- for (var _h = __values(pipeline.promptTemplates), _j = _h.next(); !_j.done; _j = _h.next()) {
1012
- var template = _j.value;
1013
- if (definedParameters.has(template.resultingParameterName)) {
1014
- throw new PipelineLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
1025
+ var _loop_2 = function (template) {
1026
+ var e_4, _h, e_5, _j;
1027
+ if (definedParameters.has(template.resultingParameterName)) {
1028
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1029
+ }
1030
+ if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1031
+ 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 "); }));
1032
+ }
1033
+ definedParameters.add(template.resultingParameterName);
1034
+ if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
1035
+ 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 "); }));
1036
+ }
1037
+ if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
1038
+ if (!template.expectFormat &&
1039
+ !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1040
+ 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 "); }));
1015
1041
  }
1016
- if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1017
- throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name"));
1042
+ var _loop_4 = function (joker) {
1043
+ if (!template.dependentParameterNames.includes(joker)) {
1044
+ 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 "); }));
1045
+ }
1046
+ };
1047
+ try {
1048
+ for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1049
+ var joker = _l.value;
1050
+ _loop_4(joker);
1051
+ }
1018
1052
  }
1019
- definedParameters.add(template.resultingParameterName);
1020
- if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
1021
- 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 ")));
1053
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1054
+ finally {
1055
+ try {
1056
+ if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
1057
+ }
1058
+ finally { if (e_4) throw e_4.error; }
1022
1059
  }
1023
- if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
1024
- if (!template.expectFormat &&
1025
- !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1026
- throw new PipelineLogicError("Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined"));
1060
+ }
1061
+ if (template.expectations) {
1062
+ var _loop_5 = function (unit, min, max) {
1063
+ if (min !== undefined && max !== undefined && min > max) {
1064
+ 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 "); }));
1027
1065
  }
1028
- try {
1029
- for (var _k = (e_3 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1030
- var joker = _l.value;
1031
- if (!template.dependentParameterNames.includes(joker)) {
1032
- throw new PipelineLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
1033
- }
1034
- }
1066
+ if (min !== undefined && min < 0) {
1067
+ 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 "); }));
1035
1068
  }
1036
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1037
- finally {
1038
- try {
1039
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
1040
- }
1041
- finally { if (e_3) throw e_3.error; }
1069
+ if (max !== undefined && max <= 0) {
1070
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Max expectation of ".concat(unit, " must be positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
1071
+ }
1072
+ };
1073
+ try {
1074
+ for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1075
+ var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
1076
+ _loop_5(unit, min, max);
1042
1077
  }
1043
1078
  }
1044
- if (template.expectations) {
1079
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1080
+ finally {
1045
1081
  try {
1046
- for (var _m = (e_4 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1047
- var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
1048
- if (min !== undefined && max !== undefined && min > max) {
1049
- throw new PipelineLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
1050
- }
1051
- if (min !== undefined && min < 0) {
1052
- throw new PipelineLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
1053
- }
1054
- if (max !== undefined && max <= 0) {
1055
- throw new PipelineLogicError("Max expectation of ".concat(unit, " must be positive"));
1056
- }
1057
- }
1058
- }
1059
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1060
- finally {
1061
- try {
1062
- if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
1063
- }
1064
- finally { if (e_4) throw e_4.error; }
1082
+ if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
1065
1083
  }
1084
+ finally { if (e_5) throw e_5.error; }
1066
1085
  }
1067
1086
  }
1087
+ };
1088
+ try {
1089
+ // Note: Checking each template individually
1090
+ for (var _f = __values(pipeline.promptTemplates), _g = _f.next(); !_g.done; _g = _f.next()) {
1091
+ var template = _g.value;
1092
+ _loop_2(template);
1093
+ }
1068
1094
  }
1069
1095
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
1070
1096
  finally {
1071
1097
  try {
1072
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
1098
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
1073
1099
  }
1074
1100
  finally { if (e_2) throw e_2.error; }
1075
1101
  }
@@ -1090,20 +1116,20 @@
1090
1116
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), [reservedParameterName], false);
1091
1117
  }
1092
1118
  }
1093
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1119
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1094
1120
  finally {
1095
1121
  try {
1096
- if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (_e = RESERVED_PARAMETER_NAMES_1.return)) _e.call(RESERVED_PARAMETER_NAMES_1);
1122
+ if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (_c = RESERVED_PARAMETER_NAMES_1.return)) _c.call(RESERVED_PARAMETER_NAMES_1);
1097
1123
  }
1098
- finally { if (e_5) throw e_5.error; }
1124
+ finally { if (e_3) throw e_3.error; }
1099
1125
  }
1100
1126
  var unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
1101
1127
  // <- TODO: [🧠][🥜]
1102
1128
  var loopLimit = LOOP_LIMIT;
1103
- var _loop_2 = function () {
1129
+ var _loop_3 = function () {
1104
1130
  if (loopLimit-- < 0) {
1105
1131
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1106
- throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
1132
+ 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 "); }));
1107
1133
  }
1108
1134
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1109
1135
  return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
@@ -1118,7 +1144,7 @@
1118
1144
  .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1119
1145
  .join(' and '));
1120
1146
  })
1121
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n "); }));
1147
+ .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1122
1148
  }
1123
1149
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1124
1150
  var resultingParameterName = _a.resultingParameterName;
@@ -1127,7 +1153,7 @@
1127
1153
  unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
1128
1154
  };
1129
1155
  while (unresovedTemplates.length > 0) {
1130
- _loop_2();
1156
+ _loop_3();
1131
1157
  }
1132
1158
  return pipeline;
1133
1159
  }
@@ -1180,6 +1206,36 @@
1180
1206
  return ReferenceError;
1181
1207
  }(Error));
1182
1208
 
1209
+ /**
1210
+ * Parses the template and returns the list of all parameter names
1211
+ *
1212
+ * @param template the template with parameters in {curly} braces
1213
+ * @returns the list of parameter names
1214
+ */
1215
+ function extractParameterNames(template) {
1216
+ var e_1, _a;
1217
+ var matches = template.matchAll(/{\w+}/g);
1218
+ var parameterNames = new Set();
1219
+ try {
1220
+ for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
1221
+ var match = matches_1_1.value;
1222
+ var parameterName = match[0].slice(1, -1);
1223
+ parameterNames.add(parameterName);
1224
+ }
1225
+ }
1226
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1227
+ finally {
1228
+ try {
1229
+ if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
1230
+ }
1231
+ finally { if (e_1) throw e_1.error; }
1232
+ }
1233
+ return parameterNames;
1234
+ }
1235
+ /**
1236
+ * TODO: !!!!! Rename to extractParameterNames
1237
+ */
1238
+
1183
1239
  /**
1184
1240
  * Unprepare just strips the preparation data of the pipeline
1185
1241
  */
@@ -1187,7 +1243,14 @@
1187
1243
  var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, promptTemplates = pipeline.promptTemplates;
1188
1244
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
1189
1245
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
1190
- promptTemplates = promptTemplates.map(function (promptTemplate) { return (__assign(__assign({}, promptTemplate), { preparedContent: undefined })); });
1246
+ promptTemplates = promptTemplates.map(function (promptTemplate) {
1247
+ var dependentParameterNames = promptTemplate.dependentParameterNames;
1248
+ var parameterNames = extractParameterNames(promptTemplate.preparedContent || '');
1249
+ dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
1250
+ var promptTemplateUnprepared = __assign(__assign({}, promptTemplate), { dependentParameterNames: dependentParameterNames });
1251
+ delete promptTemplateUnprepared.preparedContent;
1252
+ return promptTemplateUnprepared;
1253
+ });
1191
1254
  return __assign(__assign({}, pipeline), { promptTemplates: promptTemplates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
1192
1255
  }
1193
1256
  /**
@@ -1684,33 +1747,6 @@
1684
1747
  * TODO: [🧠] Can this return type be better typed than void
1685
1748
  */
1686
1749
 
1687
- /**
1688
- * Parses the template and returns the list of all parameter names
1689
- *
1690
- * @param template the template with parameters in {curly} braces
1691
- * @returns the list of parameter names
1692
- */
1693
- function extractParameters(template) {
1694
- var e_1, _a;
1695
- var matches = template.matchAll(/{\w+}/g);
1696
- var parameterNames = new Set();
1697
- try {
1698
- for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
1699
- var match = matches_1_1.value;
1700
- var parameterName = match[0].slice(1, -1);
1701
- parameterNames.add(parameterName);
1702
- }
1703
- }
1704
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1705
- finally {
1706
- try {
1707
- if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
1708
- }
1709
- finally { if (e_1) throw e_1.error; }
1710
- }
1711
- return parameterNames;
1712
- }
1713
-
1714
1750
  /**
1715
1751
  * Parses the given script and returns the list of all used variables that are not defined in the script
1716
1752
  *
@@ -1766,12 +1802,12 @@
1766
1802
  * @returns the set of parameter names
1767
1803
  * @throws {ParsingError} if the script is invalid
1768
1804
  */
1769
- function extractParametersFromPromptTemplate(promptTemplate) {
1805
+ function extractParameterNamesFromPromptTemplate(promptTemplate) {
1770
1806
  var e_1, _a, e_2, _b, e_3, _c;
1771
- var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, jokerParameterNames = promptTemplate.jokerParameterNames;
1807
+ var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
1772
1808
  var parameterNames = new Set();
1773
1809
  try {
1774
- for (var _d = __values(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameters(title)), false), __read(extractParameters(description || '')), false), __read(extractParameters(content)), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
1810
+ 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()) {
1775
1811
  var parameterName = _e.value;
1776
1812
  parameterNames.add(parameterName);
1777
1813
  }
@@ -1811,6 +1847,8 @@
1811
1847
  }
1812
1848
  finally { if (e_3) throw e_3.error; }
1813
1849
  }
1850
+ parameterNames.delete('content');
1851
+ // <- Note {websiteContent} is used in `preparedContent`
1814
1852
  return parameterNames;
1815
1853
  }
1816
1854
  /**
@@ -1980,7 +2018,14 @@
1980
2018
  throw errors[0];
1981
2019
  }
1982
2020
  else if (errors.length > 1) {
1983
- throw new PipelineExecutionError(spaceTrim__default["default"](function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors.map(function (error) { return "- ".concat(error.name || 'Error', ": ").concat(error.message); }).join('\n')), "\n\n "); }));
2021
+ throw new PipelineExecutionError(
2022
+ // TODO: Tell which execution tools failed like
2023
+ // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
2024
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
2025
+ // 3) ...
2026
+ spaceTrim__default["default"](function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
2027
+ .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
2028
+ .join('\n')), "\n\n "); }));
1984
2029
  }
1985
2030
  else {
1986
2031
  throw new PipelineExecutionError(spaceTrim__default["default"](function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools
@@ -2185,6 +2230,10 @@
2185
2230
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
2186
2231
  throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
2187
2232
  }
2233
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
2234
+ // TODO: [🍵]
2235
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
2236
+ }
2188
2237
  }
2189
2238
  }
2190
2239
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -2447,7 +2496,7 @@
2447
2496
  console.warn(spaceTrim.spaceTrim("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n ").concat(rawPipeline.sourceFile, "\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
2448
2497
  }
2449
2498
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
2450
- // TODO: !!!!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2499
+ // TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2451
2500
  function getContextForTemplate(// <- TODO: [🧠][🥜]
2452
2501
  template) {
2453
2502
  return __awaiter(this, void 0, void 0, function () {
@@ -2498,6 +2547,7 @@
2498
2547
  currentDate = new Date().toISOString();
2499
2548
  modelName = RESERVED_PARAMETER_MISSING_VALUE;
2500
2549
  reservedParameters = {
2550
+ content: RESERVED_PARAMETER_RESTRICTED,
2501
2551
  context: context,
2502
2552
  knowledge: knowledge,
2503
2553
  samples: samples,
@@ -2551,7 +2601,7 @@
2551
2601
  _u.sent();
2552
2602
  _u.label = 2;
2553
2603
  case 2:
2554
- usedParameterNames = extractParametersFromPromptTemplate(currentTemplate);
2604
+ usedParameterNames = extractParameterNamesFromPromptTemplate(currentTemplate);
2555
2605
  dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
2556
2606
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
2557
2607
  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 ")));
@@ -2937,14 +2987,7 @@
2937
2987
  ) {
2938
2988
  // TODO: [🧠] Maybe put other blockTypes into report
2939
2989
  executionReport.promptExecutions.push({
2940
- prompt: {
2941
- title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */,
2942
- content: prompt.content,
2943
- modelRequirements: prompt.modelRequirements,
2944
- expectations: prompt.expectations,
2945
- expectFormat: prompt.expectFormat,
2946
- // <- Note: Do want to pass ONLY wanted information to the report
2947
- },
2990
+ 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 }),
2948
2991
  result: result || undefined,
2949
2992
  error: expectError || undefined,
2950
2993
  });
@@ -3208,6 +3251,8 @@
3208
3251
  return pipelineExecutor;
3209
3252
  }
3210
3253
  /**
3254
+ * TODO: !!!! return `preparedPipeline` from execution
3255
+ * TODO: !!!! `isNotPreparedWarningSupressed`
3211
3256
  * TODO: Use isVerbose here (not only pass to `preparePipeline`)
3212
3257
  * TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
3213
3258
  * TODO: [♈] Probbably move expectations from templates to parameters
@@ -3222,7 +3267,7 @@
3222
3267
  /**
3223
3268
  * @@@
3224
3269
  */
3225
- function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3270
+ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3226
3271
  return __awaiter(this, void 0, void 0, function () {
3227
3272
  var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
3228
3273
  var _f, _g, _h;
@@ -3260,7 +3305,7 @@
3260
3305
  llm: llmTools,
3261
3306
  },
3262
3307
  _h)]);
3263
- return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
3308
+ return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent })];
3264
3309
  case 4:
3265
3310
  result = _j.sent();
3266
3311
  assertsExecutionSuccessful(result);
@@ -3273,25 +3318,25 @@
3273
3318
  return [4 /*yield*/, Promise.all(
3274
3319
  // TODO: [🪂] !! Do not send all at once but in chunks
3275
3320
  knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
3276
- var name, title, content, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
3321
+ var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
3277
3322
  return __generator(this, function (_c) {
3278
3323
  switch (_c.label) {
3279
3324
  case 0:
3280
3325
  name = "piece-".concat(i);
3281
3326
  title = spaceTrim__default["default"](knowledgeTextPiece.substring(0, 100));
3282
- content = spaceTrim__default["default"](knowledgeTextPiece);
3327
+ knowledgePieceContent = spaceTrim__default["default"](knowledgeTextPiece);
3283
3328
  keywords = [];
3284
3329
  index = [];
3285
3330
  _c.label = 1;
3286
3331
  case 1:
3287
3332
  _c.trys.push([1, 7, , 8]);
3288
- return [4 /*yield*/, prepareTitleExecutor({ content: content })];
3333
+ return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent })];
3289
3334
  case 2:
3290
3335
  titleResult = _c.sent();
3291
3336
  _a = titleResult.outputParameters.title, titleRaw = _a === void 0 ? 'Untitled' : _a;
3292
3337
  title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
3293
3338
  name = titleToName(title);
3294
- return [4 /*yield*/, prepareKeywordsExecutor({ content: content })];
3339
+ return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent })];
3295
3340
  case 3:
3296
3341
  keywordsResult = _c.sent();
3297
3342
  _b = keywordsResult.outputParameters.keywords, keywordsRaw = _b === void 0 ? '' : _b;
@@ -3309,7 +3354,7 @@
3309
3354
  case 4: return [4 /*yield*/, llmTools.callEmbeddingModel({
3310
3355
  title: "Embedding for ".concat(title) /* <- Note: No impact on embedding result itself, just for logging */,
3311
3356
  parameters: {},
3312
- content: content,
3357
+ content: knowledgePieceContent,
3313
3358
  modelRequirements: {
3314
3359
  modelVariant: 'EMBEDDING',
3315
3360
  },
@@ -3330,7 +3375,7 @@
3330
3375
  case 8: return [2 /*return*/, {
3331
3376
  name: name,
3332
3377
  title: title,
3333
- content: content,
3378
+ content: knowledgePieceContent,
3334
3379
  keywords: keywords,
3335
3380
  index: index,
3336
3381
  // <- TODO: [☀] sources,
@@ -3496,14 +3541,18 @@
3496
3541
  TODO_USE(parameters);
3497
3542
  promptTemplatesPrepared = new Array(promptTemplates.length);
3498
3543
  return [4 /*yield*/, forEachAsync(promptTemplates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
3499
- var preparedContent, preparedTemplate;
3544
+ var dependentParameterNames, preparedContent, preparedTemplate;
3500
3545
  return __generator(this, function (_a) {
3546
+ dependentParameterNames = template.dependentParameterNames;
3501
3547
  preparedContent = undefined;
3502
- if (knowledgePiecesCount > 0) {
3548
+ if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
3503
3549
  preparedContent = spaceTrim.spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
3504
3550
  // <- TODO: [🧠][🧻] Cutomize shape/language/formatting of the addition to the prompt
3551
+ dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
3552
+ 'knowledge',
3553
+ ], false);
3505
3554
  }
3506
- preparedTemplate = __assign(__assign({}, template), { preparedContent: preparedContent });
3555
+ preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
3507
3556
  promptTemplatesPrepared[index] = preparedTemplate;
3508
3557
  return [2 /*return*/];
3509
3558
  });
@@ -4319,7 +4368,7 @@
4319
4368
  /**
4320
4369
  * Example usages of the PARAMETER command
4321
4370
  */
4322
- examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {content} Content of the book'],
4371
+ examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {websiteContent} Content of the book'],
4323
4372
  /**
4324
4373
  * Parses the PARAMETER command
4325
4374
  */
@@ -4418,11 +4467,8 @@
4418
4467
  /**
4419
4468
  * Name of the command
4420
4469
  */
4421
- name: 'VERSION',
4422
- /*
4423
- Note: [📇] No need to put here "PROMPTBOOK" alias here
4424
- aliasNames: ['PROMPTBOOK_VERSION'],
4425
- */
4470
+ name: 'PROMPTBOOK_VERSION',
4471
+ aliasNames: ['PTBK_VERSION', 'PTBK_V', 'PTBKV'],
4426
4472
  /**
4427
4473
  * BOILERPLATE command can be used in:
4428
4474
  */
@@ -4438,7 +4484,7 @@
4438
4484
  /**
4439
4485
  * Example usages of the PROMPTBOOK_VERSION command
4440
4486
  */
4441
- examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "VERSION ".concat(PROMPTBOOK_VERSION)],
4487
+ examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "PTBKV ".concat(PROMPTBOOK_VERSION)],
4442
4488
  /**
4443
4489
  * Parses the PROMPTBOOK_VERSION command
4444
4490
  */
@@ -4472,8 +4518,9 @@
4472
4518
  * Name of the command
4473
4519
  */
4474
4520
  name: 'URL',
4521
+ aliasNames: ['PIPELINE_URL'],
4475
4522
  /*
4476
- Note: [🛵] No need for alias name because it is already preprocessed
4523
+ Note: [🛵] No need for this alias name because it is already preprocessed
4477
4524
  aliasNames: ['HTTPS'],
4478
4525
  */
4479
4526
  /**
@@ -4492,6 +4539,7 @@
4492
4539
  * Example usages of the URL command
4493
4540
  */
4494
4541
  examples: [
4542
+ 'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
4495
4543
  'URL https://promptbook.studio/library/write-cv.ptbk.md',
4496
4544
  'https://promptbook.studio/library/write-cv.ptbk.md',
4497
4545
  ],
@@ -4730,10 +4778,6 @@
4730
4778
  .split(' ')
4731
4779
  .map(function (part) { return part.trim(); })
4732
4780
  .filter(function (item) { return item !== ''; })
4733
- // Note: [📇]:
4734
- .filter(function (item) { return !/^PTBK$/i.test(item); })
4735
- .filter(function (item) { return !/^PIPELINE$/i.test(item); })
4736
- .filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
4737
4781
  .map(removeMarkdownFormatting)
4738
4782
  .map(function (item) { return item.trim(); });
4739
4783
  if (items.length === 0 || items[0] === '') {
@@ -5448,7 +5492,7 @@
5448
5492
  if (templateModelRequirements.modelVariant === undefined) {
5449
5493
  templateModelRequirements.modelVariant = 'CHAT';
5450
5494
  }
5451
- templateJson.dependentParameterNames = Array.from(extractParametersFromPromptTemplate(templateJson));
5495
+ templateJson.dependentParameterNames = Array.from(extractParameterNamesFromPromptTemplate(templateJson));
5452
5496
  // TODO: [🍧][❔] Remove this condition - modelRequirements should be put here via BLOCK command not removed when PROMPT_TEMPLATE
5453
5497
  if (templateJson.blockType !== 'PROMPT_TEMPLATE') {
5454
5498
  delete templateJson.modelRequirements;