@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/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.74.0-13';
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
@@ -987,7 +996,7 @@
987
996
  if (!url.startsWith('https://')) {
988
997
  return false;
989
998
  }
990
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
999
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
991
1000
  return false;
992
1001
  }
993
1002
  if (url.includes('#')) {
@@ -1056,9 +1065,9 @@
1056
1065
  // <- Note: [🚲]
1057
1066
  throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1058
1067
  }
1059
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
1068
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
1060
1069
  // <- Note: [🚲]
1061
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1070
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1062
1071
  }
1063
1072
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1064
1073
  if (!Array.isArray(pipeline.parameters)) {
@@ -2305,7 +2314,7 @@
2305
2314
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2306
2315
  */
2307
2316
 
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"}];
2317
+ 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
2318
 
2310
2319
  /**
2311
2320
  * This error indicates that the pipeline collection cannot be propperly loaded
@@ -3308,30 +3317,42 @@
3308
3317
  return text.length;
3309
3318
  }
3310
3319
 
3320
+ /**
3321
+ * Number of characters per standard line with 11pt Arial font size.
3322
+ *
3323
+ * @public exported from `@promptbook/utils`
3324
+ */
3325
+ var CHARACTERS_PER_STANDARD_LINE = 63;
3326
+ /**
3327
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
3328
+ *
3329
+ * @public exported from `@promptbook/utils`
3330
+ */
3331
+ var LINES_PER_STANDARD_PAGE = 44;
3332
+
3311
3333
  /**
3312
3334
  * Counts number of lines in the text
3313
3335
  *
3336
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
3337
+ *
3314
3338
  * @public exported from `@promptbook/utils`
3315
3339
  */
3316
3340
  function countLines(text) {
3317
- if (text === '') {
3318
- return 0;
3319
- }
3320
- return text.split('\n').length;
3341
+ text = text.replace('\r\n', '\n');
3342
+ text = text.replace('\r', '\n');
3343
+ var lines = text.split('\n');
3344
+ return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
3321
3345
  }
3322
3346
 
3323
3347
  /**
3324
3348
  * Counts number of pages in the text
3325
3349
  *
3350
+ * 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.
3351
+ *
3326
3352
  * @public exported from `@promptbook/utils`
3327
3353
  */
3328
3354
  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);
3355
+ return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
3335
3356
  }
3336
3357
 
3337
3358
  /**
@@ -3894,7 +3915,7 @@
3894
3915
  promptTitle: template.title,
3895
3916
  promptMessage: replaceParameters(template.description || '', parameters),
3896
3917
  defaultValue: replaceParameters(preparedContent, parameters),
3897
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
3918
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
3898
3919
  placeholder: undefined,
3899
3920
  priority: priority,
3900
3921
  }))];
@@ -4460,7 +4481,7 @@
4460
4481
  pipelineUrl: preparedPipeline.pipelineUrl,
4461
4482
  title: preparedPipeline.title,
4462
4483
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
4463
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
4484
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
4464
4485
  description: preparedPipeline.description,
4465
4486
  promptExecutions: [],
4466
4487
  };
@@ -4809,7 +4830,7 @@
4809
4830
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
4810
4831
  _b = createPipelineExecutor;
4811
4832
  _c = {};
4812
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
4833
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
4813
4834
  case 1:
4814
4835
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
4815
4836
  _c.tools = tools,
@@ -5566,13 +5587,14 @@
5566
5587
  */
5567
5588
  function clonePipeline(pipeline) {
5568
5589
  // 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;
5590
+ 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
5591
  return {
5571
5592
  pipelineUrl: pipelineUrl,
5572
5593
  sourceFile: sourceFile,
5573
5594
  title: title,
5574
- promptbookVersion: promptbookVersion,
5595
+ bookVersion: bookVersion,
5575
5596
  description: description,
5597
+ formfactorName: formfactorName,
5576
5598
  parameters: parameters,
5577
5599
  templates: templates,
5578
5600
  knowledgeSources: knowledgeSources,
@@ -5783,7 +5805,7 @@
5783
5805
  throw new ParseError("Source not valid");
5784
5806
  }
5785
5807
  if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
5786
- throw new ParseError("Source cannot be outside of the .ptbk.md folder");
5808
+ throw new ParseError("Source cannot be outside of the .book.md folder");
5787
5809
  }
5788
5810
  return {
5789
5811
  type: 'KNOWLEDGE',
@@ -6003,6 +6025,175 @@
6003
6025
  * ```
6004
6026
  */
6005
6027
 
6028
+ /**
6029
+ * Parses the boilerplate command
6030
+ *
6031
+ * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
6032
+ *
6033
+ * @see `documentationUrl` for more details
6034
+ * @private within the commands folder
6035
+ */
6036
+ var boilerplateCommandParser = {
6037
+ /**
6038
+ * Name of the command
6039
+ */
6040
+ name: 'BOILERPLATE',
6041
+ /**
6042
+ * Aliases for the BOILERPLATE command
6043
+ */
6044
+ aliasNames: ['BP'],
6045
+ /**
6046
+ * BOILERPLATE command can be used in:
6047
+ */
6048
+ isUsedInPipelineHead: true,
6049
+ isUsedInPipelineTemplate: true,
6050
+ /**
6051
+ * Description of the BOILERPLATE command
6052
+ */
6053
+ description: "@@",
6054
+ /**
6055
+ * Link to documentation
6056
+ */
6057
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
6058
+ /**
6059
+ * Example usages of the BOILERPLATE command
6060
+ */
6061
+ examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
6062
+ /**
6063
+ * Parses the BOILERPLATE command
6064
+ */
6065
+ parse: function (input) {
6066
+ var args = input.args;
6067
+ if (args.length !== 1) {
6068
+ throw new ParseError("BOILERPLATE command requires exactly one argument");
6069
+ }
6070
+ var value = args[0].toLowerCase();
6071
+ if (value.includes('brr')) {
6072
+ throw new ParseError("BOILERPLATE value can not contain brr");
6073
+ }
6074
+ return {
6075
+ type: 'BOILERPLATE',
6076
+ value: value,
6077
+ };
6078
+ },
6079
+ /**
6080
+ * Apply the BOILERPLATE command to the `pipelineJson`
6081
+ *
6082
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6083
+ */
6084
+ $applyToPipelineJson: function (command, $pipelineJson) {
6085
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6086
+ },
6087
+ /**
6088
+ * Apply the BOILERPLATE command to the `pipelineJson`
6089
+ *
6090
+ * Note: `$` is used to indicate that this function mutates given `templateJson`
6091
+ */
6092
+ $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6093
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6094
+ },
6095
+ /**
6096
+ * Converts the BOILERPLATE command back to string
6097
+ *
6098
+ * Note: This is used in `pipelineJsonToString` utility
6099
+ */
6100
+ stringify: function (command) {
6101
+ return "---"; // <- TODO: [🛋] Implement
6102
+ },
6103
+ /**
6104
+ * Reads the BOILERPLATE command from the `PipelineJson`
6105
+ *
6106
+ * Note: This is used in `pipelineJsonToString` utility
6107
+ */
6108
+ takeFromPipelineJson: function (pipelineJson) {
6109
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6110
+ },
6111
+ /**
6112
+ * Reads the BOILERPLATE command from the `TemplateJson`
6113
+ *
6114
+ * Note: This is used in `pipelineJsonToString` utility
6115
+ */
6116
+ takeFromTemplateJson: function ($templateJson) {
6117
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6118
+ },
6119
+ };
6120
+
6121
+ /**
6122
+ * Parses the BOOK_VERSION command
6123
+ *
6124
+ * @see `documentationUrl` for more details
6125
+ * @private within the commands folder
6126
+ */
6127
+ var bookVersionCommandParser = {
6128
+ /**
6129
+ * Name of the command
6130
+ */
6131
+ name: 'BOOK_VERSION',
6132
+ aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
6133
+ /**
6134
+ * BOILERPLATE command can be used in:
6135
+ */
6136
+ isUsedInPipelineHead: true,
6137
+ isUsedInPipelineTemplate: false,
6138
+ /**
6139
+ * Description of the BOOK_VERSION command
6140
+ */
6141
+ description: "Which version of the Book language is the .book.md using",
6142
+ /**
6143
+ * Link to documentation
6144
+ */
6145
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
6146
+ /**
6147
+ * Example usages of the BOOK_VERSION command
6148
+ */
6149
+ examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
6150
+ /**
6151
+ * Parses the BOOK_VERSION command
6152
+ */
6153
+ parse: function (input) {
6154
+ var args = input.args;
6155
+ var bookVersion = args.pop();
6156
+ if (bookVersion === undefined) {
6157
+ throw new ParseError("Version is required");
6158
+ }
6159
+ if (!isValidPromptbookVersion(bookVersion)) {
6160
+ throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
6161
+ }
6162
+ if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
6163
+ throw new ParseError("Can not have more than one Promptbook version");
6164
+ }
6165
+ return {
6166
+ type: 'BOOK_VERSION',
6167
+ bookVersion: bookVersion,
6168
+ };
6169
+ },
6170
+ /**
6171
+ * Apply the BOOK_VERSION command to the `pipelineJson`
6172
+ *
6173
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6174
+ */
6175
+ $applyToPipelineJson: function (command, $pipelineJson) {
6176
+ // TODO: Warn if the version is overridden
6177
+ $pipelineJson.bookVersion = command.bookVersion;
6178
+ },
6179
+ /**
6180
+ * Converts the BOOK_VERSION command back to string
6181
+ *
6182
+ * Note: This is used in `pipelineJsonToString` utility
6183
+ */
6184
+ stringify: function (command) {
6185
+ return "---"; // <- TODO: [🛋] Implement
6186
+ },
6187
+ /**
6188
+ * Reads the BOOK_VERSION command from the `PipelineJson`
6189
+ *
6190
+ * Note: This is used in `pipelineJsonToString` utility
6191
+ */
6192
+ takeFromPipelineJson: function (pipelineJson) {
6193
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6194
+ },
6195
+ };
6196
+
6006
6197
  /**
6007
6198
  * Units of text measurement
6008
6199
  *
@@ -6415,7 +6606,7 @@
6415
6606
  /**
6416
6607
  * Parses the foreach command
6417
6608
  *
6418
- * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.ptbk.md` file
6609
+ * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
6419
6610
  *
6420
6611
  * @see `documentationUrl` for more details
6421
6612
  * @private within the commands folder
@@ -6565,7 +6756,7 @@
6565
6756
  },
6566
6757
  };
6567
6758
  /**
6568
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH with wrong parsing and logic
6759
+ * TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
6569
6760
  */
6570
6761
 
6571
6762
  /**
@@ -6640,6 +6831,120 @@
6640
6831
  },
6641
6832
  };
6642
6833
 
6834
+ /**
6835
+ * @@@
6836
+ *
6837
+ * @public exported from `@promptbook/core`
6838
+ */
6839
+ var ChatFormfactorDefinition = {
6840
+ name: 'CHAT',
6841
+ description: "@@@",
6842
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6843
+ };
6844
+
6845
+ /**
6846
+ * @@@
6847
+ *
6848
+ * @public exported from `@promptbook/core`
6849
+ */
6850
+ var GenericFormfactorDefinition = {
6851
+ name: 'GENERIC',
6852
+ description: "@@@",
6853
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6854
+ };
6855
+
6856
+ /**
6857
+ * All available formfactor definitions
6858
+ *
6859
+ * @public exported from `@promptbook/core`
6860
+ */
6861
+ var FORMFACTOR_DEFINITIONS = [GenericFormfactorDefinition, ChatFormfactorDefinition];
6862
+
6863
+ /**
6864
+ * Parses the formfactor command
6865
+ *
6866
+ * Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
6867
+ *
6868
+ * @see `documentationUrl` for more details
6869
+ * @private within the commands folder
6870
+ */
6871
+ var formfactorCommandParser = {
6872
+ /**
6873
+ * Name of the command
6874
+ */
6875
+ name: 'FORMFACTOR',
6876
+ /**
6877
+ * Aliases for the FORMFACTOR command
6878
+ */
6879
+ aliasNames: ['FORM', 'FF'],
6880
+ /**
6881
+ * FORMFACTOR command can be used in:
6882
+ */
6883
+ isUsedInPipelineHead: true,
6884
+ isUsedInPipelineTemplate: false,
6885
+ /**
6886
+ * Description of the FORMFACTOR command
6887
+ */
6888
+ description: "@@",
6889
+ /**
6890
+ * Link to documentation
6891
+ */
6892
+ documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/168',
6893
+ /**
6894
+ * Example usages of the FORMFACTOR command
6895
+ */
6896
+ examples: ['FORMFACTOR Chat', 'FORMFACTOR Generic'],
6897
+ /**
6898
+ * Parses the FORMFACTOR command
6899
+ */
6900
+ parse: function (input) {
6901
+ var args = input.args;
6902
+ if (args.length !== 1) {
6903
+ throw new ParseError("FORMFACTOR command requires exactly one argument");
6904
+ }
6905
+ var formfactorName = args[0].toUpperCase();
6906
+ if (!FORMFACTOR_DEFINITIONS.some(function (definition) { return definition.name === formfactorName; })) {
6907
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown formfactor name \"".concat(formfactorName, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
6908
+ var name = _a.name;
6909
+ return "- ".concat(name);
6910
+ }).join('\n')), "\n "); }));
6911
+ }
6912
+ return {
6913
+ type: 'FORMFACTOR',
6914
+ formfactorName: formfactorName,
6915
+ };
6916
+ },
6917
+ /**
6918
+ * Apply the FORMFACTOR command to the `pipelineJson`
6919
+ *
6920
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6921
+ */
6922
+ $applyToPipelineJson: function (command, $pipelineJson) {
6923
+ $pipelineJson.formfactorName = command.formfactorName;
6924
+ },
6925
+ /**
6926
+ * Converts the FORMFACTOR command back to string
6927
+ *
6928
+ * Note: This is used in `pipelineJsonToString` utility
6929
+ */
6930
+ stringify: function (command) {
6931
+ return "FORMFACTOR ".concat(command.formfactorName);
6932
+ },
6933
+ /**
6934
+ * Reads the FORMFACTOR command from the `PipelineJson`
6935
+ *
6936
+ * Note: This is used in `pipelineJsonToString` utility
6937
+ */
6938
+ takeFromPipelineJson: function (pipelineJson) {
6939
+ return [
6940
+ {
6941
+ type: 'FORMFACTOR',
6942
+ formfactorName: pipelineJson.formfactorName,
6943
+ },
6944
+ ];
6945
+ },
6946
+ };
6947
+
6643
6948
  /**
6644
6949
  * Parses the joker command
6645
6950
  *
@@ -7179,82 +7484,6 @@
7179
7484
  },
7180
7485
  };
7181
7486
 
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
7487
  /**
7259
7488
  * Parses the url command
7260
7489
  *
@@ -7288,9 +7517,9 @@
7288
7517
  * Example usages of the URL command
7289
7518
  */
7290
7519
  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',
7520
+ 'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
7521
+ 'URL https://promptbook.studio/library/write-cv.book.md',
7522
+ 'https://promptbook.studio/library/write-cv.book.md',
7294
7523
  ],
7295
7524
  /**
7296
7525
  * Parses the URL command
@@ -7488,99 +7717,6 @@
7488
7717
  * Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
7489
7718
  */
7490
7719
 
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
7720
  /**
7585
7721
  * All available command parsers
7586
7722
  *
@@ -7595,6 +7731,7 @@
7595
7731
  parameterCommandParser,
7596
7732
  postprocessCommandParser,
7597
7733
  bookVersionCommandParser,
7734
+ formfactorCommandParser,
7598
7735
  urlCommandParser,
7599
7736
  knowledgeCommandParser,
7600
7737
  actionCommandParser,
@@ -7906,7 +8043,7 @@
7906
8043
  return;
7907
8044
  }
7908
8045
  if (!section.startsWith('#')) {
7909
- section = "# Untitled\n\n".concat(section);
8046
+ section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
7910
8047
  }
7911
8048
  sections.push(section);
7912
8049
  buffer = [];
@@ -7970,7 +8107,7 @@
7970
8107
  var e_1, _a;
7971
8108
  var sections = splitMarkdownIntoSections(markdown);
7972
8109
  if (sections.length === 0) {
7973
- return '# Untitled';
8110
+ return "# ".concat(DEFAULT_TITLE);
7974
8111
  }
7975
8112
  var flattenedMarkdown = '';
7976
8113
  var parsedSections = sections.map(parseMarkdownSection);
@@ -7981,7 +8118,7 @@
7981
8118
  }
7982
8119
  else {
7983
8120
  parsedSections.unshift(firstSection);
7984
- flattenedMarkdown += "# Untitled" + "\n\n"; // <- [🧠] Maybe 3 new lines?
8121
+ flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
7985
8122
  }
7986
8123
  try {
7987
8124
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
@@ -8053,8 +8190,8 @@
8053
8190
  * Note: This function does not validate logic of the pipeline only the parsing
8054
8191
  * Note: This function acts as compilation process
8055
8192
  *
8056
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8057
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8193
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8194
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8058
8195
  * @throws {ParseError} if the promptbook string is not valid
8059
8196
  * @public exported from `@promptbook/core`
8060
8197
  */
@@ -8063,8 +8200,9 @@
8063
8200
  var $pipelineJson = {
8064
8201
  title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
8065
8202
  pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
8066
- promptbookVersion: undefined /* <- Note: By default no explicit version */,
8203
+ bookVersion: undefined /* <- Note: By default no explicit version */,
8067
8204
  description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
8205
+ formfactorName: 'GENERIC',
8068
8206
  parameters: [],
8069
8207
  templates: [],
8070
8208
  knowledgeSources: [],
@@ -8446,10 +8584,10 @@
8446
8584
  * Note: This function does not validate logic of the pipeline only the parsing
8447
8585
  * Note: This function acts as compilation process
8448
8586
  *
8449
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8587
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8450
8588
  * @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
8451
8589
  * @param options - Options and tools for the compilation
8452
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8590
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8453
8591
  * @throws {ParseError} if the promptbook string is not valid
8454
8592
  * @public exported from `@promptbook/core`
8455
8593
  */
@@ -8665,7 +8803,7 @@
8665
8803
  return pipelineJsonStringified;
8666
8804
  }
8667
8805
  /**
8668
- * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.ptbk.md
8806
+ * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
8669
8807
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
8670
8808
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
8671
8809
  * TODO: [🍙] Make some standard order of json properties
@@ -8939,7 +9077,7 @@
8939
9077
  */
8940
9078
 
8941
9079
  /**
8942
- * Stores
9080
+ * Stores data in memory (HEAP)
8943
9081
  *
8944
9082
  * @public exported from `@promptbook/core`
8945
9083
  */
@@ -9069,13 +9207,18 @@
9069
9207
  promptResult = _c.sent();
9070
9208
  return [3 /*break*/, 11];
9071
9209
  case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
9072
- case 11: return [4 /*yield*/, storage.setItem(key, {
9210
+ case 11:
9211
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
9212
+ // promptResult.timing: FromtoItems
9213
+ return [4 /*yield*/, storage.setItem(key, {
9073
9214
  date: $currentDate(),
9074
9215
  promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
9075
9216
  prompt: prompt,
9076
9217
  promptResult: promptResult,
9077
9218
  })];
9078
9219
  case 12:
9220
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
9221
+ // promptResult.timing: FromtoItems
9079
9222
  _c.sent();
9080
9223
  return [2 /*return*/, promptResult];
9081
9224
  }
@@ -9327,6 +9470,83 @@
9327
9470
  },
9328
9471
  });
9329
9472
 
9473
+ /**
9474
+ * @@@
9475
+ *
9476
+ * @public exported from `@promptbook/core`
9477
+ */
9478
+ function getPipelineInterface(pipeline) {
9479
+ var e_1, _a, e_2, _b;
9480
+ var pipelineInterface = {
9481
+ inputParameterNames: [],
9482
+ outputParameterNames: [],
9483
+ };
9484
+ try {
9485
+ for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
9486
+ var parameter = _d.value;
9487
+ var name_1 = parameter.name, isInput = parameter.isInput, isOutput = parameter.isOutput;
9488
+ if (isInput) {
9489
+ pipelineInterface.inputParameterNames.push(name_1);
9490
+ }
9491
+ if (isOutput) {
9492
+ pipelineInterface.outputParameterNames.push(name_1);
9493
+ }
9494
+ }
9495
+ }
9496
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9497
+ finally {
9498
+ try {
9499
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
9500
+ }
9501
+ finally { if (e_1) throw e_1.error; }
9502
+ }
9503
+ try {
9504
+ for (var _e = __values(['inputParameterNames', 'outputParameterNames']), _f = _e.next(); !_f.done; _f = _e.next()) {
9505
+ var key = _f.value;
9506
+ pipelineInterface[key].sort(function (a, b) { return a.localeCompare(b); });
9507
+ }
9508
+ }
9509
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
9510
+ finally {
9511
+ try {
9512
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
9513
+ }
9514
+ finally { if (e_2) throw e_2.error; }
9515
+ }
9516
+ return Object.freeze(pipelineInterface);
9517
+ }
9518
+ /**
9519
+ * TODO: !!!!!! Write unit test
9520
+ */
9521
+
9522
+ /**
9523
+ * @@@
9524
+ *
9525
+ * @public exported from `@promptbook/core`
9526
+ */
9527
+ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
9528
+ // TODO: [🧠] !!! Implement better
9529
+ return JSON.stringify(pipelineInterface1) === JSON.stringify(pipelineInterface2);
9530
+ }
9531
+ /**
9532
+ * TODO: [🧠] !!! Return more states than true/false - 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
9533
+ * TODO: !!! Write unit test
9534
+ */
9535
+
9536
+ /**
9537
+ * @@@
9538
+ *
9539
+ * @public exported from `@promptbook/core`
9540
+ */
9541
+ function isPipelineImplementingInterface(options) {
9542
+ var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
9543
+ return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
9544
+ }
9545
+ /**
9546
+ * TODO: !!!!!! Test real implementing NOT equality
9547
+ * TODO: !!!!!! Write unit test
9548
+ */
9549
+
9330
9550
  /**
9331
9551
  * Metadata of the scraper
9332
9552
  *
@@ -9451,6 +9671,54 @@
9451
9671
  */
9452
9672
  var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
9453
9673
 
9674
+ /**
9675
+ * Behaves like a storage but forgets everything you put in it
9676
+ *
9677
+ * @public exported from `@promptbook/core`
9678
+ */
9679
+ var BlackholeStorage = /** @class */ (function () {
9680
+ function BlackholeStorage() {
9681
+ }
9682
+ Object.defineProperty(BlackholeStorage.prototype, "length", {
9683
+ /**
9684
+ * Returns the number of key/value pairs currently present in the list associated with the object.
9685
+ */
9686
+ get: function () {
9687
+ return 0;
9688
+ },
9689
+ enumerable: false,
9690
+ configurable: true
9691
+ });
9692
+ /**
9693
+ * Empties the list associated with the object of all key/value pairs, if there are any.
9694
+ */
9695
+ BlackholeStorage.prototype.clear = function () { };
9696
+ /**
9697
+ * 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.
9698
+ * @param key
9699
+ */
9700
+ BlackholeStorage.prototype.getItem = function (key) {
9701
+ return null;
9702
+ };
9703
+ /**
9704
+ * 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.
9705
+ */
9706
+ BlackholeStorage.prototype.key = function (index) {
9707
+ return null;
9708
+ };
9709
+ /**
9710
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
9711
+ */
9712
+ BlackholeStorage.prototype.setItem = function (key, value) {
9713
+ };
9714
+ /**
9715
+ * 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.
9716
+ */
9717
+ BlackholeStorage.prototype.removeItem = function (key) {
9718
+ };
9719
+ return BlackholeStorage;
9720
+ }());
9721
+
9454
9722
  /**
9455
9723
  * This class behaves like LocalStorage but separates keys by prefix
9456
9724
  *
@@ -9807,8 +10075,10 @@
9807
10075
  exports.$scrapersRegister = $scrapersRegister;
9808
10076
  exports.AbstractFormatError = AbstractFormatError;
9809
10077
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
10078
+ exports.BlackholeStorage = BlackholeStorage;
9810
10079
  exports.CLAIM = CLAIM;
9811
10080
  exports.CallbackInterfaceTools = CallbackInterfaceTools;
10081
+ exports.ChatFormfactorDefinition = ChatFormfactorDefinition;
9812
10082
  exports.CollectionError = CollectionError;
9813
10083
  exports.CsvFormatDefinition = CsvFormatDefinition;
9814
10084
  exports.CsvFormatError = CsvFormatError;
@@ -9825,11 +10095,14 @@
9825
10095
  exports.DEFAULT_REMOTE_URL = DEFAULT_REMOTE_URL;
9826
10096
  exports.DEFAULT_REMOTE_URL_PATH = DEFAULT_REMOTE_URL_PATH;
9827
10097
  exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
10098
+ exports.DEFAULT_TITLE = DEFAULT_TITLE;
9828
10099
  exports.ERRORS = ERRORS;
9829
10100
  exports.EXPECTATION_UNITS = EXPECTATION_UNITS;
9830
10101
  exports.EnvironmentMismatchError = EnvironmentMismatchError;
9831
10102
  exports.ExecutionReportStringOptionsDefaults = ExecutionReportStringOptionsDefaults;
9832
10103
  exports.ExpectError = ExpectError;
10104
+ exports.FORMFACTOR_DEFINITIONS = FORMFACTOR_DEFINITIONS;
10105
+ exports.GenericFormfactorDefinition = GenericFormfactorDefinition;
9833
10106
  exports.KnowledgeScrapeError = KnowledgeScrapeError;
9834
10107
  exports.LimitReachedError = LimitReachedError;
9835
10108
  exports.MANDATORY_CSV_SETTINGS = MANDATORY_CSV_SETTINGS;
@@ -9874,7 +10147,10 @@
9874
10147
  exports.createSubcollection = createSubcollection;
9875
10148
  exports.embeddingVectorToString = embeddingVectorToString;
9876
10149
  exports.executionReportJsonToString = executionReportJsonToString;
10150
+ exports.getPipelineInterface = getPipelineInterface;
9877
10151
  exports.isPassingExpectations = isPassingExpectations;
10152
+ exports.isPipelineImplementingInterface = isPipelineImplementingInterface;
10153
+ exports.isPipelineInterfacesEqual = isPipelineInterfacesEqual;
9878
10154
  exports.isPipelinePrepared = isPipelinePrepared;
9879
10155
  exports.joinLlmExecutionTools = joinLlmExecutionTools;
9880
10156
  exports.limitTotalUsage = limitTotalUsage;