@promptbook/core 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/esm/index.es.js CHANGED
@@ -9,7 +9,7 @@ import moment from 'moment';
9
9
  /**
10
10
  * The version of the Promptbook library
11
11
  */
12
- var PROMPTBOOK_VERSION = '0.67.4';
12
+ var PROMPTBOOK_VERSION = '0.67.6';
13
13
  // TODO: !!!! List here all the versions and annotate + put into script
14
14
 
15
15
  /*! *****************************************************************************
@@ -1779,7 +1779,7 @@ function forEachAsync(array, options, callbackfunction) {
1779
1779
  });
1780
1780
  }
1781
1781
 
1782
- 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"}];
1782
+ 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"}];
1783
1783
 
1784
1784
  var defaultDiacriticsRemovalMap = [
1785
1785
  {
@@ -6061,6 +6061,17 @@ function pipelineStringToJsonSync(pipelineString) {
6061
6061
  personas: [],
6062
6062
  preparations: [],
6063
6063
  };
6064
+ function getPipelineIdentification() {
6065
+ // Note: This is a 😐 implementation of [🚞]
6066
+ var _ = [];
6067
+ if (pipelineJson.sourceFile !== undefined) {
6068
+ _.push("File: ".concat(pipelineJson.sourceFile));
6069
+ }
6070
+ if (pipelineJson.pipelineUrl !== undefined) {
6071
+ _.push("Url: ".concat(pipelineJson.pipelineUrl));
6072
+ }
6073
+ return _.join('\n');
6074
+ }
6064
6075
  // =============================================================
6065
6076
  // Note: 1️⃣ Parsing of the markdown into object
6066
6077
  pipelineString = removeContentComments(pipelineString);
@@ -6069,27 +6080,27 @@ function pipelineStringToJsonSync(pipelineString) {
6069
6080
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
6070
6081
  var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
6071
6082
  if (pipelineHead === undefined) {
6072
- throw new UnexpectedError(spaceTrim$1("\n Pipeline head is not defined\n\n This should never happen, because the pipeline already flattened\n "));
6083
+ throw new UnexpectedError(spaceTrim$1(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 "); }));
6073
6084
  }
6074
6085
  if (pipelineHead.level !== 1) {
6075
- throw new UnexpectedError(spaceTrim$1("\n Pipeline head is not h1\n\n This should never happen, because the pipeline already flattened\n "));
6086
+ throw new UnexpectedError(spaceTrim$1(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 "); }));
6076
6087
  }
6077
6088
  if (!pipelineSections.every(function (section) { return section.level === 2; })) {
6078
- throw new UnexpectedError(spaceTrim$1("\n Not every pipeline section is h2\n\n This should never happen, because the pipeline already flattened\n "));
6089
+ throw new UnexpectedError(spaceTrim$1(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 "); }));
6079
6090
  }
6080
6091
  // =============================================================
6081
6092
  ///Note: 2️⃣ Function for defining parameters
6082
6093
  var defineParam = function (parameterCommand) {
6083
6094
  var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
6084
6095
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
6085
- throw new ParsingError("Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name") /* <- TODO: [🚞] */);
6096
+ throw new ParsingError(spaceTrim$1(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: [🚞] */);
6086
6097
  }
6087
6098
  var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
6088
6099
  if (existingParameter &&
6089
6100
  existingParameter.description &&
6090
6101
  existingParameter.description !== parameterDescription &&
6091
6102
  parameterDescription) {
6092
- throw new ParsingError(spaceTrim$1(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 "); }));
6103
+ throw new ParsingError(spaceTrim$1(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 "); }));
6093
6104
  }
6094
6105
  if (existingParameter) {
6095
6106
  if (parameterDescription) {
@@ -6122,44 +6133,46 @@ function pipelineStringToJsonSync(pipelineString) {
6122
6133
  pipelineJson.description = description;
6123
6134
  var defaultModelRequirements = {};
6124
6135
  var listItems = extractAllListItemsFromMarkdown(pipelineHead.content);
6136
+ var _loop_1 = function (listItem) {
6137
+ var command = parseCommand(listItem, 'PIPELINE_HEAD');
6138
+ switch (command.type) {
6139
+ // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
6140
+ case 'MODEL':
6141
+ defaultModelRequirements[command.key] = command.value;
6142
+ break;
6143
+ case 'PARAMETER':
6144
+ defineParam(command);
6145
+ break;
6146
+ case 'PROMPTBOOK_VERSION':
6147
+ pipelineJson.promptbookVersion = command.promptbookVersion;
6148
+ break;
6149
+ case 'URL':
6150
+ pipelineJson.pipelineUrl = command.pipelineUrl.href;
6151
+ break;
6152
+ case 'KNOWLEDGE':
6153
+ knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
6154
+ break;
6155
+ case 'ACTION':
6156
+ console.error(new NotYetImplementedError('Actions are not implemented yet'));
6157
+ break;
6158
+ case 'INSTRUMENT':
6159
+ console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6160
+ break;
6161
+ case 'PERSONA':
6162
+ personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
6163
+ // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6164
+ break;
6165
+ case 'BOILERPLATE':
6166
+ throw new ParsingError(spaceTrim$1(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: [🚞]
6167
+ // <- [💐]
6168
+ default:
6169
+ throw new ParsingError(spaceTrim$1(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: [🚞]
6170
+ }
6171
+ };
6125
6172
  try {
6126
6173
  for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
6127
6174
  var listItem = listItems_1_1.value;
6128
- var command = parseCommand(listItem, 'PIPELINE_HEAD');
6129
- switch (command.type) {
6130
- // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
6131
- case 'MODEL':
6132
- defaultModelRequirements[command.key] = command.value;
6133
- break;
6134
- case 'PARAMETER':
6135
- defineParam(command);
6136
- break;
6137
- case 'PROMPTBOOK_VERSION':
6138
- pipelineJson.promptbookVersion = command.promptbookVersion;
6139
- break;
6140
- case 'URL':
6141
- pipelineJson.pipelineUrl = command.pipelineUrl.href;
6142
- break;
6143
- case 'KNOWLEDGE':
6144
- knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
6145
- break;
6146
- case 'ACTION':
6147
- console.error(new NotYetImplementedError('Actions are not implemented yet'));
6148
- break;
6149
- case 'INSTRUMENT':
6150
- console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6151
- break;
6152
- case 'PERSONA':
6153
- personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
6154
- // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6155
- break;
6156
- case 'BOILERPLATE':
6157
- throw new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'); // <- TODO: [🚞]
6158
- break;
6159
- // <- [💐]
6160
- default:
6161
- throw new ParsingError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template")); // <- TODO: [🚞]
6162
- }
6175
+ _loop_1(listItem);
6163
6176
  }
6164
6177
  }
6165
6178
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -6169,7 +6182,7 @@ function pipelineStringToJsonSync(pipelineString) {
6169
6182
  }
6170
6183
  finally { if (e_1) throw e_1.error; }
6171
6184
  }
6172
- var _loop_1 = function (section) {
6185
+ var _loop_2 = function (section) {
6173
6186
  var e_3, _d;
6174
6187
  // TODO: Parse prompt template description (the content out of the codeblock and lists)
6175
6188
  var templateModelRequirements = __assign({}, defaultModelRequirements);
@@ -6186,7 +6199,7 @@ function pipelineStringToJsonSync(pipelineString) {
6186
6199
  if (resultingParameterName !== null) {
6187
6200
  return resultingParameterName;
6188
6201
  }
6189
- throw new ParsingError(spaceTrim$1(function (block) { return "\n Template section must end with -> {parameterName}\n\n Invalid section:\n ".concat(block(
6202
+ throw new ParsingError(spaceTrim$1(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
6190
6203
  // TODO: Show code of invalid sections each time + DRY
6191
6204
  section.content
6192
6205
  .split('\n')
@@ -6222,110 +6235,116 @@ function pipelineStringToJsonSync(pipelineString) {
6222
6235
  * Note: [2]
6223
6236
  */
6224
6237
  var isBlockTypeSet = false;
6225
- try {
6226
- 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()) {
6227
- var listItem = listItems_2_1.value;
6228
- var command = parseCommand(listItem, 'PIPELINE_TEMPLATE');
6229
- // TODO [🍧][♓️] List commands and before apply order them
6230
- switch (command.type) {
6231
- // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
6232
- case 'BLOCK':
6233
- if (isBlockTypeSet) {
6234
- throw new ParsingError('Block type is already defined in the prompt template. It can be defined only once.');
6235
- }
6236
- if (command.blockType === 'SAMPLE') {
6237
- expectResultingParameterName();
6238
- var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
6239
- if (parameter === undefined) {
6240
- throw new UnexpectedError("Can not find parameter {".concat(resultingParameterName, "} to assign sample value"));
6241
- }
6242
- parameter.sampleValues = parameter.sampleValues || [];
6243
- parameter.sampleValues.push(content);
6244
- return "continue-templates";
6245
- }
6246
- if (command.blockType === 'KNOWLEDGE') {
6247
- knowledgeCommandParser.applyToPipelineJson({
6248
- type: 'KNOWLEDGE',
6249
- sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
6250
- }, {
6251
- pipelineJson: pipelineJson,
6252
- templateJson: templateJson,
6253
- });
6254
- return "continue-templates";
6255
- }
6256
- if (command.blockType === 'ACTION') {
6257
- console.error(new NotYetImplementedError('Actions are not implemented yet'));
6258
- return "continue-templates";
6259
- }
6260
- if (command.blockType === 'INSTRUMENT') {
6261
- console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6262
- return "continue-templates";
6263
- }
6238
+ var _loop_3 = function (listItem) {
6239
+ var command = parseCommand(listItem, 'PIPELINE_TEMPLATE');
6240
+ // TODO [🍧][♓️] List commands and before apply order them
6241
+ switch (command.type) {
6242
+ // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
6243
+ case 'BLOCK':
6244
+ if (isBlockTypeSet) {
6245
+ throw new ParsingError(spaceTrim$1(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 "); }));
6246
+ }
6247
+ if (command.blockType === 'SAMPLE') {
6264
6248
  expectResultingParameterName();
6265
- templateJson.blockType = command.blockType;
6266
- isBlockTypeSet = true; //<- Note: [2]
6267
- break;
6268
- case 'EXPECT_AMOUNT':
6269
- // eslint-disable-next-line no-case-declarations
6270
- var unit = command.unit.toLowerCase();
6271
- templateJson.expectations = templateJson.expectations || {};
6272
- templateJson.expectations[unit] = templateJson.expectations[unit] || {};
6273
- if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
6274
- if (templateJson.expectations[unit].min !== undefined) {
6275
- throw new ParsingError("Already defined minumum ".concat(templateJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6276
- }
6277
- templateJson.expectations[unit].min = command.amount;
6278
- } /* not else */
6279
- if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
6280
- if (templateJson.expectations[unit].max !== undefined) {
6281
- throw new ParsingError("Already defined maximum ".concat(templateJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6282
- }
6283
- templateJson.expectations[unit].max = command.amount;
6284
- }
6285
- break;
6286
- case 'EXPECT_FORMAT':
6287
- if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
6288
- throw new ParsingError(spaceTrim$1("\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n ")));
6249
+ var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
6250
+ if (parameter === undefined) {
6251
+ throw new ParsingError(spaceTrim$1(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6289
6252
  }
6290
- templateJson.expectFormat = command.format;
6291
- break;
6292
- case 'JOKER':
6293
- templateJson.jokerParameterNames = templateJson.jokerParameterNames || [];
6294
- templateJson.jokerParameterNames.push(command.parameterName);
6295
- break;
6296
- case 'MODEL':
6297
- templateModelRequirements[command.key] = command.value;
6298
- break;
6299
- case 'PARAMETER':
6300
- // Note: This is just for detecting resulitng parameter name
6301
- defineParam(command);
6302
- break;
6303
- case 'POSTPROCESS':
6304
- templateJson.postprocessingFunctionNames = templateJson.postprocessingFunctionNames || [];
6305
- templateJson.postprocessingFunctionNames.push(command.functionName);
6306
- break;
6307
- case 'KNOWLEDGE':
6308
- // TODO: [👙] The knowledge is maybe relevant for just this template
6309
- knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
6310
- break;
6311
- case 'ACTION':
6312
- // TODO: [👙] The action is maybe relevant for just this template
6253
+ parameter.sampleValues = parameter.sampleValues || [];
6254
+ parameter.sampleValues.push(content);
6255
+ return "continue-templates";
6256
+ }
6257
+ if (command.blockType === 'KNOWLEDGE') {
6258
+ knowledgeCommandParser.applyToPipelineJson({
6259
+ type: 'KNOWLEDGE',
6260
+ sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
6261
+ }, {
6262
+ pipelineJson: pipelineJson,
6263
+ templateJson: templateJson,
6264
+ });
6265
+ return "continue-templates";
6266
+ }
6267
+ if (command.blockType === 'ACTION') {
6313
6268
  console.error(new NotYetImplementedError('Actions are not implemented yet'));
6314
- break;
6315
- case 'INSTRUMENT':
6316
- // TODO: [👙] The instrument is maybe relevant for just this template
6269
+ return "continue-templates";
6270
+ }
6271
+ if (command.blockType === 'INSTRUMENT') {
6317
6272
  console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6318
- break;
6319
- case 'PERSONA':
6320
- personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
6321
- // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6322
- break;
6323
- case 'BOILERPLATE':
6324
- console.error(new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'));
6325
- break;
6326
- // <- [💐]
6327
- default:
6328
- throw new ParsingError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline"));
6273
+ return "continue-templates";
6274
+ }
6275
+ expectResultingParameterName();
6276
+ templateJson.blockType = command.blockType;
6277
+ isBlockTypeSet = true; //<- Note: [2]
6278
+ break;
6279
+ case 'EXPECT_AMOUNT':
6280
+ // eslint-disable-next-line no-case-declarations
6281
+ var unit_1 = command.unit.toLowerCase();
6282
+ templateJson.expectations = templateJson.expectations || {};
6283
+ templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
6284
+ if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
6285
+ if (templateJson.expectations[unit_1].min !== undefined) {
6286
+ throw new ParsingError(spaceTrim$1(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 "); }));
6287
+ }
6288
+ templateJson.expectations[unit_1].min = command.amount;
6289
+ } /* not else */
6290
+ if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
6291
+ if (templateJson.expectations[unit_1].max !== undefined) {
6292
+ throw new ParsingError(spaceTrim$1(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 "); }));
6293
+ }
6294
+ templateJson.expectations[unit_1].max = command.amount;
6295
+ }
6296
+ break;
6297
+ case 'EXPECT_FORMAT':
6298
+ if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
6299
+ throw new ParsingError(spaceTrim$1(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 "); }));
6300
+ }
6301
+ templateJson.expectFormat = command.format;
6302
+ break;
6303
+ case 'JOKER':
6304
+ templateJson.jokerParameterNames = templateJson.jokerParameterNames || [];
6305
+ templateJson.jokerParameterNames.push(command.parameterName);
6306
+ break;
6307
+ case 'MODEL':
6308
+ templateModelRequirements[command.key] = command.value;
6309
+ break;
6310
+ case 'PARAMETER':
6311
+ // Note: This is just for detecting resulitng parameter name
6312
+ defineParam(command);
6313
+ break;
6314
+ case 'POSTPROCESS':
6315
+ templateJson.postprocessingFunctionNames = templateJson.postprocessingFunctionNames || [];
6316
+ templateJson.postprocessingFunctionNames.push(command.functionName);
6317
+ break;
6318
+ case 'KNOWLEDGE':
6319
+ // TODO: [👙] The knowledge is maybe relevant for just this template
6320
+ knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
6321
+ break;
6322
+ case 'ACTION':
6323
+ // TODO: [👙] The action is maybe relevant for just this template
6324
+ console.error(new NotYetImplementedError('Actions are not implemented yet'));
6325
+ break;
6326
+ case 'INSTRUMENT':
6327
+ // TODO: [👙] The instrument is maybe relevant for just this template
6328
+ console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6329
+ break;
6330
+ case 'PERSONA':
6331
+ personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
6332
+ // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6333
+ break;
6334
+ case 'BOILERPLATE':
6335
+ console.error(new ParsingError(spaceTrim$1(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 "); })));
6336
+ break;
6337
+ // <- [💐]
6338
+ default:
6339
+ throw new ParsingError(spaceTrim$1(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 "); }));
6340
+ }
6341
+ };
6342
+ try {
6343
+ 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()) {
6344
+ var listItem = listItems_2_1.value;
6345
+ var state_2 = _loop_3(listItem);
6346
+ switch (state_2) {
6347
+ case "continue-templates": return state_2;
6329
6348
  }
6330
6349
  }
6331
6350
  }
@@ -6339,7 +6358,7 @@ function pipelineStringToJsonSync(pipelineString) {
6339
6358
  // TODO: [🍧] Should be done in BLOCK command
6340
6359
  if (templateJson.blockType === 'SCRIPT') {
6341
6360
  if (!language) {
6342
- throw new ParsingError('You must specify the language of the script in the prompt template');
6361
+ throw new ParsingError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
6343
6362
  }
6344
6363
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
6345
6364
  throw new ParsingError(spaceTrim$1(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 "); }));
@@ -6365,7 +6384,7 @@ function pipelineStringToJsonSync(pipelineString) {
6365
6384
  // Note: 4️⃣ Process each template of the pipeline
6366
6385
  templates: for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
6367
6386
  var section = pipelineSections_1_1.value;
6368
- var state_1 = _loop_1(section);
6387
+ var state_1 = _loop_2(section);
6369
6388
  switch (state_1) {
6370
6389
  case "continue-templates": continue templates;
6371
6390
  }