@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/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-7';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  */
@@ -221,13 +221,13 @@
221
221
  /**
222
222
  * Converts promptbook in JSON format to string format
223
223
  *
224
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
225
- * @returns Promptbook in string format (.ptbk.md)
224
+ * @param pipelineJson Promptbook in JSON format (.book.json)
225
+ * @returns Promptbook in string format (.book.md)
226
226
  * @public exported from `@promptbook/core`
227
227
  */
228
228
  function pipelineJsonToString(pipelineJson) {
229
229
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
230
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
230
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
231
231
  var pipelineString = "# ".concat(title);
232
232
  if (description) {
233
233
  pipelineString += '\n\n';
@@ -237,8 +237,10 @@
237
237
  if (pipelineUrl) {
238
238
  commands.push("PIPELINE URL ".concat(pipelineUrl));
239
239
  }
240
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
241
- // TODO: [main] !!! This increase size of the bundle and is probbably not necessary
240
+ if (bookVersion !== "undefined") {
241
+ commands.push("BOOK VERSION ".concat(bookVersion));
242
+ }
243
+ // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
242
244
  pipelineString = prettifyMarkdown(pipelineString);
243
245
  try {
244
246
  for (var _g = __values(parameters.filter(function (_a) {
@@ -418,7 +420,7 @@
418
420
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
419
421
  * TODO: [🏛] Maybe make some markdown builder
420
422
  * TODO: [🏛] Escape all
421
- * TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
423
+ * TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
422
424
  */
423
425
 
424
426
  /**
@@ -648,6 +650,13 @@
648
650
  * @public exported from `@promptbook/core`
649
651
  */
650
652
  var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
653
+ // <- TODO: [🐊] Pick the best claim
654
+ /**
655
+ * When the title is not provided, the default title is used
656
+ *
657
+ * @public exported from `@promptbook/core`
658
+ */
659
+ var DEFAULT_TITLE = "Untitled";
651
660
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
652
661
  /**
653
662
  * The maximum number of iterations for a loops
@@ -811,6 +820,7 @@
811
820
  // Note: In normal situations, we check the pipeline logic:
812
821
  true);
813
822
  /**
823
+ * TODO: Extract `constants.ts` from `config.ts`
814
824
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
815
825
  */
816
826
 
@@ -987,7 +997,7 @@
987
997
  if (!url.startsWith('https://')) {
988
998
  return false;
989
999
  }
990
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
1000
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
991
1001
  return false;
992
1002
  }
993
1003
  if (url.includes('#')) {
@@ -1056,9 +1066,9 @@
1056
1066
  // <- Note: [🚲]
1057
1067
  throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1058
1068
  }
1059
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
1069
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
1060
1070
  // <- Note: [🚲]
1061
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1071
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1062
1072
  }
1063
1073
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1064
1074
  if (!Array.isArray(pipeline.parameters)) {
@@ -1072,18 +1082,18 @@
1072
1082
  }
1073
1083
  var _loop_1 = function (parameter) {
1074
1084
  if (parameter.isInput && parameter.isOutput) {
1075
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
1085
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Parameter `{".concat(parameter.name, "}` can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
1076
1086
  }
1077
1087
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
1078
1088
  if (!parameter.isInput &&
1079
1089
  !parameter.isOutput &&
1080
1090
  !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
1081
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
1091
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
1082
1092
  }
1083
1093
  // Note: Testing that parameter is either input or result of some template
1084
1094
  if (!parameter.isInput &&
1085
1095
  !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
1086
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of {").concat(parameter.name, "}\n 2) Add template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
1096
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add template that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1087
1097
  }
1088
1098
  };
1089
1099
  try {
@@ -1111,7 +1121,7 @@
1111
1121
  var _loop_2 = function (template) {
1112
1122
  var e_4, _h, e_5, _j;
1113
1123
  if (definedParameters.has(template.resultingParameterName)) {
1114
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1124
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1115
1125
  }
1116
1126
  if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1117
1127
  throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -1124,7 +1134,7 @@
1124
1134
  }
1125
1135
  var _loop_4 = function (joker) {
1126
1136
  if (!template.dependentParameterNames.includes(joker)) {
1127
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1137
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1128
1138
  }
1129
1139
  };
1130
1140
  try {
@@ -1219,14 +1229,24 @@
1219
1229
  if (currentlyResovedTemplates.length === 0) {
1220
1230
  throw new PipelineLogicError(
1221
1231
  // TODO: [🐎] DRY
1222
- spaceTrim.spaceTrim(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
1232
+ spaceTrim.spaceTrim(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
1223
1233
  .map(function (_a) {
1224
1234
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
1225
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
1226
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1235
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
1236
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
1227
1237
  .join(' and '));
1228
1238
  })
1229
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n\n "); }));
1239
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
1240
+ .filter(function (name) {
1241
+ return !RESERVED_PARAMETER_NAMES.includes(name);
1242
+ })
1243
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1244
+ .join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
1245
+ .filter(function (name) {
1246
+ return RESERVED_PARAMETER_NAMES.includes(name);
1247
+ })
1248
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1249
+ .join('\n')), "\n\n\n "); }));
1230
1250
  }
1231
1251
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1232
1252
  var resultingParameterName = _a.resultingParameterName;
@@ -1237,6 +1257,7 @@
1237
1257
  while (unresovedTemplates.length > 0) {
1238
1258
  _loop_3();
1239
1259
  }
1260
+ // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
1240
1261
  }
1241
1262
  /**
1242
1263
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -2229,8 +2250,8 @@
2229
2250
  else if (errors.length > 1) {
2230
2251
  throw new PipelineExecutionError(
2231
2252
  // TODO: Tell which execution tools failed like
2232
- // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
2233
- // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
2253
+ // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2254
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2234
2255
  // 3) ...
2235
2256
  spaceTrim__default["default"](function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
2236
2257
  .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
@@ -2305,7 +2326,7 @@
2305
2326
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2306
2327
  */
2307
2328
 
2308
- 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"}];
2329
+ 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"}];
2309
2330
 
2310
2331
  /**
2311
2332
  * This error indicates that the pipeline collection cannot be propperly loaded
@@ -3229,11 +3250,11 @@
3229
3250
  for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
3230
3251
  var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
3231
3252
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
3232
- throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
3253
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
3233
3254
  }
3234
3255
  else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
3235
3256
  // TODO: [🍵]
3236
- throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
3257
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
3237
3258
  }
3238
3259
  }
3239
3260
  }
@@ -3260,11 +3281,11 @@
3260
3281
  throw new PipelineExecutionError('Parameter is already opened or not closed');
3261
3282
  }
3262
3283
  if (parameters[parameterName] === undefined) {
3263
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
3284
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
3264
3285
  }
3265
3286
  var parameterValue = parameters[parameterName];
3266
3287
  if (parameterValue === undefined) {
3267
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
3288
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
3268
3289
  }
3269
3290
  parameterValue = parameterValue.toString();
3270
3291
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
@@ -3308,30 +3329,45 @@
3308
3329
  return text.length;
3309
3330
  }
3310
3331
 
3332
+ /**
3333
+ * Number of characters per standard line with 11pt Arial font size.
3334
+ *
3335
+ * @public exported from `@promptbook/utils`
3336
+ */
3337
+ var CHARACTERS_PER_STANDARD_LINE = 63;
3338
+ /**
3339
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
3340
+ *
3341
+ * @public exported from `@promptbook/utils`
3342
+ */
3343
+ var LINES_PER_STANDARD_PAGE = 44;
3344
+ /**
3345
+ * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
3346
+ */
3347
+
3311
3348
  /**
3312
3349
  * Counts number of lines in the text
3313
3350
  *
3351
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
3352
+ *
3314
3353
  * @public exported from `@promptbook/utils`
3315
3354
  */
3316
3355
  function countLines(text) {
3317
- if (text === '') {
3318
- return 0;
3319
- }
3320
- return text.split('\n').length;
3356
+ text = text.replace('\r\n', '\n');
3357
+ text = text.replace('\r', '\n');
3358
+ var lines = text.split('\n');
3359
+ return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
3321
3360
  }
3322
3361
 
3323
3362
  /**
3324
3363
  * Counts number of pages in the text
3325
3364
  *
3365
+ * 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.
3366
+ *
3326
3367
  * @public exported from `@promptbook/utils`
3327
3368
  */
3328
3369
  function countPages(text) {
3329
- if (text === '') {
3330
- return 0;
3331
- }
3332
- var pagesByLinesCount = Math.ceil(countLines(text) / 44);
3333
- var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
3334
- return Math.max(pagesByLinesCount, pagesByCharactersCount);
3370
+ return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
3335
3371
  }
3336
3372
 
3337
3373
  /**
@@ -3894,7 +3930,7 @@
3894
3930
  promptTitle: template.title,
3895
3931
  promptMessage: replaceParameters(template.description || '', parameters),
3896
3932
  defaultValue: replaceParameters(preparedContent, parameters),
3897
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
3933
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
3898
3934
  placeholder: undefined,
3899
3935
  priority: priority,
3900
3936
  }))];
@@ -4322,7 +4358,7 @@
4322
4358
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4323
4359
  // Houston, we have a problem
4324
4360
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
4325
- throw new UnexpectedError(spaceTrim.spaceTrim(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 "); }));
4361
+ throw new UnexpectedError(spaceTrim.spaceTrim(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 "); }));
4326
4362
  }
4327
4363
  };
4328
4364
  try {
@@ -4401,7 +4437,7 @@
4401
4437
  var _loop_1 = function (parameter) {
4402
4438
  if (parametersToPass[parameter.name] === undefined) {
4403
4439
  // [4]
4404
- $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(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 "); })));
4440
+ $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(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 "); })));
4405
4441
  return "continue";
4406
4442
  }
4407
4443
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -4460,7 +4496,7 @@
4460
4496
  pipelineUrl: preparedPipeline.pipelineUrl,
4461
4497
  title: preparedPipeline.title,
4462
4498
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
4463
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
4499
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
4464
4500
  description: preparedPipeline.description,
4465
4501
  promptExecutions: [],
4466
4502
  };
@@ -4488,7 +4524,7 @@
4488
4524
  case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
4489
4525
  isSuccessful: false,
4490
4526
  errors: __spreadArray([
4491
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
4527
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
4492
4528
  ], __read(errors), false).map(serializeError),
4493
4529
  warnings: [],
4494
4530
  executionReport: executionReport,
@@ -4536,7 +4572,7 @@
4536
4572
  case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
4537
4573
  isSuccessful: false,
4538
4574
  errors: __spreadArray([
4539
- new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4575
+ new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4540
4576
  ], __read(errors), false).map(serializeError),
4541
4577
  warnings: warnings.map(serializeError),
4542
4578
  executionReport: executionReport,
@@ -4610,14 +4646,24 @@
4610
4646
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
4611
4647
  throw new UnexpectedError(
4612
4648
  // TODO: [🐎] DRY
4613
- spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates_1
4649
+ spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates_1
4614
4650
  .map(function (_a) {
4615
4651
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
4616
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
4617
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
4652
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
4653
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
4618
4654
  .join(' and '));
4619
4655
  })
4620
- .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 "); }));
4656
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
4657
+ .filter(function (name) {
4658
+ return !RESERVED_PARAMETER_NAMES.includes(name);
4659
+ })
4660
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
4661
+ .join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
4662
+ .filter(function (name) {
4663
+ return RESERVED_PARAMETER_NAMES.includes(name);
4664
+ })
4665
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
4666
+ .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
4621
4667
  case 1:
4622
4668
  if (!!currentTemplate) return [3 /*break*/, 3];
4623
4669
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -4809,7 +4855,7 @@
4809
4855
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
4810
4856
  _b = createPipelineExecutor;
4811
4857
  _c = {};
4812
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
4858
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
4813
4859
  case 1:
4814
4860
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
4815
4861
  _c.tools = tools,
@@ -5566,13 +5612,14 @@
5566
5612
  */
5567
5613
  function clonePipeline(pipeline) {
5568
5614
  // Note: Not using spread operator (...) because @@@
5569
- 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;
5615
+ 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;
5570
5616
  return {
5571
5617
  pipelineUrl: pipelineUrl,
5572
5618
  sourceFile: sourceFile,
5573
5619
  title: title,
5574
- promptbookVersion: promptbookVersion,
5620
+ bookVersion: bookVersion,
5575
5621
  description: description,
5622
+ formfactorName: formfactorName,
5576
5623
  parameters: parameters,
5577
5624
  templates: templates,
5578
5625
  knowledgeSources: knowledgeSources,
@@ -5783,7 +5830,7 @@
5783
5830
  throw new ParseError("Source not valid");
5784
5831
  }
5785
5832
  if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
5786
- throw new ParseError("Source cannot be outside of the .ptbk.md folder");
5833
+ throw new ParseError("Source cannot be outside of the .book.md folder");
5787
5834
  }
5788
5835
  return {
5789
5836
  type: 'KNOWLEDGE',
@@ -6003,6 +6050,175 @@
6003
6050
  * ```
6004
6051
  */
6005
6052
 
6053
+ /**
6054
+ * Parses the boilerplate command
6055
+ *
6056
+ * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
6057
+ *
6058
+ * @see `documentationUrl` for more details
6059
+ * @private within the commands folder
6060
+ */
6061
+ var boilerplateCommandParser = {
6062
+ /**
6063
+ * Name of the command
6064
+ */
6065
+ name: 'BOILERPLATE',
6066
+ /**
6067
+ * Aliases for the BOILERPLATE command
6068
+ */
6069
+ aliasNames: ['BP'],
6070
+ /**
6071
+ * BOILERPLATE command can be used in:
6072
+ */
6073
+ isUsedInPipelineHead: true,
6074
+ isUsedInPipelineTemplate: true,
6075
+ /**
6076
+ * Description of the BOILERPLATE command
6077
+ */
6078
+ description: "@@",
6079
+ /**
6080
+ * Link to documentation
6081
+ */
6082
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
6083
+ /**
6084
+ * Example usages of the BOILERPLATE command
6085
+ */
6086
+ examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
6087
+ /**
6088
+ * Parses the BOILERPLATE command
6089
+ */
6090
+ parse: function (input) {
6091
+ var args = input.args;
6092
+ if (args.length !== 1) {
6093
+ throw new ParseError("BOILERPLATE command requires exactly one argument");
6094
+ }
6095
+ var value = args[0].toLowerCase();
6096
+ if (value.includes('brr')) {
6097
+ throw new ParseError("BOILERPLATE value can not contain brr");
6098
+ }
6099
+ return {
6100
+ type: 'BOILERPLATE',
6101
+ value: value,
6102
+ };
6103
+ },
6104
+ /**
6105
+ * Apply the BOILERPLATE command to the `pipelineJson`
6106
+ *
6107
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6108
+ */
6109
+ $applyToPipelineJson: function (command, $pipelineJson) {
6110
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6111
+ },
6112
+ /**
6113
+ * Apply the BOILERPLATE command to the `pipelineJson`
6114
+ *
6115
+ * Note: `$` is used to indicate that this function mutates given `templateJson`
6116
+ */
6117
+ $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6118
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6119
+ },
6120
+ /**
6121
+ * Converts the BOILERPLATE command back to string
6122
+ *
6123
+ * Note: This is used in `pipelineJsonToString` utility
6124
+ */
6125
+ stringify: function (command) {
6126
+ return "---"; // <- TODO: [🛋] Implement
6127
+ },
6128
+ /**
6129
+ * Reads the BOILERPLATE command from the `PipelineJson`
6130
+ *
6131
+ * Note: This is used in `pipelineJsonToString` utility
6132
+ */
6133
+ takeFromPipelineJson: function (pipelineJson) {
6134
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6135
+ },
6136
+ /**
6137
+ * Reads the BOILERPLATE command from the `TemplateJson`
6138
+ *
6139
+ * Note: This is used in `pipelineJsonToString` utility
6140
+ */
6141
+ takeFromTemplateJson: function ($templateJson) {
6142
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6143
+ },
6144
+ };
6145
+
6146
+ /**
6147
+ * Parses the BOOK_VERSION command
6148
+ *
6149
+ * @see `documentationUrl` for more details
6150
+ * @private within the commands folder
6151
+ */
6152
+ var bookVersionCommandParser = {
6153
+ /**
6154
+ * Name of the command
6155
+ */
6156
+ name: 'BOOK_VERSION',
6157
+ aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
6158
+ /**
6159
+ * BOILERPLATE command can be used in:
6160
+ */
6161
+ isUsedInPipelineHead: true,
6162
+ isUsedInPipelineTemplate: false,
6163
+ /**
6164
+ * Description of the BOOK_VERSION command
6165
+ */
6166
+ description: "Which version of the Book language is the .book.md using",
6167
+ /**
6168
+ * Link to documentation
6169
+ */
6170
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
6171
+ /**
6172
+ * Example usages of the BOOK_VERSION command
6173
+ */
6174
+ examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
6175
+ /**
6176
+ * Parses the BOOK_VERSION command
6177
+ */
6178
+ parse: function (input) {
6179
+ var args = input.args;
6180
+ var bookVersion = args.pop();
6181
+ if (bookVersion === undefined) {
6182
+ throw new ParseError("Version is required");
6183
+ }
6184
+ if (!isValidPromptbookVersion(bookVersion)) {
6185
+ throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
6186
+ }
6187
+ if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
6188
+ throw new ParseError("Can not have more than one Promptbook version");
6189
+ }
6190
+ return {
6191
+ type: 'BOOK_VERSION',
6192
+ bookVersion: bookVersion,
6193
+ };
6194
+ },
6195
+ /**
6196
+ * Apply the BOOK_VERSION command to the `pipelineJson`
6197
+ *
6198
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6199
+ */
6200
+ $applyToPipelineJson: function (command, $pipelineJson) {
6201
+ // TODO: Warn if the version is overridden
6202
+ $pipelineJson.bookVersion = command.bookVersion;
6203
+ },
6204
+ /**
6205
+ * Converts the BOOK_VERSION command back to string
6206
+ *
6207
+ * Note: This is used in `pipelineJsonToString` utility
6208
+ */
6209
+ stringify: function (command) {
6210
+ return "---"; // <- TODO: [🛋] Implement
6211
+ },
6212
+ /**
6213
+ * Reads the BOOK_VERSION command from the `PipelineJson`
6214
+ *
6215
+ * Note: This is used in `pipelineJsonToString` utility
6216
+ */
6217
+ takeFromPipelineJson: function (pipelineJson) {
6218
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6219
+ },
6220
+ };
6221
+
6006
6222
  /**
6007
6223
  * Units of text measurement
6008
6224
  *
@@ -6415,7 +6631,7 @@
6415
6631
  /**
6416
6632
  * Parses the foreach command
6417
6633
  *
6418
- * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.ptbk.md` file
6634
+ * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
6419
6635
  *
6420
6636
  * @see `documentationUrl` for more details
6421
6637
  * @private within the commands folder
@@ -6565,7 +6781,7 @@
6565
6781
  },
6566
6782
  };
6567
6783
  /**
6568
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH with wrong parsing and logic
6784
+ * TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
6569
6785
  */
6570
6786
 
6571
6787
  /**
@@ -6641,52 +6857,231 @@
6641
6857
  };
6642
6858
 
6643
6859
  /**
6644
- * Parses the joker command
6860
+ * @@@
6861
+ *
6862
+ * @public exported from `@promptbook/core`
6863
+ */
6864
+ var ChatFormfactorDefinition = {
6865
+ name: 'CHATBOT',
6866
+ aliasNames: ['CHAT'],
6867
+ description: "@@@",
6868
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6869
+ pipelineInterface: {
6870
+ inputParameterNames: ['previousTitle', 'previousConversationSummary', 'userMessage'],
6871
+ outputParameterNames: ['title', 'conversationSummary', 'chatbotResponse'],
6872
+ /*
6873
+ <- TODO: !!!!!! Change to
6874
+
6875
+ - INPUT PARAMETER `{previousTitle}` Previous title of the conversation
6876
+ - INPUT PARAMETER `{previousConversationSummary}` Previous conversation summary
6877
+ - INPUT PARAMETER `{userMessage}` User message
6878
+ - OUTPUT PARAMETER `{title}` Title of the conversation
6879
+ - OUTPUT PARAMETER `{conversationSummary}` Summary of the conversation
6880
+ - OUTPUT PARAMETER `{chatbotResponse}` Chatbot response
6881
+
6882
+ */
6883
+ },
6884
+ };
6885
+
6886
+ /**
6887
+ * @@@
6888
+ *
6889
+ * @public exported from `@promptbook/core`
6890
+ */
6891
+ var GENERIC_PIPELINE_INTERFACE = {
6892
+ inputParameterNames: [],
6893
+ outputParameterNames: [],
6894
+ };
6895
+
6896
+ /**
6897
+ * @@@
6898
+ *
6899
+ * @public exported from `@promptbook/core`
6900
+ */
6901
+ var GenericFormfactorDefinition = {
6902
+ name: 'GENERIC',
6903
+ description: "@@@",
6904
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6905
+ pipelineInterface: GENERIC_PIPELINE_INTERFACE,
6906
+ };
6907
+
6908
+ /**
6909
+ * Sheets is form of app that @@@
6910
+ *
6911
+ * @public exported from `@promptbook/core`
6912
+ */
6913
+ var SheetsFormfactorDefinition = {
6914
+ name: 'SHEETS',
6915
+ description: "@@@",
6916
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6917
+ pipelineInterface: {
6918
+ inputParameterNames: ['inputSheet'],
6919
+ outputParameterNames: ['outputSheet'],
6920
+ },
6921
+ };
6922
+
6923
+ /**
6924
+ * Translator is form of app that @@@
6925
+ *
6926
+ * @public exported from `@promptbook/core`
6927
+ */
6928
+ var TranslatorFormfactorDefinition = {
6929
+ name: 'TRANSLATOR',
6930
+ description: "@@@",
6931
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6932
+ pipelineInterface: {
6933
+ inputParameterNames: ['inputMessage'],
6934
+ outputParameterNames: ['outputMessage'],
6935
+ },
6936
+ };
6937
+
6938
+ /**
6939
+ * All available formfactor definitions
6940
+ *
6941
+ * @public exported from `@promptbook/core`
6942
+ */
6943
+ var FORMFACTOR_DEFINITIONS = [
6944
+ GenericFormfactorDefinition,
6945
+ ChatFormfactorDefinition,
6946
+ TranslatorFormfactorDefinition,
6947
+ SheetsFormfactorDefinition,
6948
+ ];
6949
+
6950
+ /**
6951
+ * Parses the formfactor command
6952
+ *
6953
+ * Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
6645
6954
  *
6646
6955
  * @see `documentationUrl` for more details
6647
6956
  * @private within the commands folder
6648
6957
  */
6649
- var jokerCommandParser = {
6958
+ var formfactorCommandParser = {
6650
6959
  /**
6651
6960
  * Name of the command
6652
6961
  */
6653
- name: 'JOKER',
6962
+ name: 'FORMFACTOR',
6654
6963
  /**
6655
- * BOILERPLATE command can be used in:
6964
+ * Aliases for the FORMFACTOR command
6656
6965
  */
6657
- isUsedInPipelineHead: false,
6658
- isUsedInPipelineTemplate: true,
6966
+ aliasNames: ['FORM', 'FF'],
6659
6967
  /**
6660
- * Description of the JOKER command
6968
+ * FORMFACTOR command can be used in:
6661
6969
  */
6662
- description: "Joker parameter is used instead of executing the template result if jokers value meets the expectations requirements",
6970
+ isUsedInPipelineHead: true,
6971
+ isUsedInPipelineTemplate: false,
6972
+ /**
6973
+ * Description of the FORMFACTOR command
6974
+ */
6975
+ description: "@@",
6663
6976
  /**
6664
6977
  * Link to documentation
6665
6978
  */
6666
- documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/66',
6979
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/168',
6667
6980
  /**
6668
- * Example usages of the JOKER command
6981
+ * Example usages of the FORMFACTOR command
6669
6982
  */
6670
- examples: ['JOKER {documentTitle}'],
6983
+ examples: ['FORMFACTOR Chatbot', 'FF Chat'],
6671
6984
  /**
6672
- * Parses the JOKER command
6985
+ * Parses the FORMFACTOR command
6673
6986
  */
6674
6987
  parse: function (input) {
6675
6988
  var args = input.args;
6676
6989
  if (args.length !== 1) {
6677
- throw new ParseError("JOKE command expects exactly one parameter name");
6990
+ throw new ParseError("FORMFACTOR command requires exactly one argument");
6991
+ }
6992
+ var formfactorNameCandidate = args[0].toUpperCase();
6993
+ var formfactor = FORMFACTOR_DEFINITIONS.find(function (definition) {
6994
+ return __spreadArray([definition.name], __read(__assign({ aliasNames: [] }, definition).aliasNames), false).includes(formfactorNameCandidate);
6995
+ });
6996
+ if (formfactor === undefined) {
6997
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown formfactor name \"".concat(formfactorNameCandidate, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
6998
+ var name = _a.name;
6999
+ return "- ".concat(name);
7000
+ }).join('\n')), "\n "); }));
6678
7001
  }
6679
- var parameterNameArg = args[0] || '';
6680
- var parameterName = validateParameterName(parameterNameArg);
6681
7002
  return {
6682
- type: 'JOKER',
6683
- parameterName: parameterName,
7003
+ type: 'FORMFACTOR',
7004
+ formfactorName: formfactor.name,
6684
7005
  };
6685
7006
  },
6686
7007
  /**
6687
- * Apply the JOKER command to the `pipelineJson`
7008
+ * Apply the FORMFACTOR command to the `pipelineJson`
6688
7009
  *
6689
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7010
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7011
+ */
7012
+ $applyToPipelineJson: function (command, $pipelineJson) {
7013
+ $pipelineJson.formfactorName = command.formfactorName;
7014
+ },
7015
+ /**
7016
+ * Converts the FORMFACTOR command back to string
7017
+ *
7018
+ * Note: This is used in `pipelineJsonToString` utility
7019
+ */
7020
+ stringify: function (command) {
7021
+ return "FORMFACTOR ".concat(command.formfactorName);
7022
+ },
7023
+ /**
7024
+ * Reads the FORMFACTOR command from the `PipelineJson`
7025
+ *
7026
+ * Note: This is used in `pipelineJsonToString` utility
7027
+ */
7028
+ takeFromPipelineJson: function (pipelineJson) {
7029
+ return [
7030
+ {
7031
+ type: 'FORMFACTOR',
7032
+ formfactorName: pipelineJson.formfactorName,
7033
+ },
7034
+ ];
7035
+ },
7036
+ };
7037
+
7038
+ /**
7039
+ * Parses the joker command
7040
+ *
7041
+ * @see `documentationUrl` for more details
7042
+ * @private within the commands folder
7043
+ */
7044
+ var jokerCommandParser = {
7045
+ /**
7046
+ * Name of the command
7047
+ */
7048
+ name: 'JOKER',
7049
+ /**
7050
+ * BOILERPLATE command can be used in:
7051
+ */
7052
+ isUsedInPipelineHead: false,
7053
+ isUsedInPipelineTemplate: true,
7054
+ /**
7055
+ * Description of the JOKER command
7056
+ */
7057
+ description: "Joker parameter is used instead of executing the template result if jokers value meets the expectations requirements",
7058
+ /**
7059
+ * Link to documentation
7060
+ */
7061
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/66',
7062
+ /**
7063
+ * Example usages of the JOKER command
7064
+ */
7065
+ examples: ['JOKER {documentTitle}'],
7066
+ /**
7067
+ * Parses the JOKER command
7068
+ */
7069
+ parse: function (input) {
7070
+ var args = input.args;
7071
+ if (args.length !== 1) {
7072
+ throw new ParseError("JOKE command expects exactly one parameter name");
7073
+ }
7074
+ var parameterNameArg = args[0] || '';
7075
+ var parameterName = validateParameterName(parameterNameArg);
7076
+ return {
7077
+ type: 'JOKER',
7078
+ parameterName: parameterName,
7079
+ };
7080
+ },
7081
+ /**
7082
+ * Apply the JOKER command to the `pipelineJson`
7083
+ *
7084
+ * Note: `$` is used to indicate that this function mutates given `templateJson`
6690
7085
  */
6691
7086
  $applyToTemplateJson: function (command, $templateJson) {
6692
7087
  $templateJson.jokerParameterNames = $templateJson.jokerParameterNames || [];
@@ -6906,7 +7301,7 @@
6906
7301
  // <- TODO: When [🥶] fixed, change to:
6907
7302
  // > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
6908
7303
  if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
6909
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Parameter {".concat(parameterNameRaw, "} can not contain another parameter in description\n\n The description:\n ").concat(block(parameterDescriptionRaw), "\n "); }));
7304
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Parameter `{".concat(parameterNameRaw, "}` can not contain another parameter in description\n\n The description:\n ").concat(block(parameterDescriptionRaw), "\n "); }));
6910
7305
  }
6911
7306
  var isInput = normalized.startsWith('INPUT');
6912
7307
  var isOutput = normalized.startsWith('OUTPUT');
@@ -7179,82 +7574,6 @@
7179
7574
  },
7180
7575
  };
7181
7576
 
7182
- /**
7183
- * Parses the BOOK_VERSION command
7184
- *
7185
- * @see `documentationUrl` for more details
7186
- * @private within the commands folder
7187
- */
7188
- var bookVersionCommandParser = {
7189
- /**
7190
- * Name of the command
7191
- */
7192
- name: 'BOOK_VERSION',
7193
- aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
7194
- /**
7195
- * BOILERPLATE command can be used in:
7196
- */
7197
- isUsedInPipelineHead: true,
7198
- isUsedInPipelineTemplate: false,
7199
- /**
7200
- * Description of the BOOK_VERSION command
7201
- */
7202
- description: "Which version of the Book language is the .ptbk.md using",
7203
- /**
7204
- * Link to documentation
7205
- */
7206
- documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
7207
- /**
7208
- * Example usages of the BOOK_VERSION command
7209
- */
7210
- examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
7211
- /**
7212
- * Parses the BOOK_VERSION command
7213
- */
7214
- parse: function (input) {
7215
- var args = input.args;
7216
- var promptbookVersion = args.pop();
7217
- if (promptbookVersion === undefined) {
7218
- throw new ParseError("Version is required");
7219
- }
7220
- if (!isValidPromptbookVersion(promptbookVersion)) {
7221
- throw new ParseError("Invalid Promptbook version \"".concat(promptbookVersion, "\""));
7222
- }
7223
- if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
7224
- throw new ParseError("Can not have more than one Promptbook version");
7225
- }
7226
- return {
7227
- type: 'BOOK_VERSION',
7228
- promptbookVersion: promptbookVersion,
7229
- };
7230
- },
7231
- /**
7232
- * Apply the BOOK_VERSION command to the `pipelineJson`
7233
- *
7234
- * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7235
- */
7236
- $applyToPipelineJson: function (command, $pipelineJson) {
7237
- // TODO: Warn if the version is overridden
7238
- $pipelineJson.promptbookVersion = command.promptbookVersion;
7239
- },
7240
- /**
7241
- * Converts the BOOK_VERSION command back to string
7242
- *
7243
- * Note: This is used in `pipelineJsonToString` utility
7244
- */
7245
- stringify: function (command) {
7246
- return "---"; // <- TODO: [🛋] Implement
7247
- },
7248
- /**
7249
- * Reads the BOOK_VERSION command from the `PipelineJson`
7250
- *
7251
- * Note: This is used in `pipelineJsonToString` utility
7252
- */
7253
- takeFromPipelineJson: function (pipelineJson) {
7254
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7255
- },
7256
- };
7257
-
7258
7577
  /**
7259
7578
  * Parses the url command
7260
7579
  *
@@ -7288,9 +7607,9 @@
7288
7607
  * Example usages of the URL command
7289
7608
  */
7290
7609
  examples: [
7291
- 'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
7292
- 'URL https://promptbook.studio/library/write-cv.ptbk.md',
7293
- 'https://promptbook.studio/library/write-cv.ptbk.md',
7610
+ 'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
7611
+ 'URL https://promptbook.studio/library/write-cv.book.md',
7612
+ 'https://promptbook.studio/library/write-cv.book.md',
7294
7613
  ],
7295
7614
  /**
7296
7615
  * Parses the URL command
@@ -7488,99 +7807,6 @@
7488
7807
  * Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
7489
7808
  */
7490
7809
 
7491
- /**
7492
- * Parses the boilerplate command
7493
- *
7494
- * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.ptbk.md` file
7495
- *
7496
- * @see `documentationUrl` for more details
7497
- * @private within the commands folder
7498
- */
7499
- var boilerplateCommandParser = {
7500
- /**
7501
- * Name of the command
7502
- */
7503
- name: 'BOILERPLATE',
7504
- /**
7505
- * Aliases for the BOILERPLATE command
7506
- */
7507
- aliasNames: ['BP'],
7508
- /**
7509
- * BOILERPLATE command can be used in:
7510
- */
7511
- isUsedInPipelineHead: true,
7512
- isUsedInPipelineTemplate: true,
7513
- /**
7514
- * Description of the BOILERPLATE command
7515
- */
7516
- description: "@@",
7517
- /**
7518
- * Link to documentation
7519
- */
7520
- documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
7521
- /**
7522
- * Example usages of the BOILERPLATE command
7523
- */
7524
- examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
7525
- /**
7526
- * Parses the BOILERPLATE command
7527
- */
7528
- parse: function (input) {
7529
- var args = input.args;
7530
- if (args.length !== 1) {
7531
- throw new ParseError("BOILERPLATE command requires exactly one argument");
7532
- }
7533
- var value = args[0].toLowerCase();
7534
- if (value.includes('brr')) {
7535
- throw new ParseError("BOILERPLATE value can not contain brr");
7536
- }
7537
- return {
7538
- type: 'BOILERPLATE',
7539
- value: value,
7540
- };
7541
- },
7542
- /**
7543
- * Apply the BOILERPLATE command to the `pipelineJson`
7544
- *
7545
- * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7546
- */
7547
- $applyToPipelineJson: function (command, $pipelineJson) {
7548
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7549
- },
7550
- /**
7551
- * Apply the BOILERPLATE command to the `pipelineJson`
7552
- *
7553
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7554
- */
7555
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7556
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7557
- },
7558
- /**
7559
- * Converts the BOILERPLATE command back to string
7560
- *
7561
- * Note: This is used in `pipelineJsonToString` utility
7562
- */
7563
- stringify: function (command) {
7564
- return "---"; // <- TODO: [🛋] Implement
7565
- },
7566
- /**
7567
- * Reads the BOILERPLATE command from the `PipelineJson`
7568
- *
7569
- * Note: This is used in `pipelineJsonToString` utility
7570
- */
7571
- takeFromPipelineJson: function (pipelineJson) {
7572
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7573
- },
7574
- /**
7575
- * Reads the BOILERPLATE command from the `TemplateJson`
7576
- *
7577
- * Note: This is used in `pipelineJsonToString` utility
7578
- */
7579
- takeFromTemplateJson: function ($templateJson) {
7580
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7581
- },
7582
- };
7583
-
7584
7810
  /**
7585
7811
  * All available command parsers
7586
7812
  *
@@ -7595,6 +7821,7 @@
7595
7821
  parameterCommandParser,
7596
7822
  postprocessCommandParser,
7597
7823
  bookVersionCommandParser,
7824
+ formfactorCommandParser,
7598
7825
  urlCommandParser,
7599
7826
  knowledgeCommandParser,
7600
7827
  actionCommandParser,
@@ -7906,7 +8133,7 @@
7906
8133
  return;
7907
8134
  }
7908
8135
  if (!section.startsWith('#')) {
7909
- section = "# Untitled\n\n".concat(section);
8136
+ section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
7910
8137
  }
7911
8138
  sections.push(section);
7912
8139
  buffer = [];
@@ -7970,7 +8197,7 @@
7970
8197
  var e_1, _a;
7971
8198
  var sections = splitMarkdownIntoSections(markdown);
7972
8199
  if (sections.length === 0) {
7973
- return '# Untitled';
8200
+ return "# ".concat(DEFAULT_TITLE);
7974
8201
  }
7975
8202
  var flattenedMarkdown = '';
7976
8203
  var parsedSections = sections.map(parseMarkdownSection);
@@ -7981,7 +8208,7 @@
7981
8208
  }
7982
8209
  else {
7983
8210
  parsedSections.unshift(firstSection);
7984
- flattenedMarkdown += "# Untitled" + "\n\n"; // <- [🧠] Maybe 3 new lines?
8211
+ flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
7985
8212
  }
7986
8213
  try {
7987
8214
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
@@ -8053,8 +8280,8 @@
8053
8280
  * Note: This function does not validate logic of the pipeline only the parsing
8054
8281
  * Note: This function acts as compilation process
8055
8282
  *
8056
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8057
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8283
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8284
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8058
8285
  * @throws {ParseError} if the promptbook string is not valid
8059
8286
  * @public exported from `@promptbook/core`
8060
8287
  */
@@ -8063,8 +8290,9 @@
8063
8290
  var $pipelineJson = {
8064
8291
  title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
8065
8292
  pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
8066
- promptbookVersion: undefined /* <- Note: By default no explicit version */,
8293
+ bookVersion: undefined /* <- Note: By default no explicit version */,
8067
8294
  description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
8295
+ formfactorName: 'GENERIC',
8068
8296
  parameters: [],
8069
8297
  templates: [],
8070
8298
  knowledgeSources: [],
@@ -8119,7 +8347,7 @@
8119
8347
  existingParameter.description &&
8120
8348
  existingParameter.description !== parameterDescription &&
8121
8349
  parameterDescription) {
8122
- throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
8350
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
8123
8351
  }
8124
8352
  if (existingParameter) {
8125
8353
  if (parameterDescription) {
@@ -8446,10 +8674,10 @@
8446
8674
  * Note: This function does not validate logic of the pipeline only the parsing
8447
8675
  * Note: This function acts as compilation process
8448
8676
  *
8449
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8677
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8450
8678
  * @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
8451
8679
  * @param options - Options and tools for the compilation
8452
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8680
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8453
8681
  * @throws {ParseError} if the promptbook string is not valid
8454
8682
  * @public exported from `@promptbook/core`
8455
8683
  */
@@ -8665,7 +8893,7 @@
8665
8893
  return pipelineJsonStringified;
8666
8894
  }
8667
8895
  /**
8668
- * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.ptbk.md
8896
+ * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
8669
8897
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
8670
8898
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
8671
8899
  * TODO: [🍙] Make some standard order of json properties
@@ -8778,6 +9006,21 @@
8778
9006
  * TODO: [🏛] Maybe make some markdown builder
8779
9007
  */
8780
9008
 
9009
+ /**
9010
+ * Boilerplate is form of app that @@@
9011
+ *
9012
+ * @public exported from `@promptbook/core`
9013
+ */
9014
+ var BoilerplateFormfactorDefinition = {
9015
+ name: 'BOILERPLATE',
9016
+ description: "@@@",
9017
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
9018
+ pipelineInterface: {
9019
+ inputParameterNames: [],
9020
+ outputParameterNames: [],
9021
+ },
9022
+ };
9023
+
8781
9024
  /**
8782
9025
  * @@@
8783
9026
  *
@@ -8939,7 +9182,7 @@
8939
9182
  */
8940
9183
 
8941
9184
  /**
8942
- * Stores
9185
+ * Stores data in memory (HEAP)
8943
9186
  *
8944
9187
  * @public exported from `@promptbook/core`
8945
9188
  */
@@ -9069,13 +9312,18 @@
9069
9312
  promptResult = _c.sent();
9070
9313
  return [3 /*break*/, 11];
9071
9314
  case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
9072
- case 11: return [4 /*yield*/, storage.setItem(key, {
9315
+ case 11:
9316
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
9317
+ // promptResult.timing: FromtoItems
9318
+ return [4 /*yield*/, storage.setItem(key, {
9073
9319
  date: $currentDate(),
9074
9320
  promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
9075
9321
  prompt: prompt,
9076
9322
  promptResult: promptResult,
9077
9323
  })];
9078
9324
  case 12:
9325
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
9326
+ // promptResult.timing: FromtoItems
9079
9327
  _c.sent();
9080
9328
  return [2 /*return*/, promptResult];
9081
9329
  }
@@ -9327,6 +9575,83 @@
9327
9575
  },
9328
9576
  });
9329
9577
 
9578
+ /**
9579
+ * @@@
9580
+ *
9581
+ * @public exported from `@promptbook/core`
9582
+ */
9583
+ function getPipelineInterface(pipeline) {
9584
+ var e_1, _a, e_2, _b;
9585
+ var pipelineInterface = {
9586
+ inputParameterNames: [],
9587
+ outputParameterNames: [],
9588
+ };
9589
+ try {
9590
+ for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
9591
+ var parameter = _d.value;
9592
+ var name_1 = parameter.name, isInput = parameter.isInput, isOutput = parameter.isOutput;
9593
+ if (isInput) {
9594
+ pipelineInterface.inputParameterNames.push(name_1);
9595
+ }
9596
+ if (isOutput) {
9597
+ pipelineInterface.outputParameterNames.push(name_1);
9598
+ }
9599
+ }
9600
+ }
9601
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9602
+ finally {
9603
+ try {
9604
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
9605
+ }
9606
+ finally { if (e_1) throw e_1.error; }
9607
+ }
9608
+ try {
9609
+ for (var _e = __values(['inputParameterNames', 'outputParameterNames']), _f = _e.next(); !_f.done; _f = _e.next()) {
9610
+ var key = _f.value;
9611
+ pipelineInterface[key].sort(function (a, b) { return a.localeCompare(b); });
9612
+ }
9613
+ }
9614
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
9615
+ finally {
9616
+ try {
9617
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
9618
+ }
9619
+ finally { if (e_2) throw e_2.error; }
9620
+ }
9621
+ return $deepFreeze(pipelineInterface);
9622
+ }
9623
+ /**
9624
+ * TODO: !!!!!! Write unit test
9625
+ */
9626
+
9627
+ /**
9628
+ * @@@
9629
+ *
9630
+ * @public exported from `@promptbook/core`
9631
+ */
9632
+ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
9633
+ // TODO: [🧠] !!! Implement better
9634
+ return JSON.stringify(pipelineInterface1) === JSON.stringify(pipelineInterface2);
9635
+ }
9636
+ /**
9637
+ * TODO: [🧠] !!! Return more states than true/false - 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
9638
+ * TODO: !!! Write unit test
9639
+ */
9640
+
9641
+ /**
9642
+ * @@@
9643
+ *
9644
+ * @public exported from `@promptbook/core`
9645
+ */
9646
+ function isPipelineImplementingInterface(options) {
9647
+ var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
9648
+ return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
9649
+ }
9650
+ /**
9651
+ * TODO: !!!!!! Test real implementing NOT equality
9652
+ * TODO: !!!!!! Write unit test
9653
+ */
9654
+
9330
9655
  /**
9331
9656
  * Metadata of the scraper
9332
9657
  *
@@ -9451,6 +9776,54 @@
9451
9776
  */
9452
9777
  var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
9453
9778
 
9779
+ /**
9780
+ * Behaves like a storage but forgets everything you put in it
9781
+ *
9782
+ * @public exported from `@promptbook/core`
9783
+ */
9784
+ var BlackholeStorage = /** @class */ (function () {
9785
+ function BlackholeStorage() {
9786
+ }
9787
+ Object.defineProperty(BlackholeStorage.prototype, "length", {
9788
+ /**
9789
+ * Returns the number of key/value pairs currently present in the list associated with the object.
9790
+ */
9791
+ get: function () {
9792
+ return 0;
9793
+ },
9794
+ enumerable: false,
9795
+ configurable: true
9796
+ });
9797
+ /**
9798
+ * Empties the list associated with the object of all key/value pairs, if there are any.
9799
+ */
9800
+ BlackholeStorage.prototype.clear = function () { };
9801
+ /**
9802
+ * 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.
9803
+ * @param key
9804
+ */
9805
+ BlackholeStorage.prototype.getItem = function (key) {
9806
+ return null;
9807
+ };
9808
+ /**
9809
+ * 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.
9810
+ */
9811
+ BlackholeStorage.prototype.key = function (index) {
9812
+ return null;
9813
+ };
9814
+ /**
9815
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
9816
+ */
9817
+ BlackholeStorage.prototype.setItem = function (key, value) {
9818
+ };
9819
+ /**
9820
+ * 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.
9821
+ */
9822
+ BlackholeStorage.prototype.removeItem = function (key) {
9823
+ };
9824
+ return BlackholeStorage;
9825
+ }());
9826
+
9454
9827
  /**
9455
9828
  * This class behaves like LocalStorage but separates keys by prefix
9456
9829
  *
@@ -9807,8 +10180,11 @@
9807
10180
  exports.$scrapersRegister = $scrapersRegister;
9808
10181
  exports.AbstractFormatError = AbstractFormatError;
9809
10182
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
10183
+ exports.BlackholeStorage = BlackholeStorage;
10184
+ exports.BoilerplateFormfactorDefinition = BoilerplateFormfactorDefinition;
9810
10185
  exports.CLAIM = CLAIM;
9811
10186
  exports.CallbackInterfaceTools = CallbackInterfaceTools;
10187
+ exports.ChatFormfactorDefinition = ChatFormfactorDefinition;
9812
10188
  exports.CollectionError = CollectionError;
9813
10189
  exports.CsvFormatDefinition = CsvFormatDefinition;
9814
10190
  exports.CsvFormatError = CsvFormatError;
@@ -9825,11 +10201,15 @@
9825
10201
  exports.DEFAULT_REMOTE_URL = DEFAULT_REMOTE_URL;
9826
10202
  exports.DEFAULT_REMOTE_URL_PATH = DEFAULT_REMOTE_URL_PATH;
9827
10203
  exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
10204
+ exports.DEFAULT_TITLE = DEFAULT_TITLE;
9828
10205
  exports.ERRORS = ERRORS;
9829
10206
  exports.EXPECTATION_UNITS = EXPECTATION_UNITS;
9830
10207
  exports.EnvironmentMismatchError = EnvironmentMismatchError;
9831
10208
  exports.ExecutionReportStringOptionsDefaults = ExecutionReportStringOptionsDefaults;
9832
10209
  exports.ExpectError = ExpectError;
10210
+ exports.FORMFACTOR_DEFINITIONS = FORMFACTOR_DEFINITIONS;
10211
+ exports.GENERIC_PIPELINE_INTERFACE = GENERIC_PIPELINE_INTERFACE;
10212
+ exports.GenericFormfactorDefinition = GenericFormfactorDefinition;
9833
10213
  exports.KnowledgeScrapeError = KnowledgeScrapeError;
9834
10214
  exports.LimitReachedError = LimitReachedError;
9835
10215
  exports.MANDATORY_CSV_SETTINGS = MANDATORY_CSV_SETTINGS;
@@ -9847,8 +10227,10 @@
9847
10227
  exports.PipelineUrlError = PipelineUrlError;
9848
10228
  exports.PrefixStorage = PrefixStorage;
9849
10229
  exports.RESERVED_PARAMETER_NAMES = RESERVED_PARAMETER_NAMES;
10230
+ exports.SheetsFormfactorDefinition = SheetsFormfactorDefinition;
9850
10231
  exports.TemplateTypes = TemplateTypes;
9851
10232
  exports.TextFormatDefinition = TextFormatDefinition;
10233
+ exports.TranslatorFormfactorDefinition = TranslatorFormfactorDefinition;
9852
10234
  exports.UNCERTAIN_USAGE = UNCERTAIN_USAGE;
9853
10235
  exports.UnexpectedError = UnexpectedError;
9854
10236
  exports.ZERO_USAGE = ZERO_USAGE;
@@ -9874,7 +10256,10 @@
9874
10256
  exports.createSubcollection = createSubcollection;
9875
10257
  exports.embeddingVectorToString = embeddingVectorToString;
9876
10258
  exports.executionReportJsonToString = executionReportJsonToString;
10259
+ exports.getPipelineInterface = getPipelineInterface;
9877
10260
  exports.isPassingExpectations = isPassingExpectations;
10261
+ exports.isPipelineImplementingInterface = isPipelineImplementingInterface;
10262
+ exports.isPipelineInterfacesEqual = isPipelineInterfacesEqual;
9878
10263
  exports.isPipelinePrepared = isPipelinePrepared;
9879
10264
  exports.joinLlmExecutionTools = joinLlmExecutionTools;
9880
10265
  exports.limitTotalUsage = limitTotalUsage;