@promptbook/node 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/esm/index.es.js CHANGED
@@ -194,6 +194,7 @@ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
194
194
  * The names of the parameters that are reserved for special purposes
195
195
  */
196
196
  var RESERVED_PARAMETER_NAMES = deepFreeze([
197
+ 'content',
197
198
  'context',
198
199
  'knowledge',
199
200
  'samples',
@@ -206,6 +207,10 @@ var RESERVED_PARAMETER_NAMES = deepFreeze([
206
207
  * @@@
207
208
  */
208
209
  var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
210
+ /**
211
+ * @@@
212
+ */
213
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
209
214
  /*
210
215
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
211
216
  */
@@ -649,7 +654,7 @@ function forEachAsync(array, options, callbackfunction) {
649
654
  });
650
655
  }
651
656
 
652
- 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"}];
657
+ 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"}];
653
658
 
654
659
  /**
655
660
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -852,52 +857,63 @@ function isValidPipelineUrl(url) {
852
857
  */
853
858
  function validatePipeline(pipeline) {
854
859
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
855
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
860
+ var e_1, _a, e_2, _b, e_3, _c;
861
+ var pipelineIdentification = (function () {
862
+ // Note: This is a 😐 implementation of [🚞]
863
+ var _ = [];
864
+ if (pipeline.sourceFile !== undefined) {
865
+ _.push("File: ".concat(pipeline.sourceFile));
866
+ }
867
+ if (pipeline.pipelineUrl !== undefined) {
868
+ _.push("Url: ".concat(pipeline.pipelineUrl));
869
+ }
870
+ return _.join('\n');
871
+ })();
856
872
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
857
873
  // <- Note: [🚲]
858
- throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\""));
874
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
859
875
  }
860
876
  if (!isValidPromptbookVersion(pipeline.promptbookVersion)) {
861
877
  // <- Note: [🚲]
862
- throw new PipelineLogicError("Invalid promptbook Version \"".concat(pipeline.pipelineUrl, "\""));
878
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
863
879
  }
864
880
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
865
881
  if (!Array.isArray(pipeline.parameters)) {
866
882
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
867
- throw new ParsingError(spaceTrim$1("\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 ")));
883
+ throw new ParsingError(spaceTrim$1(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 "); }));
868
884
  }
869
885
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
870
886
  if (!Array.isArray(pipeline.promptTemplates)) {
871
887
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
872
- throw new ParsingError(spaceTrim$1("\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 ")));
888
+ throw new ParsingError(spaceTrim$1(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 "); }));
873
889
  }
874
890
  var _loop_1 = function (parameter) {
875
891
  if (parameter.isInput && parameter.isOutput) {
876
- throw new PipelineLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
892
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
877
893
  }
878
894
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
879
895
  if (!parameter.isInput &&
880
896
  !parameter.isOutput &&
881
897
  !pipeline.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
882
- throw new PipelineLogicError(spaceTrim$1("\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 ")));
898
+ throw new PipelineLogicError(spaceTrim$1(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 "); }));
883
899
  }
884
900
  // Note: Testing that parameter is either input or result of some template
885
901
  if (!parameter.isInput &&
886
902
  !pipeline.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
887
- throw new PipelineLogicError(spaceTrim$1("\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 ")));
903
+ throw new PipelineLogicError(spaceTrim$1(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 "); }));
888
904
  }
889
905
  };
890
906
  try {
891
907
  // Note: Check each parameter individually
892
- for (var _f = __values(pipeline.parameters), _g = _f.next(); !_g.done; _g = _f.next()) {
893
- var parameter = _g.value;
908
+ for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
909
+ var parameter = _e.value;
894
910
  _loop_1(parameter);
895
911
  }
896
912
  }
897
913
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
898
914
  finally {
899
915
  try {
900
- if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
916
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
901
917
  }
902
918
  finally { if (e_1) throw e_1.error; }
903
919
  }
@@ -909,70 +925,80 @@ function validatePipeline(pipeline) {
909
925
  var name = _a.name;
910
926
  return name;
911
927
  }));
912
- try {
913
- // Note: Checking each template individually
914
- for (var _h = __values(pipeline.promptTemplates), _j = _h.next(); !_j.done; _j = _h.next()) {
915
- var template = _j.value;
916
- if (definedParameters.has(template.resultingParameterName)) {
917
- throw new PipelineLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
928
+ var _loop_2 = function (template) {
929
+ var e_4, _h, e_5, _j;
930
+ if (definedParameters.has(template.resultingParameterName)) {
931
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
932
+ }
933
+ if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
934
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
935
+ }
936
+ definedParameters.add(template.resultingParameterName);
937
+ if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
938
+ throw new PipelineLogicError(spaceTrim$1(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 "); }));
939
+ }
940
+ if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
941
+ if (!template.expectFormat &&
942
+ !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
943
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
918
944
  }
919
- if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
920
- throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name"));
945
+ var _loop_4 = function (joker) {
946
+ if (!template.dependentParameterNames.includes(joker)) {
947
+ throw new PipelineLogicError(spaceTrim$1(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 "); }));
948
+ }
949
+ };
950
+ try {
951
+ for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
952
+ var joker = _l.value;
953
+ _loop_4(joker);
954
+ }
921
955
  }
922
- definedParameters.add(template.resultingParameterName);
923
- if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
924
- throw new PipelineLogicError(spaceTrim$1("\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 ")));
956
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
957
+ finally {
958
+ try {
959
+ if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
960
+ }
961
+ finally { if (e_4) throw e_4.error; }
925
962
  }
926
- if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
927
- if (!template.expectFormat &&
928
- !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
929
- throw new PipelineLogicError("Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined"));
963
+ }
964
+ if (template.expectations) {
965
+ var _loop_5 = function (unit, min, max) {
966
+ if (min !== undefined && max !== undefined && min > max) {
967
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
930
968
  }
931
- try {
932
- for (var _k = (e_3 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
933
- var joker = _l.value;
934
- if (!template.dependentParameterNames.includes(joker)) {
935
- throw new PipelineLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
936
- }
937
- }
969
+ if (min !== undefined && min < 0) {
970
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation of ".concat(unit, " must be zero or positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
938
971
  }
939
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
940
- finally {
941
- try {
942
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
943
- }
944
- finally { if (e_3) throw e_3.error; }
972
+ if (max !== undefined && max <= 0) {
973
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Max expectation of ".concat(unit, " must be positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
974
+ }
975
+ };
976
+ try {
977
+ for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
978
+ var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
979
+ _loop_5(unit, min, max);
945
980
  }
946
981
  }
947
- if (template.expectations) {
982
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
983
+ finally {
948
984
  try {
949
- for (var _m = (e_4 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
950
- var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
951
- if (min !== undefined && max !== undefined && min > max) {
952
- throw new PipelineLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
953
- }
954
- if (min !== undefined && min < 0) {
955
- throw new PipelineLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
956
- }
957
- if (max !== undefined && max <= 0) {
958
- throw new PipelineLogicError("Max expectation of ".concat(unit, " must be positive"));
959
- }
960
- }
961
- }
962
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
963
- finally {
964
- try {
965
- if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
966
- }
967
- finally { if (e_4) throw e_4.error; }
985
+ if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
968
986
  }
987
+ finally { if (e_5) throw e_5.error; }
969
988
  }
970
989
  }
990
+ };
991
+ try {
992
+ // Note: Checking each template individually
993
+ for (var _f = __values(pipeline.promptTemplates), _g = _f.next(); !_g.done; _g = _f.next()) {
994
+ var template = _g.value;
995
+ _loop_2(template);
996
+ }
971
997
  }
972
998
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
973
999
  finally {
974
1000
  try {
975
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
1001
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
976
1002
  }
977
1003
  finally { if (e_2) throw e_2.error; }
978
1004
  }
@@ -993,20 +1019,20 @@ function validatePipeline(pipeline) {
993
1019
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), [reservedParameterName], false);
994
1020
  }
995
1021
  }
996
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1022
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
997
1023
  finally {
998
1024
  try {
999
- if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (_e = RESERVED_PARAMETER_NAMES_1.return)) _e.call(RESERVED_PARAMETER_NAMES_1);
1025
+ if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (_c = RESERVED_PARAMETER_NAMES_1.return)) _c.call(RESERVED_PARAMETER_NAMES_1);
1000
1026
  }
1001
- finally { if (e_5) throw e_5.error; }
1027
+ finally { if (e_3) throw e_3.error; }
1002
1028
  }
1003
1029
  var unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
1004
1030
  // <- TODO: [🧠][🥜]
1005
1031
  var loopLimit = LOOP_LIMIT;
1006
- var _loop_2 = function () {
1032
+ var _loop_3 = function () {
1007
1033
  if (loopLimit-- < 0) {
1008
1034
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1009
- throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
1035
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
1010
1036
  }
1011
1037
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1012
1038
  return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
@@ -1021,7 +1047,7 @@ function validatePipeline(pipeline) {
1021
1047
  .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1022
1048
  .join(' and '));
1023
1049
  })
1024
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n "); }));
1050
+ .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1025
1051
  }
1026
1052
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1027
1053
  var resultingParameterName = _a.resultingParameterName;
@@ -1030,7 +1056,7 @@ function validatePipeline(pipeline) {
1030
1056
  unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
1031
1057
  };
1032
1058
  while (unresovedTemplates.length > 0) {
1033
- _loop_2();
1059
+ _loop_3();
1034
1060
  }
1035
1061
  return pipeline;
1036
1062
  }
@@ -1083,6 +1109,36 @@ var ReferenceError$1 = /** @class */ (function (_super) {
1083
1109
  return ReferenceError;
1084
1110
  }(Error));
1085
1111
 
1112
+ /**
1113
+ * Parses the template and returns the list of all parameter names
1114
+ *
1115
+ * @param template the template with parameters in {curly} braces
1116
+ * @returns the list of parameter names
1117
+ */
1118
+ function extractParameterNames(template) {
1119
+ var e_1, _a;
1120
+ var matches = template.matchAll(/{\w+}/g);
1121
+ var parameterNames = new Set();
1122
+ try {
1123
+ for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
1124
+ var match = matches_1_1.value;
1125
+ var parameterName = match[0].slice(1, -1);
1126
+ parameterNames.add(parameterName);
1127
+ }
1128
+ }
1129
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1130
+ finally {
1131
+ try {
1132
+ if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
1133
+ }
1134
+ finally { if (e_1) throw e_1.error; }
1135
+ }
1136
+ return parameterNames;
1137
+ }
1138
+ /**
1139
+ * TODO: !!!!! Rename to extractParameterNames
1140
+ */
1141
+
1086
1142
  /**
1087
1143
  * Unprepare just strips the preparation data of the pipeline
1088
1144
  */
@@ -1090,7 +1146,14 @@ function unpreparePipeline(pipeline) {
1090
1146
  var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, promptTemplates = pipeline.promptTemplates;
1091
1147
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
1092
1148
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
1093
- promptTemplates = promptTemplates.map(function (promptTemplate) { return (__assign(__assign({}, promptTemplate), { preparedContent: undefined })); });
1149
+ promptTemplates = promptTemplates.map(function (promptTemplate) {
1150
+ var dependentParameterNames = promptTemplate.dependentParameterNames;
1151
+ var parameterNames = extractParameterNames(promptTemplate.preparedContent || '');
1152
+ dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
1153
+ var promptTemplateUnprepared = __assign(__assign({}, promptTemplate), { dependentParameterNames: dependentParameterNames });
1154
+ delete promptTemplateUnprepared.preparedContent;
1155
+ return promptTemplateUnprepared;
1156
+ });
1094
1157
  return __assign(__assign({}, pipeline), { promptTemplates: promptTemplates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
1095
1158
  }
1096
1159
  /**
@@ -1587,33 +1650,6 @@ function assertsExecutionSuccessful(executionResult) {
1587
1650
  * TODO: [🧠] Can this return type be better typed than void
1588
1651
  */
1589
1652
 
1590
- /**
1591
- * Parses the template and returns the list of all parameter names
1592
- *
1593
- * @param template the template with parameters in {curly} braces
1594
- * @returns the list of parameter names
1595
- */
1596
- function extractParameters(template) {
1597
- var e_1, _a;
1598
- var matches = template.matchAll(/{\w+}/g);
1599
- var parameterNames = new Set();
1600
- try {
1601
- for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
1602
- var match = matches_1_1.value;
1603
- var parameterName = match[0].slice(1, -1);
1604
- parameterNames.add(parameterName);
1605
- }
1606
- }
1607
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1608
- finally {
1609
- try {
1610
- if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
1611
- }
1612
- finally { if (e_1) throw e_1.error; }
1613
- }
1614
- return parameterNames;
1615
- }
1616
-
1617
1653
  /**
1618
1654
  * Parses the given script and returns the list of all used variables that are not defined in the script
1619
1655
  *
@@ -1669,12 +1705,12 @@ function extractVariables(script) {
1669
1705
  * @returns the set of parameter names
1670
1706
  * @throws {ParsingError} if the script is invalid
1671
1707
  */
1672
- function extractParametersFromPromptTemplate(promptTemplate) {
1708
+ function extractParameterNamesFromPromptTemplate(promptTemplate) {
1673
1709
  var e_1, _a, e_2, _b, e_3, _c;
1674
- var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, jokerParameterNames = promptTemplate.jokerParameterNames;
1710
+ var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
1675
1711
  var parameterNames = new Set();
1676
1712
  try {
1677
- 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()) {
1713
+ 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()) {
1678
1714
  var parameterName = _e.value;
1679
1715
  parameterNames.add(parameterName);
1680
1716
  }
@@ -1714,6 +1750,8 @@ function extractParametersFromPromptTemplate(promptTemplate) {
1714
1750
  }
1715
1751
  finally { if (e_3) throw e_3.error; }
1716
1752
  }
1753
+ parameterNames.delete('content');
1754
+ // <- Note {websiteContent} is used in `preparedContent`
1717
1755
  return parameterNames;
1718
1756
  }
1719
1757
  /**
@@ -1883,7 +1921,14 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
1883
1921
  throw errors[0];
1884
1922
  }
1885
1923
  else if (errors.length > 1) {
1886
- throw new PipelineExecutionError(spaceTrim(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 "); }));
1924
+ throw new PipelineExecutionError(
1925
+ // TODO: Tell which execution tools failed like
1926
+ // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
1927
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
1928
+ // 3) ...
1929
+ spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
1930
+ .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
1931
+ .join('\n')), "\n\n "); }));
1887
1932
  }
1888
1933
  else {
1889
1934
  throw new PipelineExecutionError(spaceTrim(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
@@ -2088,6 +2133,10 @@ function replaceParameters(template, parameters) {
2088
2133
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
2089
2134
  throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
2090
2135
  }
2136
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
2137
+ // TODO: [🍵]
2138
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
2139
+ }
2091
2140
  }
2092
2141
  }
2093
2142
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -2222,7 +2271,7 @@ function union() {
2222
2271
  /**
2223
2272
  * The version of the Promptbook library
2224
2273
  */
2225
- var PROMPTBOOK_VERSION = '0.61.0-23';
2274
+ var PROMPTBOOK_VERSION = '0.61.0-25';
2226
2275
  // TODO: !!!! List here all the versions and annotate + put into script
2227
2276
 
2228
2277
  /**
@@ -2356,7 +2405,7 @@ function createPipelineExecutor(options) {
2356
2405
  console.warn(spaceTrim$1("\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 ")));
2357
2406
  }
2358
2407
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
2359
- // TODO: !!!!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2408
+ // TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2360
2409
  function getContextForTemplate(// <- TODO: [🧠][🥜]
2361
2410
  template) {
2362
2411
  return __awaiter(this, void 0, void 0, function () {
@@ -2407,6 +2456,7 @@ function createPipelineExecutor(options) {
2407
2456
  currentDate = new Date().toISOString();
2408
2457
  modelName = RESERVED_PARAMETER_MISSING_VALUE;
2409
2458
  reservedParameters = {
2459
+ content: RESERVED_PARAMETER_RESTRICTED,
2410
2460
  context: context,
2411
2461
  knowledge: knowledge,
2412
2462
  samples: samples,
@@ -2460,7 +2510,7 @@ function createPipelineExecutor(options) {
2460
2510
  _u.sent();
2461
2511
  _u.label = 2;
2462
2512
  case 2:
2463
- usedParameterNames = extractParametersFromPromptTemplate(currentTemplate);
2513
+ usedParameterNames = extractParameterNamesFromPromptTemplate(currentTemplate);
2464
2514
  dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
2465
2515
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
2466
2516
  throw new UnexpectedError(spaceTrim$1("\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 ")));
@@ -2846,14 +2896,7 @@ function createPipelineExecutor(options) {
2846
2896
  ) {
2847
2897
  // TODO: [🧠] Maybe put other blockTypes into report
2848
2898
  executionReport.promptExecutions.push({
2849
- prompt: {
2850
- title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */,
2851
- content: prompt.content,
2852
- modelRequirements: prompt.modelRequirements,
2853
- expectations: prompt.expectations,
2854
- expectFormat: prompt.expectFormat,
2855
- // <- Note: Do want to pass ONLY wanted information to the report
2856
- },
2899
+ 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 }),
2857
2900
  result: result || undefined,
2858
2901
  error: expectError || undefined,
2859
2902
  });
@@ -3117,6 +3160,8 @@ function createPipelineExecutor(options) {
3117
3160
  return pipelineExecutor;
3118
3161
  }
3119
3162
  /**
3163
+ * TODO: !!!! return `preparedPipeline` from execution
3164
+ * TODO: !!!! `isNotPreparedWarningSupressed`
3120
3165
  * TODO: Use isVerbose here (not only pass to `preparePipeline`)
3121
3166
  * TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
3122
3167
  * TODO: [♈] Probbably move expectations from templates to parameters
@@ -3131,7 +3176,7 @@ function createPipelineExecutor(options) {
3131
3176
  /**
3132
3177
  * @@@
3133
3178
  */
3134
- function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3179
+ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3135
3180
  return __awaiter(this, void 0, void 0, function () {
3136
3181
  var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
3137
3182
  var _f, _g, _h;
@@ -3169,7 +3214,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3169
3214
  llm: llmTools,
3170
3215
  },
3171
3216
  _h)]);
3172
- return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
3217
+ return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent })];
3173
3218
  case 4:
3174
3219
  result = _j.sent();
3175
3220
  assertsExecutionSuccessful(result);
@@ -3182,25 +3227,25 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3182
3227
  return [4 /*yield*/, Promise.all(
3183
3228
  // TODO: [🪂] !! Do not send all at once but in chunks
3184
3229
  knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
3185
- var name, title, content, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
3230
+ var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
3186
3231
  return __generator(this, function (_c) {
3187
3232
  switch (_c.label) {
3188
3233
  case 0:
3189
3234
  name = "piece-".concat(i);
3190
3235
  title = spaceTrim(knowledgeTextPiece.substring(0, 100));
3191
- content = spaceTrim(knowledgeTextPiece);
3236
+ knowledgePieceContent = spaceTrim(knowledgeTextPiece);
3192
3237
  keywords = [];
3193
3238
  index = [];
3194
3239
  _c.label = 1;
3195
3240
  case 1:
3196
3241
  _c.trys.push([1, 7, , 8]);
3197
- return [4 /*yield*/, prepareTitleExecutor({ content: content })];
3242
+ return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent })];
3198
3243
  case 2:
3199
3244
  titleResult = _c.sent();
3200
3245
  _a = titleResult.outputParameters.title, titleRaw = _a === void 0 ? 'Untitled' : _a;
3201
3246
  title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
3202
3247
  name = titleToName(title);
3203
- return [4 /*yield*/, prepareKeywordsExecutor({ content: content })];
3248
+ return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent })];
3204
3249
  case 3:
3205
3250
  keywordsResult = _c.sent();
3206
3251
  _b = keywordsResult.outputParameters.keywords, keywordsRaw = _b === void 0 ? '' : _b;
@@ -3218,7 +3263,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3218
3263
  case 4: return [4 /*yield*/, llmTools.callEmbeddingModel({
3219
3264
  title: "Embedding for ".concat(title) /* <- Note: No impact on embedding result itself, just for logging */,
3220
3265
  parameters: {},
3221
- content: content,
3266
+ content: knowledgePieceContent,
3222
3267
  modelRequirements: {
3223
3268
  modelVariant: 'EMBEDDING',
3224
3269
  },
@@ -3239,7 +3284,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3239
3284
  case 8: return [2 /*return*/, {
3240
3285
  name: name,
3241
3286
  title: title,
3242
- content: content,
3287
+ content: knowledgePieceContent,
3243
3288
  keywords: keywords,
3244
3289
  index: index,
3245
3290
  // <- TODO: [☀] sources,
@@ -3405,14 +3450,18 @@ function prepareTemplates(pipeline, options) {
3405
3450
  TODO_USE(parameters);
3406
3451
  promptTemplatesPrepared = new Array(promptTemplates.length);
3407
3452
  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 () {
3408
- var preparedContent, preparedTemplate;
3453
+ var dependentParameterNames, preparedContent, preparedTemplate;
3409
3454
  return __generator(this, function (_a) {
3455
+ dependentParameterNames = template.dependentParameterNames;
3410
3456
  preparedContent = undefined;
3411
- if (knowledgePiecesCount > 0) {
3457
+ if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
3412
3458
  preparedContent = spaceTrim$1("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
3413
3459
  // <- TODO: [🧠][🧻] Cutomize shape/language/formatting of the addition to the prompt
3460
+ dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
3461
+ 'knowledge',
3462
+ ], false);
3414
3463
  }
3415
- preparedTemplate = __assign(__assign({}, template), { preparedContent: preparedContent });
3464
+ preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
3416
3465
  promptTemplatesPrepared[index] = preparedTemplate;
3417
3466
  return [2 /*return*/];
3418
3467
  });
@@ -4228,7 +4277,7 @@ var parameterCommandParser = {
4228
4277
  /**
4229
4278
  * Example usages of the PARAMETER command
4230
4279
  */
4231
- examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {content} Content of the book'],
4280
+ examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {websiteContent} Content of the book'],
4232
4281
  /**
4233
4282
  * Parses the PARAMETER command
4234
4283
  */
@@ -4327,11 +4376,8 @@ var promptbookVersionCommandParser = {
4327
4376
  /**
4328
4377
  * Name of the command
4329
4378
  */
4330
- name: 'VERSION',
4331
- /*
4332
- Note: [📇] No need to put here "PROMPTBOOK" alias here
4333
- aliasNames: ['PROMPTBOOK_VERSION'],
4334
- */
4379
+ name: 'PROMPTBOOK_VERSION',
4380
+ aliasNames: ['PTBK_VERSION', 'PTBK_V', 'PTBKV'],
4335
4381
  /**
4336
4382
  * BOILERPLATE command can be used in:
4337
4383
  */
@@ -4347,7 +4393,7 @@ var promptbookVersionCommandParser = {
4347
4393
  /**
4348
4394
  * Example usages of the PROMPTBOOK_VERSION command
4349
4395
  */
4350
- examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "VERSION ".concat(PROMPTBOOK_VERSION)],
4396
+ examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "PTBKV ".concat(PROMPTBOOK_VERSION)],
4351
4397
  /**
4352
4398
  * Parses the PROMPTBOOK_VERSION command
4353
4399
  */
@@ -4381,8 +4427,9 @@ var urlCommandParser = {
4381
4427
  * Name of the command
4382
4428
  */
4383
4429
  name: 'URL',
4430
+ aliasNames: ['PIPELINE_URL'],
4384
4431
  /*
4385
- Note: [🛵] No need for alias name because it is already preprocessed
4432
+ Note: [🛵] No need for this alias name because it is already preprocessed
4386
4433
  aliasNames: ['HTTPS'],
4387
4434
  */
4388
4435
  /**
@@ -4401,6 +4448,7 @@ var urlCommandParser = {
4401
4448
  * Example usages of the URL command
4402
4449
  */
4403
4450
  examples: [
4451
+ 'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
4404
4452
  'URL https://promptbook.studio/library/write-cv.ptbk.md',
4405
4453
  'https://promptbook.studio/library/write-cv.ptbk.md',
4406
4454
  ],
@@ -4639,10 +4687,6 @@ function parseCommand(raw, usagePlace) {
4639
4687
  .split(' ')
4640
4688
  .map(function (part) { return part.trim(); })
4641
4689
  .filter(function (item) { return item !== ''; })
4642
- // Note: [📇]:
4643
- .filter(function (item) { return !/^PTBK$/i.test(item); })
4644
- .filter(function (item) { return !/^PIPELINE$/i.test(item); })
4645
- .filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
4646
4690
  .map(removeMarkdownFormatting)
4647
4691
  .map(function (item) { return item.trim(); });
4648
4692
  if (items.length === 0 || items[0] === '') {
@@ -5357,7 +5401,7 @@ function pipelineStringToJsonSync(pipelineString) {
5357
5401
  if (templateModelRequirements.modelVariant === undefined) {
5358
5402
  templateModelRequirements.modelVariant = 'CHAT';
5359
5403
  }
5360
- templateJson.dependentParameterNames = Array.from(extractParametersFromPromptTemplate(templateJson));
5404
+ templateJson.dependentParameterNames = Array.from(extractParameterNamesFromPromptTemplate(templateJson));
5361
5405
  // TODO: [🍧][❔] Remove this condition - modelRequirements should be put here via BLOCK command not removed when PROMPT_TEMPLATE
5362
5406
  if (templateJson.blockType !== 'PROMPT_TEMPLATE') {
5363
5407
  delete templateJson.modelRequirements;