@promptbook/markdown-utils 0.81.0-8 → 0.81.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 (95) hide show
  1. package/README.md +25 -8
  2. package/esm/index.es.js +220 -135
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +38 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +12 -4
  6. package/esm/typings/src/_packages/markdown-utils.index.d.ts +2 -2
  7. package/esm/typings/src/_packages/node.index.d.ts +0 -2
  8. package/esm/typings/src/_packages/templates.index.d.ts +2 -2
  9. package/esm/typings/src/_packages/types.index.d.ts +4 -0
  10. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  11. package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
  12. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  13. package/esm/typings/src/cli/cli-commands/run.d.ts +2 -2
  14. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +11 -0
  15. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  16. package/esm/typings/src/commands/index.d.ts +1 -1
  17. package/esm/typings/src/config.d.ts +3 -3
  18. package/esm/typings/src/conversion/compilePipeline.d.ts +1 -4
  19. package/esm/typings/src/conversion/{precompilePipeline.d.ts → parsePipeline.d.ts} +3 -3
  20. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  21. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +7 -7
  22. package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +1 -1
  23. package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
  24. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
  25. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +9 -4
  26. package/esm/typings/src/formfactors/image-generator/ImageGeneratorFormfactorDefinition.d.ts +24 -0
  27. package/esm/typings/src/formfactors/index.d.ts +31 -9
  28. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
  29. package/esm/typings/src/high-level-abstractions/index.d.ts +3 -3
  30. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +3 -0
  31. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
  34. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
  37. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
  38. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
  39. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
  40. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
  41. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
  42. package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
  43. package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
  44. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
  45. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
  46. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
  47. package/esm/typings/src/llm-providers/vercel/playground/playground.d.ts +1 -1
  48. package/esm/typings/src/other/templates/getBookTemplates.d.ts +22 -0
  49. package/esm/typings/src/personas/preparePersona.d.ts +4 -4
  50. package/esm/typings/src/pipeline/PipelineString.d.ts +0 -3
  51. package/esm/typings/src/pipeline/book-notation.d.ts +14 -0
  52. package/esm/typings/src/pipeline/isValidPipelineString.d.ts +13 -0
  53. package/esm/typings/src/pipeline/isValidPipelineString.test.d.ts +4 -0
  54. package/esm/typings/src/pipeline/validatePipelineString.d.ts +14 -0
  55. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +3 -1
  56. package/esm/typings/src/prepare/preparePipeline.d.ts +2 -0
  57. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -1
  58. package/esm/typings/src/scrapers/_common/Converter.d.ts +1 -0
  59. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -1
  60. package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +3 -0
  61. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -0
  62. package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +3 -0
  63. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
  64. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
  65. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
  66. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
  67. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
  68. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
  69. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -0
  70. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  71. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
  72. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +2 -1
  73. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -1
  74. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
  75. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
  76. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.test.d.ts +1 -1
  77. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +2 -1
  78. package/esm/typings/src/types/typeAliases.d.ts +16 -2
  79. package/esm/typings/src/utils/markdown/flattenMarkdown.d.ts +1 -1
  80. package/esm/typings/src/utils/markdown/{removeContentComments.d.ts → removeMarkdownComments.d.ts} +2 -2
  81. package/esm/typings/src/utils/organization/$sideEffect.d.ts +9 -0
  82. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
  83. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -2
  84. package/esm/typings/src/utils/validators/filePath/isRootPath.d.ts +12 -0
  85. package/esm/typings/src/utils/validators/filePath/isRootPath.test.d.ts +4 -0
  86. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +3 -0
  87. package/esm/typings/src/wizzard/$getCompiledBook.d.ts +16 -0
  88. package/esm/typings/src/wizzard/wizzard.d.ts +52 -8
  89. package/package.json +1 -1
  90. package/umd/index.umd.js +220 -135
  91. package/umd/index.umd.js.map +1 -1
  92. package/esm/typings/src/other/templates/getBookTemplate.d.ts +0 -21
  93. package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +0 -8
  94. /package/esm/typings/src/conversion/{precompilePipeline.test.d.ts → parsePipeline.test.d.ts} +0 -0
  95. /package/esm/typings/src/utils/markdown/{removeContentComments.test.d.ts → removeMarkdownComments.test.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
22
22
  * @generated
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-7';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-24';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -358,7 +358,27 @@ function extractJsonBlock(markdown) {
358
358
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
359
359
  */
360
360
 
361
- 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}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/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}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/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}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou 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}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/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}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book.md`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou 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}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book.md"}];
361
+ 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}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/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}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Knowledge-piece 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}],tasks:[{taskType:"PROMPT_TASK",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- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Persona",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}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book.md`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou 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}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book.md",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book.md`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book.md"}];
362
+
363
+ /**
364
+ * Function `validatePipelineString` will validate the if the string is a valid pipeline string
365
+ * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
366
+ *
367
+ * @param {string} pipelineString the candidate for a pipeline string
368
+ * @returns {PipelineString} the same string as input, but validated as valid
369
+ * @throws {ParseError} if the string is not a valid pipeline string
370
+ * @public exported from `@promptbook/core`
371
+ */
372
+ function validatePipelineString(pipelineString) {
373
+ if (isValidJsonString(pipelineString)) {
374
+ throw new ParseError('Expected a book, but got a JSON string');
375
+ }
376
+ // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
377
+ return pipelineString;
378
+ }
379
+ /**
380
+ * TODO: [🧠][🈴] Where is the best location for this file
381
+ */
362
382
 
363
383
  /**
364
384
  * Prettify the html code
@@ -417,7 +437,7 @@ function pipelineJsonToString(pipelineJson) {
417
437
  if (bookVersion !== "undefined") {
418
438
  commands.push("BOOK VERSION ".concat(bookVersion));
419
439
  }
420
- // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
440
+ // TODO: [main] !!5 This increases size of the bundle and is probbably not necessary
421
441
  pipelineString = prettifyMarkdown(pipelineString);
422
442
  try {
423
443
  for (var _g = __values(parameters.filter(function (_a) {
@@ -565,12 +585,12 @@ function pipelineJsonToString(pipelineJson) {
565
585
  pipelineString += '```' + contentLanguage;
566
586
  pipelineString += '\n';
567
587
  pipelineString += spaceTrim(content);
568
- // <- TODO: [main] !!! Escape
588
+ // <- TODO: [main] !!3 Escape
569
589
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
570
590
  pipelineString += '\n';
571
591
  pipelineString += '```';
572
592
  pipelineString += '\n\n';
573
- pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
593
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!3 If the parameter here has description, add it and use taskParameterJsonToString
574
594
  }
575
595
  }
576
596
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -580,7 +600,7 @@ function pipelineJsonToString(pipelineJson) {
580
600
  }
581
601
  finally { if (e_3) throw e_3.error; }
582
602
  }
583
- return pipelineString;
603
+ return validatePipelineString(pipelineString);
584
604
  }
585
605
  /**
586
606
  * @private internal utility of `pipelineJsonToString`
@@ -652,7 +672,7 @@ var ADMIN_GITHUB_NAME = 'hejny';
652
672
  *
653
673
  * @public exported from `@promptbook/core`
654
674
  */
655
- var DEFAULT_TITLE = "Untitled";
675
+ var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
656
676
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
657
677
  /**
658
678
  * The maximum number of iterations for a loops
@@ -804,7 +824,7 @@ function $deepFreeze(objectValue) {
804
824
  /**
805
825
  * Make error report URL for the given error
806
826
  *
807
- * @private !!!!!!
827
+ * @private private within the repository
808
828
  */
809
829
  function getErrorReportUrl(error) {
810
830
  var report = {
@@ -925,7 +945,7 @@ function checkSerializableAsJson(options) {
925
945
  if (!(error instanceof Error)) {
926
946
  throw error;
927
947
  }
928
- throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.toString()), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
948
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.stack || error.message), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
929
949
  }
930
950
  /*
931
951
  TODO: [0] Is there some more elegant way to check circular references?
@@ -955,7 +975,7 @@ function checkSerializableAsJson(options) {
955
975
  }
956
976
  /**
957
977
  * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
958
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
978
+ * TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
959
979
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
960
980
  */
961
981
 
@@ -967,7 +987,6 @@ function checkSerializableAsJson(options) {
967
987
  function deepClone(objectValue) {
968
988
  return JSON.parse(JSON.stringify(objectValue));
969
989
  /*
970
- !!!!!!!!
971
990
  TODO: [🧠] Is there a better implementation?
972
991
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
973
992
  > for (const propertyName of propertyNames) {
@@ -1133,7 +1152,7 @@ function isValidPromptbookVersion(version) {
1133
1152
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
1134
1153
  return false;
1135
1154
  }
1136
- // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
1155
+ // <- TODO: [main] !!3 Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
1137
1156
  return true;
1138
1157
  }
1139
1158
 
@@ -1233,9 +1252,6 @@ function isValidPipelineUrl(url) {
1233
1252
  if (!url.startsWith('https://')) {
1234
1253
  return false;
1235
1254
  }
1236
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
1237
- return false;
1238
- }
1239
1255
  if (url.includes('#')) {
1240
1256
  // TODO: [🐠]
1241
1257
  return false;
@@ -1266,11 +1282,11 @@ function isValidPipelineUrl(url) {
1266
1282
  */
1267
1283
  function validatePipeline(pipeline) {
1268
1284
  if (IS_PIPELINE_LOGIC_VALIDATED) {
1269
- validatePipelineCore(pipeline);
1285
+ validatePipeline_InnerFunction(pipeline);
1270
1286
  }
1271
1287
  else {
1272
1288
  try {
1273
- validatePipelineCore(pipeline);
1289
+ validatePipeline_InnerFunction(pipeline);
1274
1290
  }
1275
1291
  catch (error) {
1276
1292
  if (!(error instanceof PipelineLogicError)) {
@@ -1284,7 +1300,7 @@ function validatePipeline(pipeline) {
1284
1300
  /**
1285
1301
  * @private internal function for `validatePipeline`
1286
1302
  */
1287
- function validatePipelineCore(pipeline) {
1303
+ function validatePipeline_InnerFunction(pipeline) {
1288
1304
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
1289
1305
  var e_1, _a, e_2, _b, e_3, _c;
1290
1306
  var pipelineIdentification = (function () {
@@ -1508,11 +1524,11 @@ function validatePipelineCore(pipeline) {
1508
1524
  _loop_3();
1509
1525
  }
1510
1526
  // Note: Check that formfactor is corresponding to the pipeline interface
1511
- // TODO: !!!!!! Implement this
1527
+ // TODO: !!6 Implement this
1512
1528
  // pipeline.formfactorName
1513
1529
  }
1514
1530
  /**
1515
- * TODO: !! [🧞‍♀️] Do not allow joker + foreach
1531
+ * TODO: [🧞‍♀️] Do not allow joker + foreach
1516
1532
  * TODO: [🧠] Work with promptbookVersion
1517
1533
  * TODO: Use here some json-schema, Zod or something similar and change it to:
1518
1534
  * > /**
@@ -1524,11 +1540,11 @@ function validatePipelineCore(pipeline) {
1524
1540
  * > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
1525
1541
  */
1526
1542
  /**
1527
- * TODO: [🧳][main] !!!! Validate that all examples match expectations
1528
- * TODO: [🧳][🐝][main] !!!! Validate that knowledge is valid (non-void)
1529
- * TODO: [🧳][main] !!!! Validate that persona can be used only with CHAT variant
1530
- * TODO: [🧳][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
1531
- * TODO: [🧳][main] !!!! Validate that reserved parameter is not used as joker
1543
+ * TODO: [🧳][main] !!4 Validate that all examples match expectations
1544
+ * TODO: [🧳][🐝][main] !!4 Validate that knowledge is valid (non-void)
1545
+ * TODO: [🧳][main] !!4 Validate that persona can be used only with CHAT variant
1546
+ * TODO: [🧳][main] !!4 Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
1547
+ * TODO: [🧳][main] !!4 Validate that reserved parameter is not used as joker
1532
1548
  * TODO: [🧠] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
1533
1549
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
1534
1550
  */
@@ -1664,7 +1680,7 @@ var SimplePipelineCollection = /** @class */ (function () {
1664
1680
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
1665
1681
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
1666
1682
  var existing = this.collection.get(pipeline.pipelineUrl);
1667
- throw new PipelineUrlError(spaceTrim$1("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection \uD83C\uDF4E\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
1683
+ throw new PipelineUrlError(spaceTrim$1("\n Pipeline with URL ".concat(pipeline.pipelineUrl, " is already in the collection \uD83C\uDF4E\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
1668
1684
  }
1669
1685
  // Note: [🧠] Overwrite existing pipeline with the same URL
1670
1686
  this.collection.set(pipeline.pipelineUrl, pipeline);
@@ -2000,11 +2016,16 @@ function assertsExecutionSuccessful(executionResult) {
2000
2016
  /**
2001
2017
  * Determine if the pipeline is fully prepared
2002
2018
  *
2019
+ * @see https://github.com/webgptorg/promptbook/discussions/196
2020
+ *
2003
2021
  * @public exported from `@promptbook/core`
2004
2022
  */
2005
2023
  function isPipelinePrepared(pipeline) {
2006
2024
  // Note: Ignoring `pipeline.preparations` @@@
2007
2025
  // Note: Ignoring `pipeline.knowledgePieces` @@@
2026
+ if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
2027
+ return false;
2028
+ }
2008
2029
  if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2009
2030
  return false;
2010
2031
  }
@@ -2020,7 +2041,7 @@ function isPipelinePrepared(pipeline) {
2020
2041
  return true;
2021
2042
  }
2022
2043
  /**
2023
- * TODO: [🔃][main] !! If the pipeline was prepared with different version or different set of models, prepare it once again
2044
+ * TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
2024
2045
  * TODO: [🐠] Maybe base this on `makeValidator`
2025
2046
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2026
2047
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -2029,6 +2050,81 @@ function isPipelinePrepared(pipeline) {
2029
2050
  * - [♨] Are tasks prepared
2030
2051
  */
2031
2052
 
2053
+ /**
2054
+ * Format either small or big number
2055
+ *
2056
+ * @public exported from `@promptbook/utils`
2057
+ */
2058
+ function numberToString(value) {
2059
+ if (value === 0) {
2060
+ return '0';
2061
+ }
2062
+ else if (Number.isNaN(value)) {
2063
+ return VALUE_STRINGS.nan;
2064
+ }
2065
+ else if (value === Infinity) {
2066
+ return VALUE_STRINGS.infinity;
2067
+ }
2068
+ else if (value === -Infinity) {
2069
+ return VALUE_STRINGS.negativeInfinity;
2070
+ }
2071
+ for (var exponent = 0; exponent < 15; exponent++) {
2072
+ var factor = Math.pow(10, exponent);
2073
+ var valueRounded = Math.round(value * factor) / factor;
2074
+ if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
2075
+ return valueRounded.toFixed(exponent);
2076
+ }
2077
+ }
2078
+ return value.toString();
2079
+ }
2080
+
2081
+ /**
2082
+ * Function `valueToString` will convert the given value to string
2083
+ * This is useful and used in the `templateParameters` function
2084
+ *
2085
+ * Note: This function is not just calling `toString` method
2086
+ * It's more complex and can handle this conversion specifically for LLM models
2087
+ * See `VALUE_STRINGS`
2088
+ *
2089
+ * Note: There are 2 similar functions
2090
+ * - `valueToString` converts value to string for LLM models as human-readable string
2091
+ * - `asSerializable` converts value to string to preserve full information to be able to convert it back
2092
+ *
2093
+ * @public exported from `@promptbook/utils`
2094
+ */
2095
+ function valueToString(value) {
2096
+ try {
2097
+ if (value === '') {
2098
+ return VALUE_STRINGS.empty;
2099
+ }
2100
+ else if (value === null) {
2101
+ return VALUE_STRINGS.null;
2102
+ }
2103
+ else if (value === undefined) {
2104
+ return VALUE_STRINGS.undefined;
2105
+ }
2106
+ else if (typeof value === 'string') {
2107
+ return value;
2108
+ }
2109
+ else if (typeof value === 'number') {
2110
+ return numberToString(value);
2111
+ }
2112
+ else if (value instanceof Date) {
2113
+ return value.toISOString();
2114
+ }
2115
+ else {
2116
+ return JSON.stringify(value);
2117
+ }
2118
+ }
2119
+ catch (error) {
2120
+ if (!(error instanceof Error)) {
2121
+ throw error;
2122
+ }
2123
+ console.error(error);
2124
+ return VALUE_STRINGS.unserializable;
2125
+ }
2126
+ }
2127
+
2032
2128
  /**
2033
2129
  * Serializes an error into a [🚉] JSON-serializable object
2034
2130
  *
@@ -2710,10 +2806,10 @@ function preparePersona(personaDescription, tools, options) {
2710
2806
  });
2711
2807
  }
2712
2808
  /**
2713
- * TODO: [🔃][main] !! If the persona was prepared with different version or different set of models, prepare it once again
2714
- * TODO: [🏢] !! Check validity of `modelName` in pipeline
2715
- * TODO: [🏢] !! Check validity of `systemMessage` in pipeline
2716
- * TODO: [🏢] !! Check validity of `temperature` in pipeline
2809
+ * TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
2810
+ * TODO: [🏢] Check validity of `modelName` in pipeline
2811
+ * TODO: [🏢] Check validity of `systemMessage` in pipeline
2812
+ * TODO: [🏢] Check validity of `temperature` in pipeline
2717
2813
  */
2718
2814
 
2719
2815
  /**
@@ -3408,21 +3504,44 @@ function isValidFilePath(filename) {
3408
3504
  if (typeof filename !== 'string') {
3409
3505
  return false;
3410
3506
  }
3507
+ if (filename.split('\n').length > 1) {
3508
+ return false;
3509
+ }
3510
+ if (filename.split(' ').length >
3511
+ 5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
3512
+ return false;
3513
+ }
3411
3514
  var filenameSlashes = filename.split('\\').join('/');
3412
3515
  // Absolute Unix path: /hello.txt
3413
3516
  if (/^(\/)/i.test(filenameSlashes)) {
3517
+ // console.log(filename, 'Absolute Unix path: /hello.txt');
3414
3518
  return true;
3415
3519
  }
3416
3520
  // Absolute Windows path: /hello.txt
3417
3521
  if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
3522
+ // console.log(filename, 'Absolute Windows path: /hello.txt');
3418
3523
  return true;
3419
3524
  }
3420
3525
  // Relative path: ./hello.txt
3421
3526
  if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
3527
+ // console.log(filename, 'Relative path: ./hello.txt');
3528
+ return true;
3529
+ }
3530
+ // Allow paths like foo/hello
3531
+ if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
3532
+ // console.log(filename, 'Allow paths like foo/hello');
3533
+ return true;
3534
+ }
3535
+ // Allow paths like hello.book
3536
+ if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
3537
+ // console.log(filename, 'Allow paths like hello.book');
3422
3538
  return true;
3423
3539
  }
3424
3540
  return false;
3425
3541
  }
3542
+ /**
3543
+ * TODO: [🍏] Implement for MacOs
3544
+ */
3426
3545
 
3427
3546
  /**
3428
3547
  * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
@@ -3447,6 +3566,9 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
3447
3566
  }
3448
3567
  });
3449
3568
  }); };
3569
+ /**
3570
+ * TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
3571
+ */
3450
3572
 
3451
3573
  /**
3452
3574
  * @@@
@@ -3514,7 +3636,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3514
3636
  },
3515
3637
  }];
3516
3638
  case 2:
3517
- if (!(isValidFilePath(sourceContent) || /\.[a-z]{1,10}$/i.exec(sourceContent))) return [3 /*break*/, 4];
3639
+ if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
3518
3640
  if (tools.fs === undefined) {
3519
3641
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
3520
3642
  // <- TODO: [🧠] What is the best error type here`
@@ -3529,7 +3651,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3529
3651
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3530
3652
  case 3:
3531
3653
  if (!(_f.sent())) {
3532
- throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
3654
+ throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(sourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
3533
3655
  }
3534
3656
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
3535
3657
  return [2 /*return*/, {
@@ -3642,7 +3764,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
3642
3764
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
3643
3765
  return [2 /*return*/, "break"];
3644
3766
  }
3645
- console.warn(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n \n The source:\n > ").concat(block(knowledgeSource.sourceContent
3767
+ console.warn(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n\n The source:\n ").concat(block(knowledgeSource.sourceContent
3646
3768
  .split('\n')
3647
3769
  .map(function (line) { return "> ".concat(line); })
3648
3770
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -3680,7 +3802,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
3680
3802
  return [7 /*endfinally*/];
3681
3803
  case 9:
3682
3804
  if (partialPieces === null) {
3683
- throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n \n The source:\n > ".concat(block(knowledgeSource.sourceContent
3805
+ throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
3684
3806
  .split('\n')
3685
3807
  .map(function (line) { return "> ".concat(line); })
3686
3808
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -3771,7 +3893,7 @@ function prepareTasks(pipeline, tools, options) {
3771
3893
  * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
3772
3894
  * TODO: [🧠] Add context to each task (if missing)
3773
3895
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
3774
- * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
3896
+ * TODO: [♨][main] !!3 Prepare index the examples and maybe tasks
3775
3897
  * TODO: Write tests for `preparePipeline`
3776
3898
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3777
3899
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -3781,6 +3903,8 @@ function prepareTasks(pipeline, tools, options) {
3781
3903
  /**
3782
3904
  * Prepare pipeline from string (markdown) format to JSON format
3783
3905
  *
3906
+ * @see https://github.com/webgptorg/promptbook/discussions/196
3907
+ *
3784
3908
  * Note: This function does not validate logic of the pipeline
3785
3909
  * Note: This function acts as part of compilation process
3786
3910
  * Note: When the pipeline is already prepared, it returns the same pipeline
@@ -3793,16 +3917,17 @@ function preparePipeline(pipeline, tools, options) {
3793
3917
  <- TODO: [🧠][🪑] `promptbookVersion` */
3794
3918
  knowledgeSources /*
3795
3919
  <- TODO: [🧊] `knowledgePieces` */, personas /*
3796
- <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
3920
+ <- TODO: [🧊] `preparations` */, sources, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, title, collection, prepareTitleExecutor, _c, result, outputParameters, titleRaw, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
3921
+ var _d;
3797
3922
  var _this = this;
3798
- return __generator(this, function (_c) {
3799
- switch (_c.label) {
3923
+ return __generator(this, function (_e) {
3924
+ switch (_e.label) {
3800
3925
  case 0:
3801
3926
  if (isPipelinePrepared(pipeline)) {
3802
3927
  return [2 /*return*/, pipeline];
3803
3928
  }
3804
3929
  rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
3805
- parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3930
+ parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas, sources = pipeline.sources;
3806
3931
  if (tools === undefined || tools.llm === undefined) {
3807
3932
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
3808
3933
  }
@@ -3820,6 +3945,33 @@ function preparePipeline(pipeline, tools, options) {
3820
3945
  // <- TODO: [🧊]
3821
3946
  currentPreparation,
3822
3947
  ];
3948
+ title = pipeline.title;
3949
+ if (!(title === undefined || title === '' || title === DEFAULT_BOOK_TITLE)) return [3 /*break*/, 3];
3950
+ collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
3951
+ _c = createPipelineExecutor;
3952
+ _d = {};
3953
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book.md')];
3954
+ case 1:
3955
+ prepareTitleExecutor = _c.apply(void 0, [(_d.pipeline = _e.sent(),
3956
+ _d.tools = tools,
3957
+ _d)]);
3958
+ return [4 /*yield*/, prepareTitleExecutor({
3959
+ book: sources.map(function (_a) {
3960
+ var content = _a.content;
3961
+ return content;
3962
+ }).join('\n\n'),
3963
+ })];
3964
+ case 2:
3965
+ result = _e.sent();
3966
+ assertsExecutionSuccessful(result);
3967
+ outputParameters = result.outputParameters;
3968
+ titleRaw = outputParameters.title;
3969
+ if (isVerbose) {
3970
+ console.info("The title is \"".concat(titleRaw, "\""));
3971
+ }
3972
+ title = titleRaw || DEFAULT_BOOK_TITLE;
3973
+ _e.label = 3;
3974
+ case 3:
3823
3975
  preparedPersonas = new Array(personas.length);
3824
3976
  return [4 /*yield*/, forEachAsync(personas, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (persona, index) { return __awaiter(_this, void 0, void 0, function () {
3825
3977
  var modelRequirements, preparedPersona;
@@ -3838,12 +3990,12 @@ function preparePipeline(pipeline, tools, options) {
3838
3990
  }
3839
3991
  });
3840
3992
  }); })];
3841
- case 1:
3842
- _c.sent();
3993
+ case 4:
3994
+ _e.sent();
3843
3995
  knowledgeSourcesPrepared = knowledgeSources.map(function (source) { return (__assign(__assign({}, source), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3844
3996
  return [4 /*yield*/, prepareKnowledgePieces(knowledgeSources /* <- TODO: [🧊] {knowledgeSources, knowledgePieces} */, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), __assign(__assign({}, options), { rootDirname: rootDirname, maxParallelCount: maxParallelCount /* <- TODO: [🪂] */, isVerbose: isVerbose }))];
3845
- case 2:
3846
- partialknowledgePiecesPrepared = _c.sent();
3997
+ case 5:
3998
+ partialknowledgePiecesPrepared = _e.sent();
3847
3999
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3848
4000
  return [4 /*yield*/, prepareTasks({
3849
4001
  parameters: parameters,
@@ -3854,8 +4006,8 @@ function preparePipeline(pipeline, tools, options) {
3854
4006
  maxParallelCount: maxParallelCount /* <- TODO: [🪂] */,
3855
4007
  isVerbose: isVerbose,
3856
4008
  })];
3857
- case 3:
3858
- tasksPrepared = (_c.sent()).tasksPrepared;
4009
+ case 6:
4010
+ tasksPrepared = (_e.sent()).tasksPrepared;
3859
4011
  // ----- /Tasks preparation -----
3860
4012
  // TODO: [😂] Use here all `AsyncHighLevelAbstraction`
3861
4013
  // Note: Count total usage
@@ -3866,7 +4018,7 @@ function preparePipeline(pipeline, tools, options) {
3866
4018
  order: ORDER_OF_PIPELINE_JSON,
3867
4019
  value: __assign(__assign({}, pipeline), {
3868
4020
  // <- TODO: Probbably deeply clone the pipeline because `$exportJson` freezes the subobjects
3869
- knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
4021
+ title: title, knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
3870
4022
  // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3871
4023
  personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }),
3872
4024
  })];
@@ -3937,7 +4089,7 @@ function extractVariablesFromScript(script) {
3937
4089
  if (!(error instanceof Error)) {
3938
4090
  throw error;
3939
4091
  }
3940
- throw new ParseError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n\n\n Found variables:\n\n ").concat(Array.from(variables)
4092
+ throw new ParseError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n ".concat(block(error.stack || error.message), "\n\n Found variables:\n ").concat(Array.from(variables)
3941
4093
  .map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
3942
4094
  .join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
3943
4095
  }
@@ -4419,81 +4571,6 @@ function mapAvailableToExpectedParameters(options) {
4419
4571
  return mappedParameters;
4420
4572
  }
4421
4573
 
4422
- /**
4423
- * Format either small or big number
4424
- *
4425
- * @public exported from `@promptbook/utils`
4426
- */
4427
- function numberToString(value) {
4428
- if (value === 0) {
4429
- return '0';
4430
- }
4431
- else if (Number.isNaN(value)) {
4432
- return VALUE_STRINGS.nan;
4433
- }
4434
- else if (value === Infinity) {
4435
- return VALUE_STRINGS.infinity;
4436
- }
4437
- else if (value === -Infinity) {
4438
- return VALUE_STRINGS.negativeInfinity;
4439
- }
4440
- for (var exponent = 0; exponent < 15; exponent++) {
4441
- var factor = Math.pow(10, exponent);
4442
- var valueRounded = Math.round(value * factor) / factor;
4443
- if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
4444
- return valueRounded.toFixed(exponent);
4445
- }
4446
- }
4447
- return value.toString();
4448
- }
4449
-
4450
- /**
4451
- * Function `valueToString` will convert the given value to string
4452
- * This is useful and used in the `templateParameters` function
4453
- *
4454
- * Note: This function is not just calling `toString` method
4455
- * It's more complex and can handle this conversion specifically for LLM models
4456
- * See `VALUE_STRINGS`
4457
- *
4458
- * Note: There are 2 similar functions
4459
- * - `valueToString` converts value to string for LLM models as human-readable string
4460
- * - `asSerializable` converts value to string to preserve full information to be able to convert it back
4461
- *
4462
- * @public exported from `@promptbook/utils`
4463
- */
4464
- function valueToString(value) {
4465
- try {
4466
- if (value === '') {
4467
- return VALUE_STRINGS.empty;
4468
- }
4469
- else if (value === null) {
4470
- return VALUE_STRINGS.null;
4471
- }
4472
- else if (value === undefined) {
4473
- return VALUE_STRINGS.undefined;
4474
- }
4475
- else if (typeof value === 'string') {
4476
- return value;
4477
- }
4478
- else if (typeof value === 'number') {
4479
- return numberToString(value);
4480
- }
4481
- else if (value instanceof Date) {
4482
- return value.toISOString();
4483
- }
4484
- else {
4485
- return JSON.stringify(value);
4486
- }
4487
- }
4488
- catch (error) {
4489
- if (!(error instanceof Error)) {
4490
- throw error;
4491
- }
4492
- console.error(error);
4493
- return VALUE_STRINGS.unserializable;
4494
- }
4495
- }
4496
-
4497
4574
  /**
4498
4575
  * Replaces parameters in template with values from parameters object
4499
4576
  *
@@ -4550,6 +4627,8 @@ function templateParameters(template, parameters) {
4550
4627
  throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4551
4628
  }
4552
4629
  parameterValue = valueToString(parameterValue);
4630
+ // Escape curly braces in parameter values to prevent prompt-injection
4631
+ parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
4553
4632
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
4554
4633
  parameterValue = parameterValue
4555
4634
  .split('\n')
@@ -4909,7 +4988,7 @@ function executeAttempts(options) {
4909
4988
  promptTitle: task.title,
4910
4989
  promptMessage: templateParameters(task.description || '', parameters),
4911
4990
  defaultValue: templateParameters(preparedContent, parameters),
4912
- // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4991
+ // TODO: [🧠] Figure out how to define placeholder in .book.md file
4913
4992
  placeholder: undefined,
4914
4993
  priority: priority,
4915
4994
  }))];
@@ -5609,7 +5688,10 @@ function executePipeline(options) {
5609
5688
  finally { if (e_2) throw e_2.error; }
5610
5689
  return [7 /*endfinally*/];
5611
5690
  case 19:
5612
- parametersToPass = inputParameters;
5691
+ parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
5692
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
5693
+ return [key, valueToString(value)];
5694
+ }));
5613
5695
  _g.label = 20;
5614
5696
  case 20:
5615
5697
  _g.trys.push([20, 25, , 28]);
@@ -5896,6 +5978,7 @@ var markdownScraperMetadata = $deepFreeze({
5896
5978
  mimeTypes: ['text/markdown', 'text/plain'],
5897
5979
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
5898
5980
  isAvilableInBrowser: true,
5981
+ // <- Note: [🌏] This is the only scraper which makes sense to be available in the browser, for scraping non-markdown sources in the browser use a remote server
5899
5982
  requiredExecutables: [],
5900
5983
  }); /* <- Note: [🤛] */
5901
5984
  /**
@@ -5904,6 +5987,7 @@ var markdownScraperMetadata = $deepFreeze({
5904
5987
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
5905
5988
  *
5906
5989
  * @public exported from `@promptbook/core`
5990
+ * @public exported from `@promptbook/wizzard`
5907
5991
  * @public exported from `@promptbook/cli`
5908
5992
  */
5909
5993
  $scrapersMetadataRegister.register(markdownScraperMetadata);
@@ -5989,12 +6073,12 @@ var MarkdownScraper = /** @class */ (function () {
5989
6073
  outputParameters = result.outputParameters;
5990
6074
  knowledgePiecesRaw = outputParameters.knowledgePieces;
5991
6075
  knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
5992
- // <- TODO: [main] !! Smarter split and filter out empty pieces
6076
+ // <- TODO: [main] Smarter split and filter out empty pieces
5993
6077
  if (isVerbose) {
5994
6078
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
5995
6079
  }
5996
6080
  return [4 /*yield*/, Promise.all(
5997
- // TODO: [🪂] !! Do not send all at once but in chunks
6081
+ // TODO: [🪂] Do not send all at once but in chunks
5998
6082
  knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
5999
6083
  var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
6000
6084
  return __generator(this, function (_c) {
@@ -6099,6 +6183,7 @@ var createMarkdownScraper = Object.assign(function (tools, options) {
6099
6183
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6100
6184
  *
6101
6185
  * @public exported from `@promptbook/markdown-utils`
6186
+ * @public exported from `@promptbook/wizzard`
6102
6187
  * @public exported from `@promptbook/cli`
6103
6188
  */
6104
6189
  var _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownScraper);
@@ -6108,13 +6193,13 @@ var _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownScra
6108
6193
  */
6109
6194
 
6110
6195
  /**
6111
- * Removes HTML or Markdown comments from a string.
6196
+ * Removes Markdown (or HTML) comments
6112
6197
  *
6113
6198
  * @param {string} content - The string to remove comments from.
6114
6199
  * @returns {string} The input string with all comments removed.
6115
6200
  * @public exported from `@promptbook/markdown-utils`
6116
6201
  */
6117
- function removeContentComments(content) {
6202
+ function removeMarkdownComments(content) {
6118
6203
  return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
6119
6204
  }
6120
6205
 
@@ -6133,7 +6218,7 @@ function addAutoGeneratedSection(content, options) {
6133
6218
  return content.replace(sectionRegex, contentToInsert);
6134
6219
  }
6135
6220
  // Note: Following is the case when the section is not found in the file so we add it there
6136
- var placeForSection = removeContentComments(content).match(/^##.*$/im);
6221
+ var placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
6137
6222
  if (placeForSection !== null) {
6138
6223
  var _a = __read(placeForSection, 1), heading_1 = _a[0];
6139
6224
  return content.replace(heading_1, spaceTrim$1(function (block) { return "\n ".concat(block(contentToInsert), "\n\n ").concat(block(heading_1), "\n "); }));
@@ -6313,7 +6398,7 @@ function splitMarkdownIntoSections(markdown) {
6313
6398
  return;
6314
6399
  }
6315
6400
  if (!section.startsWith('#')) {
6316
- section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
6401
+ section = "# ".concat(DEFAULT_BOOK_TITLE, "\n\n").concat(section);
6317
6402
  }
6318
6403
  sections.push(section);
6319
6404
  buffer = [];
@@ -6368,7 +6453,7 @@ function splitMarkdownIntoSections(markdown) {
6368
6453
  /**
6369
6454
  * Normalizes the markdown by flattening the structure
6370
6455
  *
6371
- * - It always have h1 - if there is no h1 in the markdown, it will be added "# Untitled"
6456
+ * - It always have h1 - if there is no h1 in the markdown, it will be added `DEFAULT_BOOK_TITLE`
6372
6457
  * - All other headings are normalized to h2
6373
6458
  *
6374
6459
  * @public exported from `@promptbook/markdown-utils`
@@ -6377,7 +6462,7 @@ function flattenMarkdown(markdown) {
6377
6462
  var e_1, _a;
6378
6463
  var sections = splitMarkdownIntoSections(markdown);
6379
6464
  if (sections.length === 0) {
6380
- return "# ".concat(DEFAULT_TITLE);
6465
+ return "# ".concat(DEFAULT_BOOK_TITLE);
6381
6466
  }
6382
6467
  var flattenedMarkdown = '';
6383
6468
  var parsedSections = sections.map(parseMarkdownSection);
@@ -6388,7 +6473,7 @@ function flattenMarkdown(markdown) {
6388
6473
  }
6389
6474
  else {
6390
6475
  parsedSections.unshift(firstSection);
6391
- flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
6476
+ flattenedMarkdown += "# ".concat(DEFAULT_BOOK_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
6392
6477
  }
6393
6478
  try {
6394
6479
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
@@ -6431,5 +6516,5 @@ function removeMarkdownFormatting(str) {
6431
6516
  return str;
6432
6517
  }
6433
6518
 
6434
- export { BOOK_LANGUAGE_VERSION, MarkdownScraper, PROMPTBOOK_ENGINE_VERSION, _MarkdownScraperRegistration, addAutoGeneratedSection, createMarkdownChart, createMarkdownScraper, createMarkdownTable, escapeMarkdownBlock, extractAllBlocksFromMarkdown, extractAllListItemsFromMarkdown, extractBlock, extractJsonBlock, extractOneBlockFromMarkdown, flattenMarkdown, parseMarkdownSection, removeContentComments, removeMarkdownFormatting, splitMarkdownIntoSections };
6519
+ export { BOOK_LANGUAGE_VERSION, MarkdownScraper, PROMPTBOOK_ENGINE_VERSION, _MarkdownScraperRegistration, addAutoGeneratedSection, createMarkdownChart, createMarkdownScraper, createMarkdownTable, escapeMarkdownBlock, extractAllBlocksFromMarkdown, extractAllListItemsFromMarkdown, extractBlock, extractJsonBlock, extractOneBlockFromMarkdown, flattenMarkdown, parseMarkdownSection, removeMarkdownComments, removeMarkdownFormatting, splitMarkdownIntoSections };
6435
6520
  //# sourceMappingURL=index.es.js.map