@promptbook/core 0.74.0-8 → 0.75.0-0

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 (53) hide show
  1. package/README.md +2 -11
  2. package/esm/index.es.js +481 -213
  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 +17 -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 +6 -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/_common/AbstractFormfactorDefinition.d.ts +29 -0
  31. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +5 -0
  32. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +5 -0
  33. package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +10 -0
  34. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +10 -0
  35. package/esm/typings/src/formfactors/index.d.ts +14 -0
  36. package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +22 -0
  37. package/esm/typings/src/pipeline/pipeline-interface/getPipelineInterface.d.ts +11 -0
  38. package/esm/typings/src/pipeline/pipeline-interface/isPipelineImplementingInterface.d.ts +25 -0
  39. package/esm/typings/src/pipeline/pipeline-interface/isPipelineInterfacesEqual.d.ts +11 -0
  40. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  41. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
  42. package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
  43. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +11 -4
  44. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  45. package/esm/typings/src/types/Prompt.d.ts +1 -1
  46. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  47. package/esm/typings/src/utils/expectation-counters/config.d.ts +12 -0
  48. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
  49. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
  50. package/package.json +1 -1
  51. package/umd/index.umd.js +488 -212
  52. package/umd/index.umd.js.map +1 -1
  53. /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.74.0-13';
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
@@ -985,7 +994,7 @@ function isValidPipelineUrl(url) {
985
994
  if (!url.startsWith('https://')) {
986
995
  return false;
987
996
  }
988
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
997
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
989
998
  return false;
990
999
  }
991
1000
  if (url.includes('#')) {
@@ -1054,9 +1063,9 @@ function validatePipelineCore(pipeline) {
1054
1063
  // <- Note: [🚲]
1055
1064
  throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1056
1065
  }
1057
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
1066
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
1058
1067
  // <- Note: [🚲]
1059
- throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1068
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1060
1069
  }
1061
1070
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1062
1071
  if (!Array.isArray(pipeline.parameters)) {
@@ -2303,7 +2312,7 @@ function joinLlmExecutionTools() {
2303
2312
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2304
2313
  */
2305
2314
 
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"}];
2315
+ 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
2316
 
2308
2317
  /**
2309
2318
  * This error indicates that the pipeline collection cannot be propperly loaded
@@ -3306,30 +3315,42 @@ function countCharacters(text) {
3306
3315
  return text.length;
3307
3316
  }
3308
3317
 
3318
+ /**
3319
+ * Number of characters per standard line with 11pt Arial font size.
3320
+ *
3321
+ * @public exported from `@promptbook/utils`
3322
+ */
3323
+ var CHARACTERS_PER_STANDARD_LINE = 63;
3324
+ /**
3325
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
3326
+ *
3327
+ * @public exported from `@promptbook/utils`
3328
+ */
3329
+ var LINES_PER_STANDARD_PAGE = 44;
3330
+
3309
3331
  /**
3310
3332
  * Counts number of lines in the text
3311
3333
  *
3334
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
3335
+ *
3312
3336
  * @public exported from `@promptbook/utils`
3313
3337
  */
3314
3338
  function countLines(text) {
3315
- if (text === '') {
3316
- return 0;
3317
- }
3318
- return text.split('\n').length;
3339
+ text = text.replace('\r\n', '\n');
3340
+ text = text.replace('\r', '\n');
3341
+ var lines = text.split('\n');
3342
+ return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
3319
3343
  }
3320
3344
 
3321
3345
  /**
3322
3346
  * Counts number of pages in the text
3323
3347
  *
3348
+ * 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.
3349
+ *
3324
3350
  * @public exported from `@promptbook/utils`
3325
3351
  */
3326
3352
  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);
3353
+ return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
3333
3354
  }
3334
3355
 
3335
3356
  /**
@@ -3892,7 +3913,7 @@ function executeAttempts(options) {
3892
3913
  promptTitle: template.title,
3893
3914
  promptMessage: replaceParameters(template.description || '', parameters),
3894
3915
  defaultValue: replaceParameters(preparedContent, parameters),
3895
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
3916
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
3896
3917
  placeholder: undefined,
3897
3918
  priority: priority,
3898
3919
  }))];
@@ -4458,7 +4479,7 @@ function executePipeline(options) {
4458
4479
  pipelineUrl: preparedPipeline.pipelineUrl,
4459
4480
  title: preparedPipeline.title,
4460
4481
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
4461
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
4482
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
4462
4483
  description: preparedPipeline.description,
4463
4484
  promptExecutions: [],
4464
4485
  };
@@ -4807,7 +4828,7 @@ function preparePersona(personaDescription, tools, options) {
4807
4828
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
4808
4829
  _b = createPipelineExecutor;
4809
4830
  _c = {};
4810
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
4831
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
4811
4832
  case 1:
4812
4833
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
4813
4834
  _c.tools = tools,
@@ -5564,13 +5585,14 @@ TODO: [🧊] This is how it can look in future
5564
5585
  */
5565
5586
  function clonePipeline(pipeline) {
5566
5587
  // 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;
5588
+ 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
5589
  return {
5569
5590
  pipelineUrl: pipelineUrl,
5570
5591
  sourceFile: sourceFile,
5571
5592
  title: title,
5572
- promptbookVersion: promptbookVersion,
5593
+ bookVersion: bookVersion,
5573
5594
  description: description,
5595
+ formfactorName: formfactorName,
5574
5596
  parameters: parameters,
5575
5597
  templates: templates,
5576
5598
  knowledgeSources: knowledgeSources,
@@ -5781,7 +5803,7 @@ var knowledgeCommandParser = {
5781
5803
  throw new ParseError("Source not valid");
5782
5804
  }
5783
5805
  if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
5784
- throw new ParseError("Source cannot be outside of the .ptbk.md folder");
5806
+ throw new ParseError("Source cannot be outside of the .book.md folder");
5785
5807
  }
5786
5808
  return {
5787
5809
  type: 'KNOWLEDGE',
@@ -6001,6 +6023,175 @@ var templateCommandParser = {
6001
6023
  * ```
6002
6024
  */
6003
6025
 
6026
+ /**
6027
+ * Parses the boilerplate command
6028
+ *
6029
+ * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
6030
+ *
6031
+ * @see `documentationUrl` for more details
6032
+ * @private within the commands folder
6033
+ */
6034
+ var boilerplateCommandParser = {
6035
+ /**
6036
+ * Name of the command
6037
+ */
6038
+ name: 'BOILERPLATE',
6039
+ /**
6040
+ * Aliases for the BOILERPLATE command
6041
+ */
6042
+ aliasNames: ['BP'],
6043
+ /**
6044
+ * BOILERPLATE command can be used in:
6045
+ */
6046
+ isUsedInPipelineHead: true,
6047
+ isUsedInPipelineTemplate: true,
6048
+ /**
6049
+ * Description of the BOILERPLATE command
6050
+ */
6051
+ description: "@@",
6052
+ /**
6053
+ * Link to documentation
6054
+ */
6055
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
6056
+ /**
6057
+ * Example usages of the BOILERPLATE command
6058
+ */
6059
+ examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
6060
+ /**
6061
+ * Parses the BOILERPLATE command
6062
+ */
6063
+ parse: function (input) {
6064
+ var args = input.args;
6065
+ if (args.length !== 1) {
6066
+ throw new ParseError("BOILERPLATE command requires exactly one argument");
6067
+ }
6068
+ var value = args[0].toLowerCase();
6069
+ if (value.includes('brr')) {
6070
+ throw new ParseError("BOILERPLATE value can not contain brr");
6071
+ }
6072
+ return {
6073
+ type: 'BOILERPLATE',
6074
+ value: value,
6075
+ };
6076
+ },
6077
+ /**
6078
+ * Apply the BOILERPLATE command to the `pipelineJson`
6079
+ *
6080
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6081
+ */
6082
+ $applyToPipelineJson: function (command, $pipelineJson) {
6083
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6084
+ },
6085
+ /**
6086
+ * Apply the BOILERPLATE command to the `pipelineJson`
6087
+ *
6088
+ * Note: `$` is used to indicate that this function mutates given `templateJson`
6089
+ */
6090
+ $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6091
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6092
+ },
6093
+ /**
6094
+ * Converts the BOILERPLATE command back to string
6095
+ *
6096
+ * Note: This is used in `pipelineJsonToString` utility
6097
+ */
6098
+ stringify: function (command) {
6099
+ return "---"; // <- TODO: [🛋] Implement
6100
+ },
6101
+ /**
6102
+ * Reads the BOILERPLATE command from the `PipelineJson`
6103
+ *
6104
+ * Note: This is used in `pipelineJsonToString` utility
6105
+ */
6106
+ takeFromPipelineJson: function (pipelineJson) {
6107
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6108
+ },
6109
+ /**
6110
+ * Reads the BOILERPLATE command from the `TemplateJson`
6111
+ *
6112
+ * Note: This is used in `pipelineJsonToString` utility
6113
+ */
6114
+ takeFromTemplateJson: function ($templateJson) {
6115
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6116
+ },
6117
+ };
6118
+
6119
+ /**
6120
+ * Parses the BOOK_VERSION command
6121
+ *
6122
+ * @see `documentationUrl` for more details
6123
+ * @private within the commands folder
6124
+ */
6125
+ var bookVersionCommandParser = {
6126
+ /**
6127
+ * Name of the command
6128
+ */
6129
+ name: 'BOOK_VERSION',
6130
+ aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
6131
+ /**
6132
+ * BOILERPLATE command can be used in:
6133
+ */
6134
+ isUsedInPipelineHead: true,
6135
+ isUsedInPipelineTemplate: false,
6136
+ /**
6137
+ * Description of the BOOK_VERSION command
6138
+ */
6139
+ description: "Which version of the Book language is the .book.md using",
6140
+ /**
6141
+ * Link to documentation
6142
+ */
6143
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
6144
+ /**
6145
+ * Example usages of the BOOK_VERSION command
6146
+ */
6147
+ examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
6148
+ /**
6149
+ * Parses the BOOK_VERSION command
6150
+ */
6151
+ parse: function (input) {
6152
+ var args = input.args;
6153
+ var bookVersion = args.pop();
6154
+ if (bookVersion === undefined) {
6155
+ throw new ParseError("Version is required");
6156
+ }
6157
+ if (!isValidPromptbookVersion(bookVersion)) {
6158
+ throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
6159
+ }
6160
+ if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
6161
+ throw new ParseError("Can not have more than one Promptbook version");
6162
+ }
6163
+ return {
6164
+ type: 'BOOK_VERSION',
6165
+ bookVersion: bookVersion,
6166
+ };
6167
+ },
6168
+ /**
6169
+ * Apply the BOOK_VERSION command to the `pipelineJson`
6170
+ *
6171
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6172
+ */
6173
+ $applyToPipelineJson: function (command, $pipelineJson) {
6174
+ // TODO: Warn if the version is overridden
6175
+ $pipelineJson.bookVersion = command.bookVersion;
6176
+ },
6177
+ /**
6178
+ * Converts the BOOK_VERSION command back to string
6179
+ *
6180
+ * Note: This is used in `pipelineJsonToString` utility
6181
+ */
6182
+ stringify: function (command) {
6183
+ return "---"; // <- TODO: [🛋] Implement
6184
+ },
6185
+ /**
6186
+ * Reads the BOOK_VERSION command from the `PipelineJson`
6187
+ *
6188
+ * Note: This is used in `pipelineJsonToString` utility
6189
+ */
6190
+ takeFromPipelineJson: function (pipelineJson) {
6191
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6192
+ },
6193
+ };
6194
+
6004
6195
  /**
6005
6196
  * Units of text measurement
6006
6197
  *
@@ -6413,7 +6604,7 @@ function validateParameterName(parameterName) {
6413
6604
  /**
6414
6605
  * Parses the foreach command
6415
6606
  *
6416
- * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.ptbk.md` file
6607
+ * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
6417
6608
  *
6418
6609
  * @see `documentationUrl` for more details
6419
6610
  * @private within the commands folder
@@ -6563,7 +6754,7 @@ var foreachCommandParser = {
6563
6754
  },
6564
6755
  };
6565
6756
  /**
6566
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH with wrong parsing and logic
6757
+ * TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
6567
6758
  */
6568
6759
 
6569
6760
  /**
@@ -6638,6 +6829,120 @@ var formatCommandParser = {
6638
6829
  },
6639
6830
  };
6640
6831
 
6832
+ /**
6833
+ * @@@
6834
+ *
6835
+ * @public exported from `@promptbook/core`
6836
+ */
6837
+ var ChatFormfactorDefinition = {
6838
+ name: 'CHAT',
6839
+ description: "@@@",
6840
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6841
+ };
6842
+
6843
+ /**
6844
+ * @@@
6845
+ *
6846
+ * @public exported from `@promptbook/core`
6847
+ */
6848
+ var GenericFormfactorDefinition = {
6849
+ name: 'GENERIC',
6850
+ description: "@@@",
6851
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6852
+ };
6853
+
6854
+ /**
6855
+ * All available formfactor definitions
6856
+ *
6857
+ * @public exported from `@promptbook/core`
6858
+ */
6859
+ var FORMFACTOR_DEFINITIONS = [GenericFormfactorDefinition, ChatFormfactorDefinition];
6860
+
6861
+ /**
6862
+ * Parses the formfactor command
6863
+ *
6864
+ * Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
6865
+ *
6866
+ * @see `documentationUrl` for more details
6867
+ * @private within the commands folder
6868
+ */
6869
+ var formfactorCommandParser = {
6870
+ /**
6871
+ * Name of the command
6872
+ */
6873
+ name: 'FORMFACTOR',
6874
+ /**
6875
+ * Aliases for the FORMFACTOR command
6876
+ */
6877
+ aliasNames: ['FORM', 'FF'],
6878
+ /**
6879
+ * FORMFACTOR command can be used in:
6880
+ */
6881
+ isUsedInPipelineHead: true,
6882
+ isUsedInPipelineTemplate: false,
6883
+ /**
6884
+ * Description of the FORMFACTOR command
6885
+ */
6886
+ description: "@@",
6887
+ /**
6888
+ * Link to documentation
6889
+ */
6890
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/168',
6891
+ /**
6892
+ * Example usages of the FORMFACTOR command
6893
+ */
6894
+ examples: ['FORMFACTOR Chat', 'FORMFACTOR Generic'],
6895
+ /**
6896
+ * Parses the FORMFACTOR command
6897
+ */
6898
+ parse: function (input) {
6899
+ var args = input.args;
6900
+ if (args.length !== 1) {
6901
+ throw new ParseError("FORMFACTOR command requires exactly one argument");
6902
+ }
6903
+ var formfactorName = args[0].toUpperCase();
6904
+ if (!FORMFACTOR_DEFINITIONS.some(function (definition) { return definition.name === formfactorName; })) {
6905
+ throw new ParseError(spaceTrim(function (block) { return "\n Unknown formfactor name \"".concat(formfactorName, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
6906
+ var name = _a.name;
6907
+ return "- ".concat(name);
6908
+ }).join('\n')), "\n "); }));
6909
+ }
6910
+ return {
6911
+ type: 'FORMFACTOR',
6912
+ formfactorName: formfactorName,
6913
+ };
6914
+ },
6915
+ /**
6916
+ * Apply the FORMFACTOR command to the `pipelineJson`
6917
+ *
6918
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6919
+ */
6920
+ $applyToPipelineJson: function (command, $pipelineJson) {
6921
+ $pipelineJson.formfactorName = command.formfactorName;
6922
+ },
6923
+ /**
6924
+ * Converts the FORMFACTOR command back to string
6925
+ *
6926
+ * Note: This is used in `pipelineJsonToString` utility
6927
+ */
6928
+ stringify: function (command) {
6929
+ return "FORMFACTOR ".concat(command.formfactorName);
6930
+ },
6931
+ /**
6932
+ * Reads the FORMFACTOR command from the `PipelineJson`
6933
+ *
6934
+ * Note: This is used in `pipelineJsonToString` utility
6935
+ */
6936
+ takeFromPipelineJson: function (pipelineJson) {
6937
+ return [
6938
+ {
6939
+ type: 'FORMFACTOR',
6940
+ formfactorName: pipelineJson.formfactorName,
6941
+ },
6942
+ ];
6943
+ },
6944
+ };
6945
+
6641
6946
  /**
6642
6947
  * Parses the joker command
6643
6948
  *
@@ -7177,82 +7482,6 @@ var postprocessCommandParser = {
7177
7482
  },
7178
7483
  };
7179
7484
 
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
7485
  /**
7257
7486
  * Parses the url command
7258
7487
  *
@@ -7286,9 +7515,9 @@ var urlCommandParser = {
7286
7515
  * Example usages of the URL command
7287
7516
  */
7288
7517
  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',
7518
+ 'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
7519
+ 'URL https://promptbook.studio/library/write-cv.book.md',
7520
+ 'https://promptbook.studio/library/write-cv.book.md',
7292
7521
  ],
7293
7522
  /**
7294
7523
  * Parses the URL command
@@ -7486,99 +7715,6 @@ var instrumentCommandParser = {
7486
7715
  * Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
7487
7716
  */
7488
7717
 
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
7718
  /**
7583
7719
  * All available command parsers
7584
7720
  *
@@ -7593,6 +7729,7 @@ var COMMANDS = [
7593
7729
  parameterCommandParser,
7594
7730
  postprocessCommandParser,
7595
7731
  bookVersionCommandParser,
7732
+ formfactorCommandParser,
7596
7733
  urlCommandParser,
7597
7734
  knowledgeCommandParser,
7598
7735
  actionCommandParser,
@@ -7904,7 +8041,7 @@ function splitMarkdownIntoSections(markdown) {
7904
8041
  return;
7905
8042
  }
7906
8043
  if (!section.startsWith('#')) {
7907
- section = "# Untitled\n\n".concat(section);
8044
+ section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
7908
8045
  }
7909
8046
  sections.push(section);
7910
8047
  buffer = [];
@@ -7968,7 +8105,7 @@ function flattenMarkdown(markdown) {
7968
8105
  var e_1, _a;
7969
8106
  var sections = splitMarkdownIntoSections(markdown);
7970
8107
  if (sections.length === 0) {
7971
- return '# Untitled';
8108
+ return "# ".concat(DEFAULT_TITLE);
7972
8109
  }
7973
8110
  var flattenedMarkdown = '';
7974
8111
  var parsedSections = sections.map(parseMarkdownSection);
@@ -7979,7 +8116,7 @@ function flattenMarkdown(markdown) {
7979
8116
  }
7980
8117
  else {
7981
8118
  parsedSections.unshift(firstSection);
7982
- flattenedMarkdown += "# Untitled" + "\n\n"; // <- [🧠] Maybe 3 new lines?
8119
+ flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
7983
8120
  }
7984
8121
  try {
7985
8122
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
@@ -8051,8 +8188,8 @@ function titleToName(value) {
8051
8188
  * Note: This function does not validate logic of the pipeline only the parsing
8052
8189
  * Note: This function acts as compilation process
8053
8190
  *
8054
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8055
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8191
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8192
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8056
8193
  * @throws {ParseError} if the promptbook string is not valid
8057
8194
  * @public exported from `@promptbook/core`
8058
8195
  */
@@ -8061,8 +8198,9 @@ function pipelineStringToJsonSync(pipelineString) {
8061
8198
  var $pipelineJson = {
8062
8199
  title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
8063
8200
  pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
8064
- promptbookVersion: undefined /* <- Note: By default no explicit version */,
8201
+ bookVersion: undefined /* <- Note: By default no explicit version */,
8065
8202
  description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
8203
+ formfactorName: 'GENERIC',
8066
8204
  parameters: [],
8067
8205
  templates: [],
8068
8206
  knowledgeSources: [],
@@ -8444,10 +8582,10 @@ function pipelineStringToJsonSync(pipelineString) {
8444
8582
  * Note: This function does not validate logic of the pipeline only the parsing
8445
8583
  * Note: This function acts as compilation process
8446
8584
  *
8447
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8585
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8448
8586
  * @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
8449
8587
  * @param options - Options and tools for the compilation
8450
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8588
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8451
8589
  * @throws {ParseError} if the promptbook string is not valid
8452
8590
  * @public exported from `@promptbook/core`
8453
8591
  */
@@ -8663,7 +8801,7 @@ function stringifyPipelineJson(pipeline) {
8663
8801
  return pipelineJsonStringified;
8664
8802
  }
8665
8803
  /**
8666
- * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.ptbk.md
8804
+ * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
8667
8805
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
8668
8806
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
8669
8807
  * TODO: [🍙] Make some standard order of json properties
@@ -8937,7 +9075,7 @@ function createLlmToolsFromConfiguration(configuration, options) {
8937
9075
  */
8938
9076
 
8939
9077
  /**
8940
- * Stores
9078
+ * Stores data in memory (HEAP)
8941
9079
  *
8942
9080
  * @public exported from `@promptbook/core`
8943
9081
  */
@@ -9067,13 +9205,18 @@ function cacheLlmTools(llmTools, options) {
9067
9205
  promptResult = _c.sent();
9068
9206
  return [3 /*break*/, 11];
9069
9207
  case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
9070
- case 11: return [4 /*yield*/, storage.setItem(key, {
9208
+ case 11:
9209
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
9210
+ // promptResult.timing: FromtoItems
9211
+ return [4 /*yield*/, storage.setItem(key, {
9071
9212
  date: $currentDate(),
9072
9213
  promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
9073
9214
  prompt: prompt,
9074
9215
  promptResult: promptResult,
9075
9216
  })];
9076
9217
  case 12:
9218
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
9219
+ // promptResult.timing: FromtoItems
9077
9220
  _c.sent();
9078
9221
  return [2 /*return*/, promptResult];
9079
9222
  }
@@ -9325,6 +9468,83 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
9325
9468
  },
9326
9469
  });
9327
9470
 
9471
+ /**
9472
+ * @@@
9473
+ *
9474
+ * @public exported from `@promptbook/core`
9475
+ */
9476
+ function getPipelineInterface(pipeline) {
9477
+ var e_1, _a, e_2, _b;
9478
+ var pipelineInterface = {
9479
+ inputParameterNames: [],
9480
+ outputParameterNames: [],
9481
+ };
9482
+ try {
9483
+ for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
9484
+ var parameter = _d.value;
9485
+ var name_1 = parameter.name, isInput = parameter.isInput, isOutput = parameter.isOutput;
9486
+ if (isInput) {
9487
+ pipelineInterface.inputParameterNames.push(name_1);
9488
+ }
9489
+ if (isOutput) {
9490
+ pipelineInterface.outputParameterNames.push(name_1);
9491
+ }
9492
+ }
9493
+ }
9494
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9495
+ finally {
9496
+ try {
9497
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
9498
+ }
9499
+ finally { if (e_1) throw e_1.error; }
9500
+ }
9501
+ try {
9502
+ for (var _e = __values(['inputParameterNames', 'outputParameterNames']), _f = _e.next(); !_f.done; _f = _e.next()) {
9503
+ var key = _f.value;
9504
+ pipelineInterface[key].sort(function (a, b) { return a.localeCompare(b); });
9505
+ }
9506
+ }
9507
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
9508
+ finally {
9509
+ try {
9510
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
9511
+ }
9512
+ finally { if (e_2) throw e_2.error; }
9513
+ }
9514
+ return Object.freeze(pipelineInterface);
9515
+ }
9516
+ /**
9517
+ * TODO: !!!!!! Write unit test
9518
+ */
9519
+
9520
+ /**
9521
+ * @@@
9522
+ *
9523
+ * @public exported from `@promptbook/core`
9524
+ */
9525
+ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
9526
+ // TODO: [🧠] !!! Implement better
9527
+ return JSON.stringify(pipelineInterface1) === JSON.stringify(pipelineInterface2);
9528
+ }
9529
+ /**
9530
+ * TODO: [🧠] !!! Return more states than true/false - 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
9531
+ * TODO: !!! Write unit test
9532
+ */
9533
+
9534
+ /**
9535
+ * @@@
9536
+ *
9537
+ * @public exported from `@promptbook/core`
9538
+ */
9539
+ function isPipelineImplementingInterface(options) {
9540
+ var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
9541
+ return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
9542
+ }
9543
+ /**
9544
+ * TODO: !!!!!! Test real implementing NOT equality
9545
+ * TODO: !!!!!! Write unit test
9546
+ */
9547
+
9328
9548
  /**
9329
9549
  * Metadata of the scraper
9330
9550
  *
@@ -9449,6 +9669,54 @@ var websiteScraperMetadata = $deepFreeze({
9449
9669
  */
9450
9670
  var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
9451
9671
 
9672
+ /**
9673
+ * Behaves like a storage but forgets everything you put in it
9674
+ *
9675
+ * @public exported from `@promptbook/core`
9676
+ */
9677
+ var BlackholeStorage = /** @class */ (function () {
9678
+ function BlackholeStorage() {
9679
+ }
9680
+ Object.defineProperty(BlackholeStorage.prototype, "length", {
9681
+ /**
9682
+ * Returns the number of key/value pairs currently present in the list associated with the object.
9683
+ */
9684
+ get: function () {
9685
+ return 0;
9686
+ },
9687
+ enumerable: false,
9688
+ configurable: true
9689
+ });
9690
+ /**
9691
+ * Empties the list associated with the object of all key/value pairs, if there are any.
9692
+ */
9693
+ BlackholeStorage.prototype.clear = function () { };
9694
+ /**
9695
+ * 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.
9696
+ * @param key
9697
+ */
9698
+ BlackholeStorage.prototype.getItem = function (key) {
9699
+ return null;
9700
+ };
9701
+ /**
9702
+ * 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.
9703
+ */
9704
+ BlackholeStorage.prototype.key = function (index) {
9705
+ return null;
9706
+ };
9707
+ /**
9708
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
9709
+ */
9710
+ BlackholeStorage.prototype.setItem = function (key, value) {
9711
+ };
9712
+ /**
9713
+ * 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.
9714
+ */
9715
+ BlackholeStorage.prototype.removeItem = function (key) {
9716
+ };
9717
+ return BlackholeStorage;
9718
+ }());
9719
+
9452
9720
  /**
9453
9721
  * This class behaves like LocalStorage but separates keys by prefix
9454
9722
  *
@@ -9799,5 +10067,5 @@ function executionReportJsonToString(executionReportJson, options) {
9799
10067
  * TODO: [🧠] Should be in generated file GENERATOR_WARNING
9800
10068
  */
9801
10069
 
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 };
10070
+ export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, 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, 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, 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, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
9803
10071
  //# sourceMappingURL=index.es.js.map