@promptbook/markdown-utils 0.74.0-11 → 0.74.0-13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -148,7 +148,7 @@ Following is the documentation and blueprint of the Book language.
148
148
 
149
149
  File is designed to be easy to read and write. It is strict subset of markdown. It is designed to be understandable by both humans and machines and without specific knowledge of the language.
150
150
 
151
- It has file with `.ptbk.md` or `.book` extension with `UTF-8` non BOM encoding.
151
+ It has file with `.book.md` or `.book` extension with `UTF-8` non BOM encoding.
152
152
 
153
153
  As it is source code, it can leverage all the features of version control systems like git and does not suffer from the problems of binary formats, proprietary formats, or no-code solutions.
154
154
 
@@ -241,11 +241,6 @@ Or you can install them separately:
241
241
 
242
242
  ## 📚 Dictionary
243
243
 
244
-
245
-
246
-
247
-
248
-
249
244
  ### 📚 Dictionary
250
245
 
251
246
  The following glossary is used to clarify certain concepts:
@@ -261,8 +256,6 @@ The following glossary is used to clarify certain concepts:
261
256
  - **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
262
257
  - **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
263
258
 
264
-
265
-
266
259
  _Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
267
260
 
268
261
  #### Promptbook core
@@ -323,8 +316,6 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
323
316
  - [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
324
317
  - [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
325
318
 
326
-
327
-
328
319
  ### Terms specific to Promptbook TypeScript implementation
329
320
 
330
321
  - Anonymous mode
package/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  *
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-10';
23
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-12';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  */
@@ -355,7 +355,7 @@ function extractJsonBlock(markdown) {
355
355
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
356
356
  */
357
357
 
358
- 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"}];
358
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.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.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.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.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.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.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.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.book.md"}];
359
359
 
360
360
  /**
361
361
  * Prettify the html code
@@ -394,13 +394,13 @@ function prettifyMarkdown(content) {
394
394
  /**
395
395
  * Converts promptbook in JSON format to string format
396
396
  *
397
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
398
- * @returns Promptbook in string format (.ptbk.md)
397
+ * @param pipelineJson Promptbook in JSON format (.book.json)
398
+ * @returns Promptbook in string format (.book.md)
399
399
  * @public exported from `@promptbook/core`
400
400
  */
401
401
  function pipelineJsonToString(pipelineJson) {
402
402
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
403
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
403
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
404
404
  var pipelineString = "# ".concat(title);
405
405
  if (description) {
406
406
  pipelineString += '\n\n';
@@ -410,8 +410,10 @@ function pipelineJsonToString(pipelineJson) {
410
410
  if (pipelineUrl) {
411
411
  commands.push("PIPELINE URL ".concat(pipelineUrl));
412
412
  }
413
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
414
- // TODO: [main] !!! This increase size of the bundle and is probbably not necessary
413
+ if (bookVersion !== "undefined") {
414
+ commands.push("BOOK VERSION ".concat(bookVersion));
415
+ }
416
+ // TODO: [main] !!!!!! This increase size of the bundle and is probbably not necessary
415
417
  pipelineString = prettifyMarkdown(pipelineString);
416
418
  try {
417
419
  for (var _g = __values(parameters.filter(function (_a) {
@@ -591,7 +593,7 @@ function templateParameterJsonToString(templateParameterJson) {
591
593
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
592
594
  * TODO: [🏛] Maybe make some markdown builder
593
595
  * TODO: [🏛] Escape all
594
- * TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
596
+ * TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
595
597
  */
596
598
 
597
599
  /**
@@ -1065,7 +1067,7 @@ function isValidPipelineUrl(url) {
1065
1067
  if (!url.startsWith('https://')) {
1066
1068
  return false;
1067
1069
  }
1068
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
1070
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
1069
1071
  return false;
1070
1072
  }
1071
1073
  if (url.includes('#')) {
@@ -1134,9 +1136,9 @@ function validatePipelineCore(pipeline) {
1134
1136
  // <- Note: [🚲]
1135
1137
  throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1136
1138
  }
1137
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
1139
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
1138
1140
  // <- Note: [🚲]
1139
- throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1141
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1140
1142
  }
1141
1143
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1142
1144
  if (!Array.isArray(pipeline.parameters)) {
@@ -2785,7 +2787,7 @@ function preparePersona(personaDescription, tools, options) {
2785
2787
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
2786
2788
  _b = createPipelineExecutor;
2787
2789
  _c = {};
2788
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
2790
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
2789
2791
  case 1:
2790
2792
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
2791
2793
  _c.tools = tools,
@@ -3457,12 +3459,12 @@ TODO: [🧊] This is how it can look in future
3457
3459
  */
3458
3460
  function clonePipeline(pipeline) {
3459
3461
  // Note: Not using spread operator (...) because @@@
3460
- 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;
3462
+ var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
3461
3463
  return {
3462
3464
  pipelineUrl: pipelineUrl,
3463
3465
  sourceFile: sourceFile,
3464
3466
  title: title,
3465
- promptbookVersion: promptbookVersion,
3467
+ bookVersion: bookVersion,
3466
3468
  description: description,
3467
3469
  parameters: parameters,
3468
3470
  templates: templates,
@@ -4573,7 +4575,7 @@ function executeAttempts(options) {
4573
4575
  promptTitle: template.title,
4574
4576
  promptMessage: replaceParameters(template.description || '', parameters),
4575
4577
  defaultValue: replaceParameters(preparedContent, parameters),
4576
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
4578
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4577
4579
  placeholder: undefined,
4578
4580
  priority: priority,
4579
4581
  }))];
@@ -5139,7 +5141,7 @@ function executePipeline(options) {
5139
5141
  pipelineUrl: preparedPipeline.pipelineUrl,
5140
5142
  title: preparedPipeline.title,
5141
5143
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
5142
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
5144
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
5143
5145
  description: preparedPipeline.description,
5144
5146
  promptExecutions: [],
5145
5147
  };
@@ -5535,7 +5537,7 @@ var MarkdownScraper = /** @class */ (function () {
5535
5537
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
5536
5538
  _d = createPipelineExecutor;
5537
5539
  _g = {};
5538
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
5540
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
5539
5541
  case 1:
5540
5542
  prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
5541
5543
  _g.tools = {
@@ -5544,7 +5546,7 @@ var MarkdownScraper = /** @class */ (function () {
5544
5546
  _g)]);
5545
5547
  _e = createPipelineExecutor;
5546
5548
  _h = {};
5547
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md')];
5549
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
5548
5550
  case 2:
5549
5551
  prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
5550
5552
  _h.tools = {
@@ -5553,7 +5555,7 @@ var MarkdownScraper = /** @class */ (function () {
5553
5555
  _h)]);
5554
5556
  _f = createPipelineExecutor;
5555
5557
  _j = {};
5556
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md')];
5558
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
5557
5559
  case 3:
5558
5560
  prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
5559
5561
  _j.tools = {