@promptbook/core 0.74.0-8 → 0.75.0-1

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 (57) hide show
  1. package/README.md +2 -11
  2. package/esm/index.es.js +630 -257
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +3 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +25 -1
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
  9. package/esm/typings/src/cli/main.d.ts +4 -1
  10. package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
  11. package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
  12. package/esm/typings/src/collection/collectionToJson.test.d.ts +1 -1
  13. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
  14. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  15. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
  16. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +11 -0
  17. package/esm/typings/src/commands/FORMFACTOR/formfactorCommand.test.d.ts +1 -0
  18. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +11 -0
  19. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
  20. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -0
  21. package/esm/typings/src/commands/index.d.ts +1 -1
  22. package/esm/typings/src/config.d.ts +7 -0
  23. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
  24. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
  25. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
  26. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  27. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +7 -7
  28. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  29. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
  30. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +14 -0
  31. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +34 -0
  32. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +5 -0
  33. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +5 -0
  34. package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +15 -0
  35. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +14 -0
  36. package/esm/typings/src/formfactors/index.d.ts +39 -0
  37. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +14 -0
  38. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +14 -0
  39. package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +22 -0
  40. package/esm/typings/src/pipeline/pipeline-interface/constants.d.ts +9 -0
  41. package/esm/typings/src/pipeline/pipeline-interface/getPipelineInterface.d.ts +11 -0
  42. package/esm/typings/src/pipeline/pipeline-interface/isPipelineImplementingInterface.d.ts +25 -0
  43. package/esm/typings/src/pipeline/pipeline-interface/isPipelineInterfacesEqual.d.ts +11 -0
  44. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  45. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
  46. package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
  47. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +11 -4
  48. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  49. package/esm/typings/src/types/Prompt.d.ts +1 -1
  50. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  51. package/esm/typings/src/utils/expectation-counters/constants.d.ts +15 -0
  52. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
  53. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
  54. package/package.json +1 -1
  55. package/umd/index.umd.js +641 -256
  56. package/umd/index.umd.js.map +1 -1
  57. /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
22
22
  *
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-7';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  */
@@ -219,13 +219,13 @@ function capitalize(word) {
219
219
  /**
220
220
  * Converts promptbook in JSON format to string format
221
221
  *
222
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
223
- * @returns Promptbook in string format (.ptbk.md)
222
+ * @param pipelineJson Promptbook in JSON format (.book.json)
223
+ * @returns Promptbook in string format (.book.md)
224
224
  * @public exported from `@promptbook/core`
225
225
  */
226
226
  function pipelineJsonToString(pipelineJson) {
227
227
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
228
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
228
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
229
229
  var pipelineString = "# ".concat(title);
230
230
  if (description) {
231
231
  pipelineString += '\n\n';
@@ -235,8 +235,10 @@ function pipelineJsonToString(pipelineJson) {
235
235
  if (pipelineUrl) {
236
236
  commands.push("PIPELINE URL ".concat(pipelineUrl));
237
237
  }
238
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
239
- // TODO: [main] !!! This increase size of the bundle and is probbably not necessary
238
+ if (bookVersion !== "undefined") {
239
+ commands.push("BOOK VERSION ".concat(bookVersion));
240
+ }
241
+ // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
240
242
  pipelineString = prettifyMarkdown(pipelineString);
241
243
  try {
242
244
  for (var _g = __values(parameters.filter(function (_a) {
@@ -416,7 +418,7 @@ function templateParameterJsonToString(templateParameterJson) {
416
418
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
417
419
  * TODO: [🏛] Maybe make some markdown builder
418
420
  * TODO: [🏛] Escape all
419
- * TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
421
+ * TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
420
422
  */
421
423
 
422
424
  /**
@@ -646,6 +648,13 @@ var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so t
646
648
  * @public exported from `@promptbook/core`
647
649
  */
648
650
  var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
651
+ // <- TODO: [🐊] Pick the best claim
652
+ /**
653
+ * When the title is not provided, the default title is used
654
+ *
655
+ * @public exported from `@promptbook/core`
656
+ */
657
+ var DEFAULT_TITLE = "Untitled";
649
658
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
650
659
  /**
651
660
  * The maximum number of iterations for a loops
@@ -809,6 +818,7 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
809
818
  // Note: In normal situations, we check the pipeline logic:
810
819
  true);
811
820
  /**
821
+ * TODO: Extract `constants.ts` from `config.ts`
812
822
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
813
823
  */
814
824
 
@@ -985,7 +995,7 @@ function isValidPipelineUrl(url) {
985
995
  if (!url.startsWith('https://')) {
986
996
  return false;
987
997
  }
988
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
998
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
989
999
  return false;
990
1000
  }
991
1001
  if (url.includes('#')) {
@@ -1054,9 +1064,9 @@ function validatePipelineCore(pipeline) {
1054
1064
  // <- Note: [🚲]
1055
1065
  throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1056
1066
  }
1057
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
1067
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
1058
1068
  // <- Note: [🚲]
1059
- throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1069
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1060
1070
  }
1061
1071
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1062
1072
  if (!Array.isArray(pipeline.parameters)) {
@@ -1070,18 +1080,18 @@ function validatePipelineCore(pipeline) {
1070
1080
  }
1071
1081
  var _loop_1 = function (parameter) {
1072
1082
  if (parameter.isInput && parameter.isOutput) {
1073
- 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 "); }));
1083
+ 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 "); }));
1074
1084
  }
1075
1085
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
1076
1086
  if (!parameter.isInput &&
1077
1087
  !parameter.isOutput &&
1078
1088
  !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
1079
- 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 "); }));
1089
+ 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 "); }));
1080
1090
  }
1081
1091
  // Note: Testing that parameter is either input or result of some template
1082
1092
  if (!parameter.isInput &&
1083
1093
  !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
1084
- 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 1) Remove declaration of {").concat(parameter.name, "}\n 2) Add template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
1094
+ 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 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add template that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1085
1095
  }
1086
1096
  };
1087
1097
  try {
@@ -1109,7 +1119,7 @@ function validatePipelineCore(pipeline) {
1109
1119
  var _loop_2 = function (template) {
1110
1120
  var e_4, _h, e_5, _j;
1111
1121
  if (definedParameters.has(template.resultingParameterName)) {
1112
- throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1122
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1113
1123
  }
1114
1124
  if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1115
1125
  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 "); }));
@@ -1122,7 +1132,7 @@ function validatePipelineCore(pipeline) {
1122
1132
  }
1123
1133
  var _loop_4 = function (joker) {
1124
1134
  if (!template.dependentParameterNames.includes(joker)) {
1125
- 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 "); }));
1135
+ 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 "); }));
1126
1136
  }
1127
1137
  };
1128
1138
  try {
@@ -1217,14 +1227,24 @@ function validatePipelineCore(pipeline) {
1217
1227
  if (currentlyResovedTemplates.length === 0) {
1218
1228
  throw new PipelineLogicError(
1219
1229
  // TODO: [🐎] DRY
1220
- spaceTrim$1(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates
1230
+ spaceTrim$1(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates
1221
1231
  .map(function (_a) {
1222
1232
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
1223
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
1224
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1233
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
1234
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
1225
1235
  .join(' and '));
1226
1236
  })
1227
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n\n "); }));
1237
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
1238
+ .filter(function (name) {
1239
+ return !RESERVED_PARAMETER_NAMES.includes(name);
1240
+ })
1241
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1242
+ .join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
1243
+ .filter(function (name) {
1244
+ return RESERVED_PARAMETER_NAMES.includes(name);
1245
+ })
1246
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1247
+ .join('\n')), "\n\n\n "); }));
1228
1248
  }
1229
1249
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1230
1250
  var resultingParameterName = _a.resultingParameterName;
@@ -1235,6 +1255,7 @@ function validatePipelineCore(pipeline) {
1235
1255
  while (unresovedTemplates.length > 0) {
1236
1256
  _loop_3();
1237
1257
  }
1258
+ // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
1238
1259
  }
1239
1260
  /**
1240
1261
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -2227,8 +2248,8 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
2227
2248
  else if (errors.length > 1) {
2228
2249
  throw new PipelineExecutionError(
2229
2250
  // TODO: Tell which execution tools failed like
2230
- // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
2231
- // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
2251
+ // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2252
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2232
2253
  // 3) ...
2233
2254
  spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
2234
2255
  .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
@@ -2303,7 +2324,7 @@ function joinLlmExecutionTools() {
2303
2324
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2304
2325
  */
2305
2326
 
2306
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],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",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],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",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",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}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
2327
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",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}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.book.md"}];
2307
2328
 
2308
2329
  /**
2309
2330
  * This error indicates that the pipeline collection cannot be propperly loaded
@@ -3227,11 +3248,11 @@ function replaceParameters(template, parameters) {
3227
3248
  for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
3228
3249
  var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
3229
3250
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
3230
- throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
3251
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
3231
3252
  }
3232
3253
  else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
3233
3254
  // TODO: [🍵]
3234
- throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
3255
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
3235
3256
  }
3236
3257
  }
3237
3258
  }
@@ -3258,11 +3279,11 @@ function replaceParameters(template, parameters) {
3258
3279
  throw new PipelineExecutionError('Parameter is already opened or not closed');
3259
3280
  }
3260
3281
  if (parameters[parameterName] === undefined) {
3261
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
3282
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
3262
3283
  }
3263
3284
  var parameterValue = parameters[parameterName];
3264
3285
  if (parameterValue === undefined) {
3265
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
3286
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
3266
3287
  }
3267
3288
  parameterValue = parameterValue.toString();
3268
3289
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
@@ -3306,30 +3327,45 @@ function countCharacters(text) {
3306
3327
  return text.length;
3307
3328
  }
3308
3329
 
3330
+ /**
3331
+ * Number of characters per standard line with 11pt Arial font size.
3332
+ *
3333
+ * @public exported from `@promptbook/utils`
3334
+ */
3335
+ var CHARACTERS_PER_STANDARD_LINE = 63;
3336
+ /**
3337
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
3338
+ *
3339
+ * @public exported from `@promptbook/utils`
3340
+ */
3341
+ var LINES_PER_STANDARD_PAGE = 44;
3342
+ /**
3343
+ * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
3344
+ */
3345
+
3309
3346
  /**
3310
3347
  * Counts number of lines in the text
3311
3348
  *
3349
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
3350
+ *
3312
3351
  * @public exported from `@promptbook/utils`
3313
3352
  */
3314
3353
  function countLines(text) {
3315
- if (text === '') {
3316
- return 0;
3317
- }
3318
- return text.split('\n').length;
3354
+ text = text.replace('\r\n', '\n');
3355
+ text = text.replace('\r', '\n');
3356
+ var lines = text.split('\n');
3357
+ return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
3319
3358
  }
3320
3359
 
3321
3360
  /**
3322
3361
  * Counts number of pages in the text
3323
3362
  *
3363
+ * Note: This does not check only for the count of newlines, but also for the length of the standard line and length of the standard page.
3364
+ *
3324
3365
  * @public exported from `@promptbook/utils`
3325
3366
  */
3326
3367
  function countPages(text) {
3327
- if (text === '') {
3328
- return 0;
3329
- }
3330
- var pagesByLinesCount = Math.ceil(countLines(text) / 44);
3331
- var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
3332
- return Math.max(pagesByLinesCount, pagesByCharactersCount);
3368
+ return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
3333
3369
  }
3334
3370
 
3335
3371
  /**
@@ -3892,7 +3928,7 @@ function executeAttempts(options) {
3892
3928
  promptTitle: template.title,
3893
3929
  promptMessage: replaceParameters(template.description || '', parameters),
3894
3930
  defaultValue: replaceParameters(preparedContent, parameters),
3895
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
3931
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
3896
3932
  placeholder: undefined,
3897
3933
  priority: priority,
3898
3934
  }))];
@@ -4320,7 +4356,7 @@ function executeTemplate(options) {
4320
4356
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4321
4357
  // Houston, we have a problem
4322
4358
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
4323
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4359
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4324
4360
  }
4325
4361
  };
4326
4362
  try {
@@ -4399,7 +4435,7 @@ function filterJustOutputParameters(options) {
4399
4435
  var _loop_1 = function (parameter) {
4400
4436
  if (parametersToPass[parameter.name] === undefined) {
4401
4437
  // [4]
4402
- $warnings.push(new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
4438
+ $warnings.push(new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameter.name, "}` should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
4403
4439
  return "continue";
4404
4440
  }
4405
4441
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -4458,7 +4494,7 @@ function executePipeline(options) {
4458
4494
  pipelineUrl: preparedPipeline.pipelineUrl,
4459
4495
  title: preparedPipeline.title,
4460
4496
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
4461
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
4497
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
4462
4498
  description: preparedPipeline.description,
4463
4499
  promptExecutions: [],
4464
4500
  };
@@ -4486,7 +4522,7 @@ function executePipeline(options) {
4486
4522
  case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
4487
4523
  isSuccessful: false,
4488
4524
  errors: __spreadArray([
4489
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
4525
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
4490
4526
  ], __read(errors), false).map(serializeError),
4491
4527
  warnings: [],
4492
4528
  executionReport: executionReport,
@@ -4534,7 +4570,7 @@ function executePipeline(options) {
4534
4570
  case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim$1(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
4535
4571
  isSuccessful: false,
4536
4572
  errors: __spreadArray([
4537
- new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4573
+ new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4538
4574
  ], __read(errors), false).map(serializeError),
4539
4575
  warnings: warnings.map(serializeError),
4540
4576
  executionReport: executionReport,
@@ -4608,14 +4644,24 @@ function executePipeline(options) {
4608
4644
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
4609
4645
  throw new UnexpectedError(
4610
4646
  // TODO: [🐎] DRY
4611
- spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates_1
4647
+ spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates_1
4612
4648
  .map(function (_a) {
4613
4649
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
4614
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
4615
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
4650
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
4651
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
4616
4652
  .join(' and '));
4617
4653
  })
4618
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameterNames_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
4654
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
4655
+ .filter(function (name) {
4656
+ return !RESERVED_PARAMETER_NAMES.includes(name);
4657
+ })
4658
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
4659
+ .join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
4660
+ .filter(function (name) {
4661
+ return RESERVED_PARAMETER_NAMES.includes(name);
4662
+ })
4663
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
4664
+ .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
4619
4665
  case 1:
4620
4666
  if (!!currentTemplate) return [3 /*break*/, 3];
4621
4667
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -4807,7 +4853,7 @@ function preparePersona(personaDescription, tools, options) {
4807
4853
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
4808
4854
  _b = createPipelineExecutor;
4809
4855
  _c = {};
4810
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
4856
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
4811
4857
  case 1:
4812
4858
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
4813
4859
  _c.tools = tools,
@@ -5564,13 +5610,14 @@ TODO: [🧊] This is how it can look in future
5564
5610
  */
5565
5611
  function clonePipeline(pipeline) {
5566
5612
  // Note: Not using spread operator (...) because @@@
5567
- var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, promptbookVersion = pipeline.promptbookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
5613
+ var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
5568
5614
  return {
5569
5615
  pipelineUrl: pipelineUrl,
5570
5616
  sourceFile: sourceFile,
5571
5617
  title: title,
5572
- promptbookVersion: promptbookVersion,
5618
+ bookVersion: bookVersion,
5573
5619
  description: description,
5620
+ formfactorName: formfactorName,
5574
5621
  parameters: parameters,
5575
5622
  templates: templates,
5576
5623
  knowledgeSources: knowledgeSources,
@@ -5781,7 +5828,7 @@ var knowledgeCommandParser = {
5781
5828
  throw new ParseError("Source not valid");
5782
5829
  }
5783
5830
  if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
5784
- throw new ParseError("Source cannot be outside of the .ptbk.md folder");
5831
+ throw new ParseError("Source cannot be outside of the .book.md folder");
5785
5832
  }
5786
5833
  return {
5787
5834
  type: 'KNOWLEDGE',
@@ -6001,6 +6048,175 @@ var templateCommandParser = {
6001
6048
  * ```
6002
6049
  */
6003
6050
 
6051
+ /**
6052
+ * Parses the boilerplate command
6053
+ *
6054
+ * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
6055
+ *
6056
+ * @see `documentationUrl` for more details
6057
+ * @private within the commands folder
6058
+ */
6059
+ var boilerplateCommandParser = {
6060
+ /**
6061
+ * Name of the command
6062
+ */
6063
+ name: 'BOILERPLATE',
6064
+ /**
6065
+ * Aliases for the BOILERPLATE command
6066
+ */
6067
+ aliasNames: ['BP'],
6068
+ /**
6069
+ * BOILERPLATE command can be used in:
6070
+ */
6071
+ isUsedInPipelineHead: true,
6072
+ isUsedInPipelineTemplate: true,
6073
+ /**
6074
+ * Description of the BOILERPLATE command
6075
+ */
6076
+ description: "@@",
6077
+ /**
6078
+ * Link to documentation
6079
+ */
6080
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
6081
+ /**
6082
+ * Example usages of the BOILERPLATE command
6083
+ */
6084
+ examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
6085
+ /**
6086
+ * Parses the BOILERPLATE command
6087
+ */
6088
+ parse: function (input) {
6089
+ var args = input.args;
6090
+ if (args.length !== 1) {
6091
+ throw new ParseError("BOILERPLATE command requires exactly one argument");
6092
+ }
6093
+ var value = args[0].toLowerCase();
6094
+ if (value.includes('brr')) {
6095
+ throw new ParseError("BOILERPLATE value can not contain brr");
6096
+ }
6097
+ return {
6098
+ type: 'BOILERPLATE',
6099
+ value: value,
6100
+ };
6101
+ },
6102
+ /**
6103
+ * Apply the BOILERPLATE command to the `pipelineJson`
6104
+ *
6105
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6106
+ */
6107
+ $applyToPipelineJson: function (command, $pipelineJson) {
6108
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6109
+ },
6110
+ /**
6111
+ * Apply the BOILERPLATE command to the `pipelineJson`
6112
+ *
6113
+ * Note: `$` is used to indicate that this function mutates given `templateJson`
6114
+ */
6115
+ $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6116
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6117
+ },
6118
+ /**
6119
+ * Converts the BOILERPLATE command back to string
6120
+ *
6121
+ * Note: This is used in `pipelineJsonToString` utility
6122
+ */
6123
+ stringify: function (command) {
6124
+ return "---"; // <- TODO: [🛋] Implement
6125
+ },
6126
+ /**
6127
+ * Reads the BOILERPLATE command from the `PipelineJson`
6128
+ *
6129
+ * Note: This is used in `pipelineJsonToString` utility
6130
+ */
6131
+ takeFromPipelineJson: function (pipelineJson) {
6132
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6133
+ },
6134
+ /**
6135
+ * Reads the BOILERPLATE command from the `TemplateJson`
6136
+ *
6137
+ * Note: This is used in `pipelineJsonToString` utility
6138
+ */
6139
+ takeFromTemplateJson: function ($templateJson) {
6140
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6141
+ },
6142
+ };
6143
+
6144
+ /**
6145
+ * Parses the BOOK_VERSION command
6146
+ *
6147
+ * @see `documentationUrl` for more details
6148
+ * @private within the commands folder
6149
+ */
6150
+ var bookVersionCommandParser = {
6151
+ /**
6152
+ * Name of the command
6153
+ */
6154
+ name: 'BOOK_VERSION',
6155
+ aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
6156
+ /**
6157
+ * BOILERPLATE command can be used in:
6158
+ */
6159
+ isUsedInPipelineHead: true,
6160
+ isUsedInPipelineTemplate: false,
6161
+ /**
6162
+ * Description of the BOOK_VERSION command
6163
+ */
6164
+ description: "Which version of the Book language is the .book.md using",
6165
+ /**
6166
+ * Link to documentation
6167
+ */
6168
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
6169
+ /**
6170
+ * Example usages of the BOOK_VERSION command
6171
+ */
6172
+ examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
6173
+ /**
6174
+ * Parses the BOOK_VERSION command
6175
+ */
6176
+ parse: function (input) {
6177
+ var args = input.args;
6178
+ var bookVersion = args.pop();
6179
+ if (bookVersion === undefined) {
6180
+ throw new ParseError("Version is required");
6181
+ }
6182
+ if (!isValidPromptbookVersion(bookVersion)) {
6183
+ throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
6184
+ }
6185
+ if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
6186
+ throw new ParseError("Can not have more than one Promptbook version");
6187
+ }
6188
+ return {
6189
+ type: 'BOOK_VERSION',
6190
+ bookVersion: bookVersion,
6191
+ };
6192
+ },
6193
+ /**
6194
+ * Apply the BOOK_VERSION command to the `pipelineJson`
6195
+ *
6196
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6197
+ */
6198
+ $applyToPipelineJson: function (command, $pipelineJson) {
6199
+ // TODO: Warn if the version is overridden
6200
+ $pipelineJson.bookVersion = command.bookVersion;
6201
+ },
6202
+ /**
6203
+ * Converts the BOOK_VERSION command back to string
6204
+ *
6205
+ * Note: This is used in `pipelineJsonToString` utility
6206
+ */
6207
+ stringify: function (command) {
6208
+ return "---"; // <- TODO: [🛋] Implement
6209
+ },
6210
+ /**
6211
+ * Reads the BOOK_VERSION command from the `PipelineJson`
6212
+ *
6213
+ * Note: This is used in `pipelineJsonToString` utility
6214
+ */
6215
+ takeFromPipelineJson: function (pipelineJson) {
6216
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6217
+ },
6218
+ };
6219
+
6004
6220
  /**
6005
6221
  * Units of text measurement
6006
6222
  *
@@ -6413,7 +6629,7 @@ function validateParameterName(parameterName) {
6413
6629
  /**
6414
6630
  * Parses the foreach command
6415
6631
  *
6416
- * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.ptbk.md` file
6632
+ * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
6417
6633
  *
6418
6634
  * @see `documentationUrl` for more details
6419
6635
  * @private within the commands folder
@@ -6563,7 +6779,7 @@ var foreachCommandParser = {
6563
6779
  },
6564
6780
  };
6565
6781
  /**
6566
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH with wrong parsing and logic
6782
+ * TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
6567
6783
  */
6568
6784
 
6569
6785
  /**
@@ -6639,52 +6855,231 @@ var formatCommandParser = {
6639
6855
  };
6640
6856
 
6641
6857
  /**
6642
- * Parses the joker command
6858
+ * @@@
6859
+ *
6860
+ * @public exported from `@promptbook/core`
6861
+ */
6862
+ var ChatFormfactorDefinition = {
6863
+ name: 'CHATBOT',
6864
+ aliasNames: ['CHAT'],
6865
+ description: "@@@",
6866
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6867
+ pipelineInterface: {
6868
+ inputParameterNames: ['previousTitle', 'previousConversationSummary', 'userMessage'],
6869
+ outputParameterNames: ['title', 'conversationSummary', 'chatbotResponse'],
6870
+ /*
6871
+ <- TODO: !!!!!! Change to
6872
+
6873
+ - INPUT PARAMETER `{previousTitle}` Previous title of the conversation
6874
+ - INPUT PARAMETER `{previousConversationSummary}` Previous conversation summary
6875
+ - INPUT PARAMETER `{userMessage}` User message
6876
+ - OUTPUT PARAMETER `{title}` Title of the conversation
6877
+ - OUTPUT PARAMETER `{conversationSummary}` Summary of the conversation
6878
+ - OUTPUT PARAMETER `{chatbotResponse}` Chatbot response
6879
+
6880
+ */
6881
+ },
6882
+ };
6883
+
6884
+ /**
6885
+ * @@@
6886
+ *
6887
+ * @public exported from `@promptbook/core`
6888
+ */
6889
+ var GENERIC_PIPELINE_INTERFACE = {
6890
+ inputParameterNames: [],
6891
+ outputParameterNames: [],
6892
+ };
6893
+
6894
+ /**
6895
+ * @@@
6896
+ *
6897
+ * @public exported from `@promptbook/core`
6898
+ */
6899
+ var GenericFormfactorDefinition = {
6900
+ name: 'GENERIC',
6901
+ description: "@@@",
6902
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6903
+ pipelineInterface: GENERIC_PIPELINE_INTERFACE,
6904
+ };
6905
+
6906
+ /**
6907
+ * Sheets is form of app that @@@
6908
+ *
6909
+ * @public exported from `@promptbook/core`
6910
+ */
6911
+ var SheetsFormfactorDefinition = {
6912
+ name: 'SHEETS',
6913
+ description: "@@@",
6914
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6915
+ pipelineInterface: {
6916
+ inputParameterNames: ['inputSheet'],
6917
+ outputParameterNames: ['outputSheet'],
6918
+ },
6919
+ };
6920
+
6921
+ /**
6922
+ * Translator is form of app that @@@
6923
+ *
6924
+ * @public exported from `@promptbook/core`
6925
+ */
6926
+ var TranslatorFormfactorDefinition = {
6927
+ name: 'TRANSLATOR',
6928
+ description: "@@@",
6929
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6930
+ pipelineInterface: {
6931
+ inputParameterNames: ['inputMessage'],
6932
+ outputParameterNames: ['outputMessage'],
6933
+ },
6934
+ };
6935
+
6936
+ /**
6937
+ * All available formfactor definitions
6938
+ *
6939
+ * @public exported from `@promptbook/core`
6940
+ */
6941
+ var FORMFACTOR_DEFINITIONS = [
6942
+ GenericFormfactorDefinition,
6943
+ ChatFormfactorDefinition,
6944
+ TranslatorFormfactorDefinition,
6945
+ SheetsFormfactorDefinition,
6946
+ ];
6947
+
6948
+ /**
6949
+ * Parses the formfactor command
6950
+ *
6951
+ * Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
6643
6952
  *
6644
6953
  * @see `documentationUrl` for more details
6645
6954
  * @private within the commands folder
6646
6955
  */
6647
- var jokerCommandParser = {
6956
+ var formfactorCommandParser = {
6648
6957
  /**
6649
6958
  * Name of the command
6650
6959
  */
6651
- name: 'JOKER',
6960
+ name: 'FORMFACTOR',
6652
6961
  /**
6653
- * BOILERPLATE command can be used in:
6962
+ * Aliases for the FORMFACTOR command
6654
6963
  */
6655
- isUsedInPipelineHead: false,
6656
- isUsedInPipelineTemplate: true,
6964
+ aliasNames: ['FORM', 'FF'],
6657
6965
  /**
6658
- * Description of the JOKER command
6966
+ * FORMFACTOR command can be used in:
6659
6967
  */
6660
- description: "Joker parameter is used instead of executing the template result if jokers value meets the expectations requirements",
6968
+ isUsedInPipelineHead: true,
6969
+ isUsedInPipelineTemplate: false,
6970
+ /**
6971
+ * Description of the FORMFACTOR command
6972
+ */
6973
+ description: "@@",
6661
6974
  /**
6662
6975
  * Link to documentation
6663
6976
  */
6664
- documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/66',
6977
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/168',
6665
6978
  /**
6666
- * Example usages of the JOKER command
6979
+ * Example usages of the FORMFACTOR command
6667
6980
  */
6668
- examples: ['JOKER {documentTitle}'],
6981
+ examples: ['FORMFACTOR Chatbot', 'FF Chat'],
6669
6982
  /**
6670
- * Parses the JOKER command
6983
+ * Parses the FORMFACTOR command
6671
6984
  */
6672
6985
  parse: function (input) {
6673
6986
  var args = input.args;
6674
6987
  if (args.length !== 1) {
6675
- throw new ParseError("JOKE command expects exactly one parameter name");
6988
+ throw new ParseError("FORMFACTOR command requires exactly one argument");
6989
+ }
6990
+ var formfactorNameCandidate = args[0].toUpperCase();
6991
+ var formfactor = FORMFACTOR_DEFINITIONS.find(function (definition) {
6992
+ return __spreadArray([definition.name], __read(__assign({ aliasNames: [] }, definition).aliasNames), false).includes(formfactorNameCandidate);
6993
+ });
6994
+ if (formfactor === undefined) {
6995
+ throw new ParseError(spaceTrim(function (block) { return "\n Unknown formfactor name \"".concat(formfactorNameCandidate, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
6996
+ var name = _a.name;
6997
+ return "- ".concat(name);
6998
+ }).join('\n')), "\n "); }));
6676
6999
  }
6677
- var parameterNameArg = args[0] || '';
6678
- var parameterName = validateParameterName(parameterNameArg);
6679
7000
  return {
6680
- type: 'JOKER',
6681
- parameterName: parameterName,
7001
+ type: 'FORMFACTOR',
7002
+ formfactorName: formfactor.name,
6682
7003
  };
6683
7004
  },
6684
7005
  /**
6685
- * Apply the JOKER command to the `pipelineJson`
7006
+ * Apply the FORMFACTOR command to the `pipelineJson`
6686
7007
  *
6687
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7008
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7009
+ */
7010
+ $applyToPipelineJson: function (command, $pipelineJson) {
7011
+ $pipelineJson.formfactorName = command.formfactorName;
7012
+ },
7013
+ /**
7014
+ * Converts the FORMFACTOR command back to string
7015
+ *
7016
+ * Note: This is used in `pipelineJsonToString` utility
7017
+ */
7018
+ stringify: function (command) {
7019
+ return "FORMFACTOR ".concat(command.formfactorName);
7020
+ },
7021
+ /**
7022
+ * Reads the FORMFACTOR command from the `PipelineJson`
7023
+ *
7024
+ * Note: This is used in `pipelineJsonToString` utility
7025
+ */
7026
+ takeFromPipelineJson: function (pipelineJson) {
7027
+ return [
7028
+ {
7029
+ type: 'FORMFACTOR',
7030
+ formfactorName: pipelineJson.formfactorName,
7031
+ },
7032
+ ];
7033
+ },
7034
+ };
7035
+
7036
+ /**
7037
+ * Parses the joker command
7038
+ *
7039
+ * @see `documentationUrl` for more details
7040
+ * @private within the commands folder
7041
+ */
7042
+ var jokerCommandParser = {
7043
+ /**
7044
+ * Name of the command
7045
+ */
7046
+ name: 'JOKER',
7047
+ /**
7048
+ * BOILERPLATE command can be used in:
7049
+ */
7050
+ isUsedInPipelineHead: false,
7051
+ isUsedInPipelineTemplate: true,
7052
+ /**
7053
+ * Description of the JOKER command
7054
+ */
7055
+ description: "Joker parameter is used instead of executing the template result if jokers value meets the expectations requirements",
7056
+ /**
7057
+ * Link to documentation
7058
+ */
7059
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/66',
7060
+ /**
7061
+ * Example usages of the JOKER command
7062
+ */
7063
+ examples: ['JOKER {documentTitle}'],
7064
+ /**
7065
+ * Parses the JOKER command
7066
+ */
7067
+ parse: function (input) {
7068
+ var args = input.args;
7069
+ if (args.length !== 1) {
7070
+ throw new ParseError("JOKE command expects exactly one parameter name");
7071
+ }
7072
+ var parameterNameArg = args[0] || '';
7073
+ var parameterName = validateParameterName(parameterNameArg);
7074
+ return {
7075
+ type: 'JOKER',
7076
+ parameterName: parameterName,
7077
+ };
7078
+ },
7079
+ /**
7080
+ * Apply the JOKER command to the `pipelineJson`
7081
+ *
7082
+ * Note: `$` is used to indicate that this function mutates given `templateJson`
6688
7083
  */
6689
7084
  $applyToTemplateJson: function (command, $templateJson) {
6690
7085
  $templateJson.jokerParameterNames = $templateJson.jokerParameterNames || [];
@@ -6904,7 +7299,7 @@ var parameterCommandParser = {
6904
7299
  // <- TODO: When [🥶] fixed, change to:
6905
7300
  // > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
6906
7301
  if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
6907
- throw new ParseError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterNameRaw, "} can not contain another parameter in description\n\n The description:\n ").concat(block(parameterDescriptionRaw), "\n "); }));
7302
+ throw new ParseError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameterNameRaw, "}` can not contain another parameter in description\n\n The description:\n ").concat(block(parameterDescriptionRaw), "\n "); }));
6908
7303
  }
6909
7304
  var isInput = normalized.startsWith('INPUT');
6910
7305
  var isOutput = normalized.startsWith('OUTPUT');
@@ -7177,82 +7572,6 @@ var postprocessCommandParser = {
7177
7572
  },
7178
7573
  };
7179
7574
 
7180
- /**
7181
- * Parses the BOOK_VERSION command
7182
- *
7183
- * @see `documentationUrl` for more details
7184
- * @private within the commands folder
7185
- */
7186
- var bookVersionCommandParser = {
7187
- /**
7188
- * Name of the command
7189
- */
7190
- name: 'BOOK_VERSION',
7191
- aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
7192
- /**
7193
- * BOILERPLATE command can be used in:
7194
- */
7195
- isUsedInPipelineHead: true,
7196
- isUsedInPipelineTemplate: false,
7197
- /**
7198
- * Description of the BOOK_VERSION command
7199
- */
7200
- description: "Which version of the Book language is the .ptbk.md using",
7201
- /**
7202
- * Link to documentation
7203
- */
7204
- documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
7205
- /**
7206
- * Example usages of the BOOK_VERSION command
7207
- */
7208
- examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
7209
- /**
7210
- * Parses the BOOK_VERSION command
7211
- */
7212
- parse: function (input) {
7213
- var args = input.args;
7214
- var promptbookVersion = args.pop();
7215
- if (promptbookVersion === undefined) {
7216
- throw new ParseError("Version is required");
7217
- }
7218
- if (!isValidPromptbookVersion(promptbookVersion)) {
7219
- throw new ParseError("Invalid Promptbook version \"".concat(promptbookVersion, "\""));
7220
- }
7221
- if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
7222
- throw new ParseError("Can not have more than one Promptbook version");
7223
- }
7224
- return {
7225
- type: 'BOOK_VERSION',
7226
- promptbookVersion: promptbookVersion,
7227
- };
7228
- },
7229
- /**
7230
- * Apply the BOOK_VERSION command to the `pipelineJson`
7231
- *
7232
- * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7233
- */
7234
- $applyToPipelineJson: function (command, $pipelineJson) {
7235
- // TODO: Warn if the version is overridden
7236
- $pipelineJson.promptbookVersion = command.promptbookVersion;
7237
- },
7238
- /**
7239
- * Converts the BOOK_VERSION command back to string
7240
- *
7241
- * Note: This is used in `pipelineJsonToString` utility
7242
- */
7243
- stringify: function (command) {
7244
- return "---"; // <- TODO: [🛋] Implement
7245
- },
7246
- /**
7247
- * Reads the BOOK_VERSION command from the `PipelineJson`
7248
- *
7249
- * Note: This is used in `pipelineJsonToString` utility
7250
- */
7251
- takeFromPipelineJson: function (pipelineJson) {
7252
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7253
- },
7254
- };
7255
-
7256
7575
  /**
7257
7576
  * Parses the url command
7258
7577
  *
@@ -7286,9 +7605,9 @@ var urlCommandParser = {
7286
7605
  * Example usages of the URL command
7287
7606
  */
7288
7607
  examples: [
7289
- 'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
7290
- 'URL https://promptbook.studio/library/write-cv.ptbk.md',
7291
- 'https://promptbook.studio/library/write-cv.ptbk.md',
7608
+ 'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
7609
+ 'URL https://promptbook.studio/library/write-cv.book.md',
7610
+ 'https://promptbook.studio/library/write-cv.book.md',
7292
7611
  ],
7293
7612
  /**
7294
7613
  * Parses the URL command
@@ -7486,99 +7805,6 @@ var instrumentCommandParser = {
7486
7805
  * Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
7487
7806
  */
7488
7807
 
7489
- /**
7490
- * Parses the boilerplate command
7491
- *
7492
- * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.ptbk.md` file
7493
- *
7494
- * @see `documentationUrl` for more details
7495
- * @private within the commands folder
7496
- */
7497
- var boilerplateCommandParser = {
7498
- /**
7499
- * Name of the command
7500
- */
7501
- name: 'BOILERPLATE',
7502
- /**
7503
- * Aliases for the BOILERPLATE command
7504
- */
7505
- aliasNames: ['BP'],
7506
- /**
7507
- * BOILERPLATE command can be used in:
7508
- */
7509
- isUsedInPipelineHead: true,
7510
- isUsedInPipelineTemplate: true,
7511
- /**
7512
- * Description of the BOILERPLATE command
7513
- */
7514
- description: "@@",
7515
- /**
7516
- * Link to documentation
7517
- */
7518
- documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
7519
- /**
7520
- * Example usages of the BOILERPLATE command
7521
- */
7522
- examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
7523
- /**
7524
- * Parses the BOILERPLATE command
7525
- */
7526
- parse: function (input) {
7527
- var args = input.args;
7528
- if (args.length !== 1) {
7529
- throw new ParseError("BOILERPLATE command requires exactly one argument");
7530
- }
7531
- var value = args[0].toLowerCase();
7532
- if (value.includes('brr')) {
7533
- throw new ParseError("BOILERPLATE value can not contain brr");
7534
- }
7535
- return {
7536
- type: 'BOILERPLATE',
7537
- value: value,
7538
- };
7539
- },
7540
- /**
7541
- * Apply the BOILERPLATE command to the `pipelineJson`
7542
- *
7543
- * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7544
- */
7545
- $applyToPipelineJson: function (command, $pipelineJson) {
7546
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7547
- },
7548
- /**
7549
- * Apply the BOILERPLATE command to the `pipelineJson`
7550
- *
7551
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7552
- */
7553
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7554
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7555
- },
7556
- /**
7557
- * Converts the BOILERPLATE command back to string
7558
- *
7559
- * Note: This is used in `pipelineJsonToString` utility
7560
- */
7561
- stringify: function (command) {
7562
- return "---"; // <- TODO: [🛋] Implement
7563
- },
7564
- /**
7565
- * Reads the BOILERPLATE command from the `PipelineJson`
7566
- *
7567
- * Note: This is used in `pipelineJsonToString` utility
7568
- */
7569
- takeFromPipelineJson: function (pipelineJson) {
7570
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7571
- },
7572
- /**
7573
- * Reads the BOILERPLATE command from the `TemplateJson`
7574
- *
7575
- * Note: This is used in `pipelineJsonToString` utility
7576
- */
7577
- takeFromTemplateJson: function ($templateJson) {
7578
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7579
- },
7580
- };
7581
-
7582
7808
  /**
7583
7809
  * All available command parsers
7584
7810
  *
@@ -7593,6 +7819,7 @@ var COMMANDS = [
7593
7819
  parameterCommandParser,
7594
7820
  postprocessCommandParser,
7595
7821
  bookVersionCommandParser,
7822
+ formfactorCommandParser,
7596
7823
  urlCommandParser,
7597
7824
  knowledgeCommandParser,
7598
7825
  actionCommandParser,
@@ -7904,7 +8131,7 @@ function splitMarkdownIntoSections(markdown) {
7904
8131
  return;
7905
8132
  }
7906
8133
  if (!section.startsWith('#')) {
7907
- section = "# Untitled\n\n".concat(section);
8134
+ section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
7908
8135
  }
7909
8136
  sections.push(section);
7910
8137
  buffer = [];
@@ -7968,7 +8195,7 @@ function flattenMarkdown(markdown) {
7968
8195
  var e_1, _a;
7969
8196
  var sections = splitMarkdownIntoSections(markdown);
7970
8197
  if (sections.length === 0) {
7971
- return '# Untitled';
8198
+ return "# ".concat(DEFAULT_TITLE);
7972
8199
  }
7973
8200
  var flattenedMarkdown = '';
7974
8201
  var parsedSections = sections.map(parseMarkdownSection);
@@ -7979,7 +8206,7 @@ function flattenMarkdown(markdown) {
7979
8206
  }
7980
8207
  else {
7981
8208
  parsedSections.unshift(firstSection);
7982
- flattenedMarkdown += "# Untitled" + "\n\n"; // <- [🧠] Maybe 3 new lines?
8209
+ flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
7983
8210
  }
7984
8211
  try {
7985
8212
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
@@ -8051,8 +8278,8 @@ function titleToName(value) {
8051
8278
  * Note: This function does not validate logic of the pipeline only the parsing
8052
8279
  * Note: This function acts as compilation process
8053
8280
  *
8054
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8055
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8281
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8282
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8056
8283
  * @throws {ParseError} if the promptbook string is not valid
8057
8284
  * @public exported from `@promptbook/core`
8058
8285
  */
@@ -8061,8 +8288,9 @@ function pipelineStringToJsonSync(pipelineString) {
8061
8288
  var $pipelineJson = {
8062
8289
  title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
8063
8290
  pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
8064
- promptbookVersion: undefined /* <- Note: By default no explicit version */,
8291
+ bookVersion: undefined /* <- Note: By default no explicit version */,
8065
8292
  description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
8293
+ formfactorName: 'GENERIC',
8066
8294
  parameters: [],
8067
8295
  templates: [],
8068
8296
  knowledgeSources: [],
@@ -8117,7 +8345,7 @@ function pipelineStringToJsonSync(pipelineString) {
8117
8345
  existingParameter.description &&
8118
8346
  existingParameter.description !== parameterDescription &&
8119
8347
  parameterDescription) {
8120
- throw new ParseError(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 "); }));
8348
+ throw new ParseError(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 "); }));
8121
8349
  }
8122
8350
  if (existingParameter) {
8123
8351
  if (parameterDescription) {
@@ -8444,10 +8672,10 @@ function pipelineStringToJsonSync(pipelineString) {
8444
8672
  * Note: This function does not validate logic of the pipeline only the parsing
8445
8673
  * Note: This function acts as compilation process
8446
8674
  *
8447
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8675
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8448
8676
  * @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
8449
8677
  * @param options - Options and tools for the compilation
8450
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8678
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8451
8679
  * @throws {ParseError} if the promptbook string is not valid
8452
8680
  * @public exported from `@promptbook/core`
8453
8681
  */
@@ -8663,7 +8891,7 @@ function stringifyPipelineJson(pipeline) {
8663
8891
  return pipelineJsonStringified;
8664
8892
  }
8665
8893
  /**
8666
- * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.ptbk.md
8894
+ * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
8667
8895
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
8668
8896
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
8669
8897
  * TODO: [🍙] Make some standard order of json properties
@@ -8776,6 +9004,21 @@ function usageToHuman(usage) {
8776
9004
  * TODO: [🏛] Maybe make some markdown builder
8777
9005
  */
8778
9006
 
9007
+ /**
9008
+ * Boilerplate is form of app that @@@
9009
+ *
9010
+ * @public exported from `@promptbook/core`
9011
+ */
9012
+ var BoilerplateFormfactorDefinition = {
9013
+ name: 'BOILERPLATE',
9014
+ description: "@@@",
9015
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
9016
+ pipelineInterface: {
9017
+ inputParameterNames: [],
9018
+ outputParameterNames: [],
9019
+ },
9020
+ };
9021
+
8779
9022
  /**
8780
9023
  * @@@
8781
9024
  *
@@ -8937,7 +9180,7 @@ function createLlmToolsFromConfiguration(configuration, options) {
8937
9180
  */
8938
9181
 
8939
9182
  /**
8940
- * Stores
9183
+ * Stores data in memory (HEAP)
8941
9184
  *
8942
9185
  * @public exported from `@promptbook/core`
8943
9186
  */
@@ -9067,13 +9310,18 @@ function cacheLlmTools(llmTools, options) {
9067
9310
  promptResult = _c.sent();
9068
9311
  return [3 /*break*/, 11];
9069
9312
  case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
9070
- case 11: return [4 /*yield*/, storage.setItem(key, {
9313
+ case 11:
9314
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
9315
+ // promptResult.timing: FromtoItems
9316
+ return [4 /*yield*/, storage.setItem(key, {
9071
9317
  date: $currentDate(),
9072
9318
  promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
9073
9319
  prompt: prompt,
9074
9320
  promptResult: promptResult,
9075
9321
  })];
9076
9322
  case 12:
9323
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
9324
+ // promptResult.timing: FromtoItems
9077
9325
  _c.sent();
9078
9326
  return [2 /*return*/, promptResult];
9079
9327
  }
@@ -9325,6 +9573,83 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
9325
9573
  },
9326
9574
  });
9327
9575
 
9576
+ /**
9577
+ * @@@
9578
+ *
9579
+ * @public exported from `@promptbook/core`
9580
+ */
9581
+ function getPipelineInterface(pipeline) {
9582
+ var e_1, _a, e_2, _b;
9583
+ var pipelineInterface = {
9584
+ inputParameterNames: [],
9585
+ outputParameterNames: [],
9586
+ };
9587
+ try {
9588
+ for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
9589
+ var parameter = _d.value;
9590
+ var name_1 = parameter.name, isInput = parameter.isInput, isOutput = parameter.isOutput;
9591
+ if (isInput) {
9592
+ pipelineInterface.inputParameterNames.push(name_1);
9593
+ }
9594
+ if (isOutput) {
9595
+ pipelineInterface.outputParameterNames.push(name_1);
9596
+ }
9597
+ }
9598
+ }
9599
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9600
+ finally {
9601
+ try {
9602
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
9603
+ }
9604
+ finally { if (e_1) throw e_1.error; }
9605
+ }
9606
+ try {
9607
+ for (var _e = __values(['inputParameterNames', 'outputParameterNames']), _f = _e.next(); !_f.done; _f = _e.next()) {
9608
+ var key = _f.value;
9609
+ pipelineInterface[key].sort(function (a, b) { return a.localeCompare(b); });
9610
+ }
9611
+ }
9612
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
9613
+ finally {
9614
+ try {
9615
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
9616
+ }
9617
+ finally { if (e_2) throw e_2.error; }
9618
+ }
9619
+ return $deepFreeze(pipelineInterface);
9620
+ }
9621
+ /**
9622
+ * TODO: !!!!!! Write unit test
9623
+ */
9624
+
9625
+ /**
9626
+ * @@@
9627
+ *
9628
+ * @public exported from `@promptbook/core`
9629
+ */
9630
+ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
9631
+ // TODO: [🧠] !!! Implement better
9632
+ return JSON.stringify(pipelineInterface1) === JSON.stringify(pipelineInterface2);
9633
+ }
9634
+ /**
9635
+ * TODO: [🧠] !!! Return more states than true/false - 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
9636
+ * TODO: !!! Write unit test
9637
+ */
9638
+
9639
+ /**
9640
+ * @@@
9641
+ *
9642
+ * @public exported from `@promptbook/core`
9643
+ */
9644
+ function isPipelineImplementingInterface(options) {
9645
+ var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
9646
+ return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
9647
+ }
9648
+ /**
9649
+ * TODO: !!!!!! Test real implementing NOT equality
9650
+ * TODO: !!!!!! Write unit test
9651
+ */
9652
+
9328
9653
  /**
9329
9654
  * Metadata of the scraper
9330
9655
  *
@@ -9449,6 +9774,54 @@ var websiteScraperMetadata = $deepFreeze({
9449
9774
  */
9450
9775
  var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
9451
9776
 
9777
+ /**
9778
+ * Behaves like a storage but forgets everything you put in it
9779
+ *
9780
+ * @public exported from `@promptbook/core`
9781
+ */
9782
+ var BlackholeStorage = /** @class */ (function () {
9783
+ function BlackholeStorage() {
9784
+ }
9785
+ Object.defineProperty(BlackholeStorage.prototype, "length", {
9786
+ /**
9787
+ * Returns the number of key/value pairs currently present in the list associated with the object.
9788
+ */
9789
+ get: function () {
9790
+ return 0;
9791
+ },
9792
+ enumerable: false,
9793
+ configurable: true
9794
+ });
9795
+ /**
9796
+ * Empties the list associated with the object of all key/value pairs, if there are any.
9797
+ */
9798
+ BlackholeStorage.prototype.clear = function () { };
9799
+ /**
9800
+ * Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
9801
+ * @param key
9802
+ */
9803
+ BlackholeStorage.prototype.getItem = function (key) {
9804
+ return null;
9805
+ };
9806
+ /**
9807
+ * Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
9808
+ */
9809
+ BlackholeStorage.prototype.key = function (index) {
9810
+ return null;
9811
+ };
9812
+ /**
9813
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
9814
+ */
9815
+ BlackholeStorage.prototype.setItem = function (key, value) {
9816
+ };
9817
+ /**
9818
+ * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
9819
+ */
9820
+ BlackholeStorage.prototype.removeItem = function (key) {
9821
+ };
9822
+ return BlackholeStorage;
9823
+ }());
9824
+
9452
9825
  /**
9453
9826
  * This class behaves like LocalStorage but separates keys by prefix
9454
9827
  *
@@ -9799,5 +10172,5 @@ function executionReportJsonToString(executionReportJson, options) {
9799
10172
  * TODO: [🧠] Should be in generated file GENERATOR_WARNING
9800
10173
  */
9801
10174
 
9802
- export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
10175
+ export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GenericFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SheetsFormfactorDefinition, TemplateTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
9803
10176
  //# sourceMappingURL=index.es.js.map