@promptbook/node 0.67.5 → 0.67.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.67.5",
3
+ "version": "0.67.7",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,7 +47,7 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.67.5"
50
+ "@promptbook/core": "0.67.7"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * The version of the Promptbook library
37
37
  */
38
- var PROMPTBOOK_VERSION = '0.67.4';
38
+ var PROMPTBOOK_VERSION = '0.67.6';
39
39
  // TODO: !!!! List here all the versions and annotate + put into script
40
40
 
41
41
  /*! *****************************************************************************
@@ -889,7 +889,7 @@
889
889
  });
890
890
  }
891
891
 
892
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.4",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.67.4",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.67.4",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.67.4",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"},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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
892
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.6",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.67.6",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.67.6",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.67.6",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"},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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
893
893
 
894
894
  /**
895
895
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -5781,6 +5781,17 @@
5781
5781
  personas: [],
5782
5782
  preparations: [],
5783
5783
  };
5784
+ function getPipelineIdentification() {
5785
+ // Note: This is a 😐 implementation of [🚞]
5786
+ var _ = [];
5787
+ if (pipelineJson.sourceFile !== undefined) {
5788
+ _.push("File: ".concat(pipelineJson.sourceFile));
5789
+ }
5790
+ if (pipelineJson.pipelineUrl !== undefined) {
5791
+ _.push("Url: ".concat(pipelineJson.pipelineUrl));
5792
+ }
5793
+ return _.join('\n');
5794
+ }
5784
5795
  // =============================================================
5785
5796
  // Note: 1️⃣ Parsing of the markdown into object
5786
5797
  pipelineString = removeContentComments(pipelineString);
@@ -5789,27 +5800,27 @@
5789
5800
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
5790
5801
  var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
5791
5802
  if (pipelineHead === undefined) {
5792
- throw new UnexpectedError(spaceTrim.spaceTrim("\n Pipeline head is not defined\n\n This should never happen, because the pipeline already flattened\n "));
5803
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5793
5804
  }
5794
5805
  if (pipelineHead.level !== 1) {
5795
- throw new UnexpectedError(spaceTrim.spaceTrim("\n Pipeline head is not h1\n\n This should never happen, because the pipeline already flattened\n "));
5806
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5796
5807
  }
5797
5808
  if (!pipelineSections.every(function (section) { return section.level === 2; })) {
5798
- throw new UnexpectedError(spaceTrim.spaceTrim("\n Not every pipeline section is h2\n\n This should never happen, because the pipeline already flattened\n "));
5809
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5799
5810
  }
5800
5811
  // =============================================================
5801
5812
  ///Note: 2️⃣ Function for defining parameters
5802
5813
  var defineParam = function (parameterCommand) {
5803
5814
  var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
5804
5815
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
5805
- throw new ParsingError("Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name") /* <- TODO: [🚞] */);
5816
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(getPipelineIdentification()), "\n "); }) /* <- TODO: [🚞] */);
5806
5817
  }
5807
5818
  var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
5808
5819
  if (existingParameter &&
5809
5820
  existingParameter.description &&
5810
5821
  existingParameter.description !== parameterDescription &&
5811
5822
  parameterDescription) {
5812
- throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
5823
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
5813
5824
  }
5814
5825
  if (existingParameter) {
5815
5826
  if (parameterDescription) {
@@ -5842,44 +5853,46 @@
5842
5853
  pipelineJson.description = description;
5843
5854
  var defaultModelRequirements = {};
5844
5855
  var listItems = extractAllListItemsFromMarkdown(pipelineHead.content);
5856
+ var _loop_1 = function (listItem) {
5857
+ var command = parseCommand(listItem, 'PIPELINE_HEAD');
5858
+ switch (command.type) {
5859
+ // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
5860
+ case 'MODEL':
5861
+ defaultModelRequirements[command.key] = command.value;
5862
+ break;
5863
+ case 'PARAMETER':
5864
+ defineParam(command);
5865
+ break;
5866
+ case 'PROMPTBOOK_VERSION':
5867
+ pipelineJson.promptbookVersion = command.promptbookVersion;
5868
+ break;
5869
+ case 'URL':
5870
+ pipelineJson.pipelineUrl = command.pipelineUrl.href;
5871
+ break;
5872
+ case 'KNOWLEDGE':
5873
+ knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
5874
+ break;
5875
+ case 'ACTION':
5876
+ console.error(new NotYetImplementedError('Actions are not implemented yet'));
5877
+ break;
5878
+ case 'INSTRUMENT':
5879
+ console.error(new NotYetImplementedError('Instruments are not implemented yet'));
5880
+ break;
5881
+ case 'PERSONA':
5882
+ personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
5883
+ // <- Note: Prototype of [🍧] (remove this comment after full implementation)
5884
+ break;
5885
+ case 'BOILERPLATE':
5886
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
5887
+ // <- [💐]
5888
+ default:
5889
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
5890
+ }
5891
+ };
5845
5892
  try {
5846
5893
  for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
5847
5894
  var listItem = listItems_1_1.value;
5848
- var command = parseCommand(listItem, 'PIPELINE_HEAD');
5849
- switch (command.type) {
5850
- // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
5851
- case 'MODEL':
5852
- defaultModelRequirements[command.key] = command.value;
5853
- break;
5854
- case 'PARAMETER':
5855
- defineParam(command);
5856
- break;
5857
- case 'PROMPTBOOK_VERSION':
5858
- pipelineJson.promptbookVersion = command.promptbookVersion;
5859
- break;
5860
- case 'URL':
5861
- pipelineJson.pipelineUrl = command.pipelineUrl.href;
5862
- break;
5863
- case 'KNOWLEDGE':
5864
- knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
5865
- break;
5866
- case 'ACTION':
5867
- console.error(new NotYetImplementedError('Actions are not implemented yet'));
5868
- break;
5869
- case 'INSTRUMENT':
5870
- console.error(new NotYetImplementedError('Instruments are not implemented yet'));
5871
- break;
5872
- case 'PERSONA':
5873
- personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
5874
- // <- Note: Prototype of [🍧] (remove this comment after full implementation)
5875
- break;
5876
- case 'BOILERPLATE':
5877
- throw new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'); // <- TODO: [🚞]
5878
- break;
5879
- // <- [💐]
5880
- default:
5881
- throw new ParsingError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template")); // <- TODO: [🚞]
5882
- }
5895
+ _loop_1(listItem);
5883
5896
  }
5884
5897
  }
5885
5898
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -5889,7 +5902,7 @@
5889
5902
  }
5890
5903
  finally { if (e_1) throw e_1.error; }
5891
5904
  }
5892
- var _loop_1 = function (section) {
5905
+ var _loop_2 = function (section) {
5893
5906
  var e_3, _d;
5894
5907
  // TODO: Parse prompt template description (the content out of the codeblock and lists)
5895
5908
  var templateModelRequirements = __assign({}, defaultModelRequirements);
@@ -5906,7 +5919,7 @@
5906
5919
  if (resultingParameterName !== null) {
5907
5920
  return resultingParameterName;
5908
5921
  }
5909
- throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n Invalid section:\n ".concat(block(
5922
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
5910
5923
  // TODO: Show code of invalid sections each time + DRY
5911
5924
  section.content
5912
5925
  .split('\n')
@@ -5942,110 +5955,116 @@
5942
5955
  * Note: [2]
5943
5956
  */
5944
5957
  var isBlockTypeSet = false;
5945
- try {
5946
- for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
5947
- var listItem = listItems_2_1.value;
5948
- var command = parseCommand(listItem, 'PIPELINE_TEMPLATE');
5949
- // TODO [🍧][♓️] List commands and before apply order them
5950
- switch (command.type) {
5951
- // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
5952
- case 'BLOCK':
5953
- if (isBlockTypeSet) {
5954
- throw new ParsingError('Block type is already defined in the prompt template. It can be defined only once.');
5955
- }
5956
- if (command.blockType === 'SAMPLE') {
5957
- expectResultingParameterName();
5958
- var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
5959
- if (parameter === undefined) {
5960
- throw new UnexpectedError("Can not find parameter {".concat(resultingParameterName, "} to assign sample value"));
5961
- }
5962
- parameter.sampleValues = parameter.sampleValues || [];
5963
- parameter.sampleValues.push(content);
5964
- return "continue-templates";
5965
- }
5966
- if (command.blockType === 'KNOWLEDGE') {
5967
- knowledgeCommandParser.applyToPipelineJson({
5968
- type: 'KNOWLEDGE',
5969
- sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5970
- }, {
5971
- pipelineJson: pipelineJson,
5972
- templateJson: templateJson,
5973
- });
5974
- return "continue-templates";
5975
- }
5976
- if (command.blockType === 'ACTION') {
5977
- console.error(new NotYetImplementedError('Actions are not implemented yet'));
5978
- return "continue-templates";
5979
- }
5980
- if (command.blockType === 'INSTRUMENT') {
5981
- console.error(new NotYetImplementedError('Instruments are not implemented yet'));
5982
- return "continue-templates";
5983
- }
5958
+ var _loop_3 = function (listItem) {
5959
+ var command = parseCommand(listItem, 'PIPELINE_TEMPLATE');
5960
+ // TODO [🍧][♓️] List commands and before apply order them
5961
+ switch (command.type) {
5962
+ // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
5963
+ case 'BLOCK':
5964
+ if (isBlockTypeSet) {
5965
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
5966
+ }
5967
+ if (command.blockType === 'SAMPLE') {
5984
5968
  expectResultingParameterName();
5985
- templateJson.blockType = command.blockType;
5986
- isBlockTypeSet = true; //<- Note: [2]
5987
- break;
5988
- case 'EXPECT_AMOUNT':
5989
- // eslint-disable-next-line no-case-declarations
5990
- var unit = command.unit.toLowerCase();
5991
- templateJson.expectations = templateJson.expectations || {};
5992
- templateJson.expectations[unit] = templateJson.expectations[unit] || {};
5993
- if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
5994
- if (templateJson.expectations[unit].min !== undefined) {
5995
- throw new ParsingError("Already defined minumum ".concat(templateJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
5996
- }
5997
- templateJson.expectations[unit].min = command.amount;
5998
- } /* not else */
5999
- if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
6000
- if (templateJson.expectations[unit].max !== undefined) {
6001
- throw new ParsingError("Already defined maximum ".concat(templateJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6002
- }
6003
- templateJson.expectations[unit].max = command.amount;
6004
- }
6005
- break;
6006
- case 'EXPECT_FORMAT':
6007
- if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
6008
- throw new ParsingError(spaceTrim.spaceTrim("\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n ")));
5969
+ var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
5970
+ if (parameter === undefined) {
5971
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6009
5972
  }
6010
- templateJson.expectFormat = command.format;
6011
- break;
6012
- case 'JOKER':
6013
- templateJson.jokerParameterNames = templateJson.jokerParameterNames || [];
6014
- templateJson.jokerParameterNames.push(command.parameterName);
6015
- break;
6016
- case 'MODEL':
6017
- templateModelRequirements[command.key] = command.value;
6018
- break;
6019
- case 'PARAMETER':
6020
- // Note: This is just for detecting resulitng parameter name
6021
- defineParam(command);
6022
- break;
6023
- case 'POSTPROCESS':
6024
- templateJson.postprocessingFunctionNames = templateJson.postprocessingFunctionNames || [];
6025
- templateJson.postprocessingFunctionNames.push(command.functionName);
6026
- break;
6027
- case 'KNOWLEDGE':
6028
- // TODO: [👙] The knowledge is maybe relevant for just this template
6029
- knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
6030
- break;
6031
- case 'ACTION':
6032
- // TODO: [👙] The action is maybe relevant for just this template
5973
+ parameter.sampleValues = parameter.sampleValues || [];
5974
+ parameter.sampleValues.push(content);
5975
+ return "continue-templates";
5976
+ }
5977
+ if (command.blockType === 'KNOWLEDGE') {
5978
+ knowledgeCommandParser.applyToPipelineJson({
5979
+ type: 'KNOWLEDGE',
5980
+ sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5981
+ }, {
5982
+ pipelineJson: pipelineJson,
5983
+ templateJson: templateJson,
5984
+ });
5985
+ return "continue-templates";
5986
+ }
5987
+ if (command.blockType === 'ACTION') {
6033
5988
  console.error(new NotYetImplementedError('Actions are not implemented yet'));
6034
- break;
6035
- case 'INSTRUMENT':
6036
- // TODO: [👙] The instrument is maybe relevant for just this template
5989
+ return "continue-templates";
5990
+ }
5991
+ if (command.blockType === 'INSTRUMENT') {
6037
5992
  console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6038
- break;
6039
- case 'PERSONA':
6040
- personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
6041
- // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6042
- break;
6043
- case 'BOILERPLATE':
6044
- console.error(new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'));
6045
- break;
6046
- // <- [💐]
6047
- default:
6048
- throw new ParsingError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline"));
5993
+ return "continue-templates";
5994
+ }
5995
+ expectResultingParameterName();
5996
+ templateJson.blockType = command.blockType;
5997
+ isBlockTypeSet = true; //<- Note: [2]
5998
+ break;
5999
+ case 'EXPECT_AMOUNT':
6000
+ // eslint-disable-next-line no-case-declarations
6001
+ var unit_1 = command.unit.toLowerCase();
6002
+ templateJson.expectations = templateJson.expectations || {};
6003
+ templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
6004
+ if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
6005
+ if (templateJson.expectations[unit_1].min !== undefined) {
6006
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6007
+ }
6008
+ templateJson.expectations[unit_1].min = command.amount;
6009
+ } /* not else */
6010
+ if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
6011
+ if (templateJson.expectations[unit_1].max !== undefined) {
6012
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6013
+ }
6014
+ templateJson.expectations[unit_1].max = command.amount;
6015
+ }
6016
+ break;
6017
+ case 'EXPECT_FORMAT':
6018
+ if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
6019
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6020
+ }
6021
+ templateJson.expectFormat = command.format;
6022
+ break;
6023
+ case 'JOKER':
6024
+ templateJson.jokerParameterNames = templateJson.jokerParameterNames || [];
6025
+ templateJson.jokerParameterNames.push(command.parameterName);
6026
+ break;
6027
+ case 'MODEL':
6028
+ templateModelRequirements[command.key] = command.value;
6029
+ break;
6030
+ case 'PARAMETER':
6031
+ // Note: This is just for detecting resulitng parameter name
6032
+ defineParam(command);
6033
+ break;
6034
+ case 'POSTPROCESS':
6035
+ templateJson.postprocessingFunctionNames = templateJson.postprocessingFunctionNames || [];
6036
+ templateJson.postprocessingFunctionNames.push(command.functionName);
6037
+ break;
6038
+ case 'KNOWLEDGE':
6039
+ // TODO: [👙] The knowledge is maybe relevant for just this template
6040
+ knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
6041
+ break;
6042
+ case 'ACTION':
6043
+ // TODO: [👙] The action is maybe relevant for just this template
6044
+ console.error(new NotYetImplementedError('Actions are not implemented yet'));
6045
+ break;
6046
+ case 'INSTRUMENT':
6047
+ // TODO: [👙] The instrument is maybe relevant for just this template
6048
+ console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6049
+ break;
6050
+ case 'PERSONA':
6051
+ personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
6052
+ // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6053
+ break;
6054
+ case 'BOILERPLATE':
6055
+ console.error(new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })));
6056
+ break;
6057
+ // <- [💐]
6058
+ default:
6059
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(getPipelineIdentification()), "\n\n "); }));
6060
+ }
6061
+ };
6062
+ try {
6063
+ for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
6064
+ var listItem = listItems_2_1.value;
6065
+ var state_2 = _loop_3(listItem);
6066
+ switch (state_2) {
6067
+ case "continue-templates": return state_2;
6049
6068
  }
6050
6069
  }
6051
6070
  }
@@ -6059,7 +6078,7 @@
6059
6078
  // TODO: [🍧] Should be done in BLOCK command
6060
6079
  if (templateJson.blockType === 'SCRIPT') {
6061
6080
  if (!language) {
6062
- throw new ParsingError('You must specify the language of the script in the prompt template');
6081
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
6063
6082
  }
6064
6083
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
6065
6084
  throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
@@ -6085,7 +6104,7 @@
6085
6104
  // Note: 4️⃣ Process each template of the pipeline
6086
6105
  templates: for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
6087
6106
  var section = pipelineSections_1_1.value;
6088
- var state_1 = _loop_1(section);
6107
+ var state_1 = _loop_2(section);
6089
6108
  switch (state_1) {
6090
6109
  case "continue-templates": continue templates;
6091
6110
  }