@promptbook/markdown-utils 0.81.0-9 → 0.82.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +25 -4
  2. package/esm/index.es.js +143 -61
  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/remote-client.index.d.ts +7 -3
  9. package/esm/typings/src/_packages/remote-server.index.d.ts +2 -2
  10. package/esm/typings/src/_packages/templates.index.d.ts +2 -2
  11. package/esm/typings/src/_packages/types.index.d.ts +32 -30
  12. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  13. package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
  14. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  15. package/esm/typings/src/cli/cli-commands/run.d.ts +2 -2
  16. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +11 -0
  17. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  18. package/esm/typings/src/commands/index.d.ts +1 -1
  19. package/esm/typings/src/config.d.ts +3 -3
  20. package/esm/typings/src/conversion/compilePipeline.d.ts +1 -4
  21. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +18 -0
  22. package/esm/typings/src/conversion/{precompilePipeline.d.ts → parsePipeline.d.ts} +3 -3
  23. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  24. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +7 -7
  25. package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +1 -1
  26. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +9 -4
  27. package/esm/typings/src/formfactors/image-generator/ImageGeneratorFormfactorDefinition.d.ts +24 -0
  28. package/esm/typings/src/formfactors/index.d.ts +31 -9
  29. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
  30. package/esm/typings/src/high-level-abstractions/index.d.ts +3 -3
  31. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +3 -0
  32. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
  35. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  37. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
  39. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
  40. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
  41. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
  42. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
  43. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
  44. package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
  45. package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
  46. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
  47. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
  48. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
  49. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  50. package/esm/typings/src/llm-providers/vercel/playground/playground.d.ts +1 -1
  51. package/esm/typings/src/other/templates/getBookTemplates.d.ts +22 -0
  52. package/esm/typings/src/personas/preparePersona.d.ts +4 -4
  53. package/esm/typings/src/pipeline/PipelineString.d.ts +0 -3
  54. package/esm/typings/src/pipeline/book-notation.d.ts +14 -0
  55. package/esm/typings/src/pipeline/isValidPipelineString.d.ts +13 -0
  56. package/esm/typings/src/pipeline/isValidPipelineString.test.d.ts +4 -0
  57. package/esm/typings/src/pipeline/validatePipelineString.d.ts +14 -0
  58. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +3 -1
  59. package/esm/typings/src/prepare/preparePipeline.d.ts +4 -2
  60. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +14 -0
  61. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -1
  62. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_Error.d.ts +1 -1
  63. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_ListModels_Request.d.ts +4 -4
  64. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_ListModels_Response.d.ts +1 -1
  65. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_Prompt_Progress.d.ts +1 -1
  66. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_Prompt_Request.d.ts +5 -5
  67. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_Prompt_Response.d.ts +1 -1
  68. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/RemoteLlmExecutionToolsOptions.d.ts +7 -7
  69. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/RemoteServerOptions.d.ts +10 -10
  70. package/esm/typings/src/scrapers/_common/Converter.d.ts +1 -0
  71. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -1
  72. package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +3 -0
  73. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -0
  74. package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +3 -0
  75. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
  76. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
  77. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
  78. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
  79. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
  80. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
  81. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -0
  82. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  83. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
  84. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +2 -1
  85. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -1
  86. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
  87. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
  88. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.test.d.ts +1 -1
  89. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +2 -1
  90. package/esm/typings/src/types/typeAliases.d.ts +8 -2
  91. package/esm/typings/src/utils/markdown/flattenMarkdown.d.ts +1 -1
  92. package/esm/typings/src/utils/markdown/{removeContentComments.d.ts → removeMarkdownComments.d.ts} +2 -2
  93. package/esm/typings/src/utils/organization/$sideEffect.d.ts +9 -0
  94. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
  95. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -2
  96. package/esm/typings/src/utils/validators/filePath/isRootPath.d.ts +12 -0
  97. package/esm/typings/src/utils/validators/filePath/isRootPath.test.d.ts +4 -0
  98. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +3 -0
  99. package/esm/typings/src/wizzard/$getCompiledBook.d.ts +16 -0
  100. package/esm/typings/src/wizzard/wizzard.d.ts +51 -7
  101. package/package.json +1 -1
  102. package/umd/index.umd.js +143 -61
  103. package/umd/index.umd.js.map +1 -1
  104. package/esm/typings/src/other/templates/getBookTemplate.d.ts +0 -21
  105. package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +0 -8
  106. /package/esm/typings/src/conversion/{precompilePipeline.test.d.ts → parsePipeline.test.d.ts} +0 -0
  107. /package/esm/typings/src/{llm-providers/remote → remote-server}/startRemoteServer.d.ts +0 -0
  108. /package/esm/typings/src/utils/markdown/{removeContentComments.test.d.ts → removeMarkdownComments.test.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-8';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-23';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -360,7 +360,27 @@
360
360
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
361
361
  */
362
362
 
363
- 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"}];
363
+ 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- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\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- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\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 task:\n\n> {book}\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Title starts with emoticon",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 task:\n\n> {book}\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Title starts with emoticon\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book.md"}];
364
+
365
+ /**
366
+ * Function `validatePipelineString` will validate the if the string is a valid pipeline string
367
+ * 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.
368
+ *
369
+ * @param {string} pipelineString the candidate for a pipeline string
370
+ * @returns {PipelineString} the same string as input, but validated as valid
371
+ * @throws {ParseError} if the string is not a valid pipeline string
372
+ * @public exported from `@promptbook/core`
373
+ */
374
+ function validatePipelineString(pipelineString) {
375
+ if (isValidJsonString(pipelineString)) {
376
+ throw new ParseError('Expected a book, but got a JSON string');
377
+ }
378
+ // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
379
+ return pipelineString;
380
+ }
381
+ /**
382
+ * TODO: [🧠][🈴] Where is the best location for this file
383
+ */
364
384
 
365
385
  /**
366
386
  * Prettify the html code
@@ -419,7 +439,7 @@
419
439
  if (bookVersion !== "undefined") {
420
440
  commands.push("BOOK VERSION ".concat(bookVersion));
421
441
  }
422
- // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
442
+ // TODO: [main] !!5 This increases size of the bundle and is probbably not necessary
423
443
  pipelineString = prettifyMarkdown(pipelineString);
424
444
  try {
425
445
  for (var _g = __values(parameters.filter(function (_a) {
@@ -567,12 +587,12 @@
567
587
  pipelineString += '```' + contentLanguage;
568
588
  pipelineString += '\n';
569
589
  pipelineString += spaceTrim__default["default"](content);
570
- // <- TODO: [main] !!! Escape
590
+ // <- TODO: [main] !!3 Escape
571
591
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
572
592
  pipelineString += '\n';
573
593
  pipelineString += '```';
574
594
  pipelineString += '\n\n';
575
- pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
595
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!3 If the parameter here has description, add it and use taskParameterJsonToString
576
596
  }
577
597
  }
578
598
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -582,7 +602,7 @@
582
602
  }
583
603
  finally { if (e_3) throw e_3.error; }
584
604
  }
585
- return pipelineString;
605
+ return validatePipelineString(pipelineString);
586
606
  }
587
607
  /**
588
608
  * @private internal utility of `pipelineJsonToString`
@@ -654,7 +674,7 @@
654
674
  *
655
675
  * @public exported from `@promptbook/core`
656
676
  */
657
- var DEFAULT_TITLE = "Untitled";
677
+ var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
658
678
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
659
679
  /**
660
680
  * The maximum number of iterations for a loops
@@ -806,7 +826,7 @@
806
826
  /**
807
827
  * Make error report URL for the given error
808
828
  *
809
- * @private !!!!!!
829
+ * @private private within the repository
810
830
  */
811
831
  function getErrorReportUrl(error) {
812
832
  var report = {
@@ -927,7 +947,7 @@
927
947
  if (!(error instanceof Error)) {
928
948
  throw error;
929
949
  }
930
- throw new UnexpectedError(spaceTrim__default["default"](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 "); }));
950
+ throw new UnexpectedError(spaceTrim__default["default"](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 "); }));
931
951
  }
932
952
  /*
933
953
  TODO: [0] Is there some more elegant way to check circular references?
@@ -957,7 +977,7 @@
957
977
  }
958
978
  /**
959
979
  * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
960
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
980
+ * TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
961
981
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
962
982
  */
963
983
 
@@ -969,7 +989,6 @@
969
989
  function deepClone(objectValue) {
970
990
  return JSON.parse(JSON.stringify(objectValue));
971
991
  /*
972
- !!!!!!!!
973
992
  TODO: [🧠] Is there a better implementation?
974
993
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
975
994
  > for (const propertyName of propertyNames) {
@@ -1135,7 +1154,7 @@
1135
1154
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
1136
1155
  return false;
1137
1156
  }
1138
- // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
1157
+ // <- TODO: [main] !!3 Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
1139
1158
  return true;
1140
1159
  }
1141
1160
 
@@ -1235,9 +1254,6 @@
1235
1254
  if (!url.startsWith('https://')) {
1236
1255
  return false;
1237
1256
  }
1238
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
1239
- return false;
1240
- }
1241
1257
  if (url.includes('#')) {
1242
1258
  // TODO: [🐠]
1243
1259
  return false;
@@ -1268,11 +1284,11 @@
1268
1284
  */
1269
1285
  function validatePipeline(pipeline) {
1270
1286
  if (IS_PIPELINE_LOGIC_VALIDATED) {
1271
- validatePipelineCore(pipeline);
1287
+ validatePipeline_InnerFunction(pipeline);
1272
1288
  }
1273
1289
  else {
1274
1290
  try {
1275
- validatePipelineCore(pipeline);
1291
+ validatePipeline_InnerFunction(pipeline);
1276
1292
  }
1277
1293
  catch (error) {
1278
1294
  if (!(error instanceof PipelineLogicError)) {
@@ -1286,7 +1302,7 @@
1286
1302
  /**
1287
1303
  * @private internal function for `validatePipeline`
1288
1304
  */
1289
- function validatePipelineCore(pipeline) {
1305
+ function validatePipeline_InnerFunction(pipeline) {
1290
1306
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
1291
1307
  var e_1, _a, e_2, _b, e_3, _c;
1292
1308
  var pipelineIdentification = (function () {
@@ -1510,11 +1526,11 @@
1510
1526
  _loop_3();
1511
1527
  }
1512
1528
  // Note: Check that formfactor is corresponding to the pipeline interface
1513
- // TODO: !!!!!! Implement this
1529
+ // TODO: !!6 Implement this
1514
1530
  // pipeline.formfactorName
1515
1531
  }
1516
1532
  /**
1517
- * TODO: !! [🧞‍♀️] Do not allow joker + foreach
1533
+ * TODO: [🧞‍♀️] Do not allow joker + foreach
1518
1534
  * TODO: [🧠] Work with promptbookVersion
1519
1535
  * TODO: Use here some json-schema, Zod or something similar and change it to:
1520
1536
  * > /**
@@ -1526,11 +1542,11 @@
1526
1542
  * > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
1527
1543
  */
1528
1544
  /**
1529
- * TODO: [🧳][main] !!!! Validate that all examples match expectations
1530
- * TODO: [🧳][🐝][main] !!!! Validate that knowledge is valid (non-void)
1531
- * TODO: [🧳][main] !!!! Validate that persona can be used only with CHAT variant
1532
- * TODO: [🧳][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
1533
- * TODO: [🧳][main] !!!! Validate that reserved parameter is not used as joker
1545
+ * TODO: [🧳][main] !!4 Validate that all examples match expectations
1546
+ * TODO: [🧳][🐝][main] !!4 Validate that knowledge is valid (non-void)
1547
+ * TODO: [🧳][main] !!4 Validate that persona can be used only with CHAT variant
1548
+ * TODO: [🧳][main] !!4 Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
1549
+ * TODO: [🧳][main] !!4 Validate that reserved parameter is not used as joker
1534
1550
  * TODO: [🧠] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
1535
1551
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
1536
1552
  */
@@ -1666,7 +1682,7 @@
1666
1682
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
1667
1683
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
1668
1684
  var existing = this.collection.get(pipeline.pipelineUrl);
1669
- throw new PipelineUrlError(spaceTrim.spaceTrim("\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 ")));
1685
+ throw new PipelineUrlError(spaceTrim.spaceTrim("\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 ")));
1670
1686
  }
1671
1687
  // Note: [🧠] Overwrite existing pipeline with the same URL
1672
1688
  this.collection.set(pipeline.pipelineUrl, pipeline);
@@ -2002,11 +2018,16 @@
2002
2018
  /**
2003
2019
  * Determine if the pipeline is fully prepared
2004
2020
  *
2021
+ * @see https://github.com/webgptorg/promptbook/discussions/196
2022
+ *
2005
2023
  * @public exported from `@promptbook/core`
2006
2024
  */
2007
2025
  function isPipelinePrepared(pipeline) {
2008
2026
  // Note: Ignoring `pipeline.preparations` @@@
2009
2027
  // Note: Ignoring `pipeline.knowledgePieces` @@@
2028
+ if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
2029
+ return false;
2030
+ }
2010
2031
  if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2011
2032
  return false;
2012
2033
  }
@@ -2022,7 +2043,7 @@
2022
2043
  return true;
2023
2044
  }
2024
2045
  /**
2025
- * TODO: [🔃][main] !! If the pipeline was prepared with different version or different set of models, prepare it once again
2046
+ * TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
2026
2047
  * TODO: [🐠] Maybe base this on `makeValidator`
2027
2048
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2028
2049
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -2787,10 +2808,10 @@
2787
2808
  });
2788
2809
  }
2789
2810
  /**
2790
- * TODO: [🔃][main] !! If the persona was prepared with different version or different set of models, prepare it once again
2791
- * TODO: [🏢] !! Check validity of `modelName` in pipeline
2792
- * TODO: [🏢] !! Check validity of `systemMessage` in pipeline
2793
- * TODO: [🏢] !! Check validity of `temperature` in pipeline
2811
+ * TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
2812
+ * TODO: [🏢] Check validity of `modelName` in pipeline
2813
+ * TODO: [🏢] Check validity of `systemMessage` in pipeline
2814
+ * TODO: [🏢] Check validity of `temperature` in pipeline
2794
2815
  */
2795
2816
 
2796
2817
  /**
@@ -3485,21 +3506,44 @@
3485
3506
  if (typeof filename !== 'string') {
3486
3507
  return false;
3487
3508
  }
3509
+ if (filename.split('\n').length > 1) {
3510
+ return false;
3511
+ }
3512
+ if (filename.split(' ').length >
3513
+ 5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
3514
+ return false;
3515
+ }
3488
3516
  var filenameSlashes = filename.split('\\').join('/');
3489
3517
  // Absolute Unix path: /hello.txt
3490
3518
  if (/^(\/)/i.test(filenameSlashes)) {
3519
+ // console.log(filename, 'Absolute Unix path: /hello.txt');
3491
3520
  return true;
3492
3521
  }
3493
3522
  // Absolute Windows path: /hello.txt
3494
3523
  if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
3524
+ // console.log(filename, 'Absolute Windows path: /hello.txt');
3495
3525
  return true;
3496
3526
  }
3497
3527
  // Relative path: ./hello.txt
3498
3528
  if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
3529
+ // console.log(filename, 'Relative path: ./hello.txt');
3530
+ return true;
3531
+ }
3532
+ // Allow paths like foo/hello
3533
+ if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
3534
+ // console.log(filename, 'Allow paths like foo/hello');
3535
+ return true;
3536
+ }
3537
+ // Allow paths like hello.book
3538
+ if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
3539
+ // console.log(filename, 'Allow paths like hello.book');
3499
3540
  return true;
3500
3541
  }
3501
3542
  return false;
3502
3543
  }
3544
+ /**
3545
+ * TODO: [🍏] Implement for MacOs
3546
+ */
3503
3547
 
3504
3548
  /**
3505
3549
  * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
@@ -3524,6 +3568,9 @@
3524
3568
  }
3525
3569
  });
3526
3570
  }); };
3571
+ /**
3572
+ * TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
3573
+ */
3527
3574
 
3528
3575
  /**
3529
3576
  * @@@
@@ -3591,7 +3638,7 @@
3591
3638
  },
3592
3639
  }];
3593
3640
  case 2:
3594
- if (!(isValidFilePath(sourceContent) || /\.[a-z]{1,10}$/i.exec(sourceContent))) return [3 /*break*/, 4];
3641
+ if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
3595
3642
  if (tools.fs === undefined) {
3596
3643
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
3597
3644
  // <- TODO: [🧠] What is the best error type here`
@@ -3606,7 +3653,7 @@
3606
3653
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3607
3654
  case 3:
3608
3655
  if (!(_f.sent())) {
3609
- throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
3656
+ throw new NotFoundError(spaceTrim__default["default"](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 "); }));
3610
3657
  }
3611
3658
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
3612
3659
  return [2 /*return*/, {
@@ -3719,7 +3766,7 @@
3719
3766
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
3720
3767
  return [2 /*return*/, "break"];
3721
3768
  }
3722
- console.warn(spaceTrim__default["default"](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
3769
+ console.warn(spaceTrim__default["default"](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
3723
3770
  .split('\n')
3724
3771
  .map(function (line) { return "> ".concat(line); })
3725
3772
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -3757,7 +3804,7 @@
3757
3804
  return [7 /*endfinally*/];
3758
3805
  case 9:
3759
3806
  if (partialPieces === null) {
3760
- throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n \n The source:\n > ".concat(block(knowledgeSource.sourceContent
3807
+ throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
3761
3808
  .split('\n')
3762
3809
  .map(function (line) { return "> ".concat(line); })
3763
3810
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -3848,7 +3895,7 @@
3848
3895
  * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
3849
3896
  * TODO: [🧠] Add context to each task (if missing)
3850
3897
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
3851
- * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
3898
+ * TODO: [♨][main] !!3 Prepare index the examples and maybe tasks
3852
3899
  * TODO: Write tests for `preparePipeline`
3853
3900
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3854
3901
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -3856,7 +3903,9 @@
3856
3903
  */
3857
3904
 
3858
3905
  /**
3859
- * Prepare pipeline from string (markdown) format to JSON format
3906
+ * Prepare pipeline locally
3907
+ *
3908
+ * @see https://github.com/webgptorg/promptbook/discussions/196
3860
3909
  *
3861
3910
  * Note: This function does not validate logic of the pipeline
3862
3911
  * Note: This function acts as part of compilation process
@@ -3870,16 +3919,17 @@
3870
3919
  <- TODO: [🧠][🪑] `promptbookVersion` */
3871
3920
  knowledgeSources /*
3872
3921
  <- TODO: [🧊] `knowledgePieces` */, personas /*
3873
- <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
3922
+ <- TODO: [🧊] `preparations` */, sources, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, title, collection, prepareTitleExecutor, _c, result, outputParameters, titleRaw, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
3923
+ var _d;
3874
3924
  var _this = this;
3875
- return __generator(this, function (_c) {
3876
- switch (_c.label) {
3925
+ return __generator(this, function (_e) {
3926
+ switch (_e.label) {
3877
3927
  case 0:
3878
3928
  if (isPipelinePrepared(pipeline)) {
3879
3929
  return [2 /*return*/, pipeline];
3880
3930
  }
3881
3931
  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;
3882
- parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3932
+ parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas, sources = pipeline.sources;
3883
3933
  if (tools === undefined || tools.llm === undefined) {
3884
3934
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
3885
3935
  }
@@ -3897,6 +3947,33 @@
3897
3947
  // <- TODO: [🧊]
3898
3948
  currentPreparation,
3899
3949
  ];
3950
+ title = pipeline.title;
3951
+ if (!(title === undefined || title === '' || title === DEFAULT_BOOK_TITLE)) return [3 /*break*/, 3];
3952
+ collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
3953
+ _c = createPipelineExecutor;
3954
+ _d = {};
3955
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book.md')];
3956
+ case 1:
3957
+ prepareTitleExecutor = _c.apply(void 0, [(_d.pipeline = _e.sent(),
3958
+ _d.tools = tools,
3959
+ _d)]);
3960
+ return [4 /*yield*/, prepareTitleExecutor({
3961
+ book: sources.map(function (_a) {
3962
+ var content = _a.content;
3963
+ return content;
3964
+ }).join('\n\n'),
3965
+ })];
3966
+ case 2:
3967
+ result = _e.sent();
3968
+ assertsExecutionSuccessful(result);
3969
+ outputParameters = result.outputParameters;
3970
+ titleRaw = outputParameters.title;
3971
+ if (isVerbose) {
3972
+ console.info("The title is \"".concat(titleRaw, "\""));
3973
+ }
3974
+ title = titleRaw || DEFAULT_BOOK_TITLE;
3975
+ _e.label = 3;
3976
+ case 3:
3900
3977
  preparedPersonas = new Array(personas.length);
3901
3978
  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 () {
3902
3979
  var modelRequirements, preparedPersona;
@@ -3915,12 +3992,12 @@
3915
3992
  }
3916
3993
  });
3917
3994
  }); })];
3918
- case 1:
3919
- _c.sent();
3995
+ case 4:
3996
+ _e.sent();
3920
3997
  knowledgeSourcesPrepared = knowledgeSources.map(function (source) { return (__assign(__assign({}, source), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3921
3998
  return [4 /*yield*/, prepareKnowledgePieces(knowledgeSources /* <- TODO: [🧊] {knowledgeSources, knowledgePieces} */, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), __assign(__assign({}, options), { rootDirname: rootDirname, maxParallelCount: maxParallelCount /* <- TODO: [🪂] */, isVerbose: isVerbose }))];
3922
- case 2:
3923
- partialknowledgePiecesPrepared = _c.sent();
3999
+ case 5:
4000
+ partialknowledgePiecesPrepared = _e.sent();
3924
4001
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3925
4002
  return [4 /*yield*/, prepareTasks({
3926
4003
  parameters: parameters,
@@ -3931,8 +4008,8 @@
3931
4008
  maxParallelCount: maxParallelCount /* <- TODO: [🪂] */,
3932
4009
  isVerbose: isVerbose,
3933
4010
  })];
3934
- case 3:
3935
- tasksPrepared = (_c.sent()).tasksPrepared;
4011
+ case 6:
4012
+ tasksPrepared = (_e.sent()).tasksPrepared;
3936
4013
  // ----- /Tasks preparation -----
3937
4014
  // TODO: [😂] Use here all `AsyncHighLevelAbstraction`
3938
4015
  // Note: Count total usage
@@ -3943,7 +4020,7 @@
3943
4020
  order: ORDER_OF_PIPELINE_JSON,
3944
4021
  value: __assign(__assign({}, pipeline), {
3945
4022
  // <- TODO: Probbably deeply clone the pipeline because `$exportJson` freezes the subobjects
3946
- knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
4023
+ title: title, knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
3947
4024
  // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3948
4025
  personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }),
3949
4026
  })];
@@ -3952,7 +4029,7 @@
3952
4029
  });
3953
4030
  }
3954
4031
  /**
3955
- * TODO: Write tests for `preparePipeline`
4032
+ * TODO: Write tests for `preparePipeline` and `preparePipelineOnRemoteServer`
3956
4033
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3957
4034
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
3958
4035
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
@@ -4014,7 +4091,7 @@
4014
4091
  if (!(error instanceof Error)) {
4015
4092
  throw error;
4016
4093
  }
4017
- throw new ParseError(spaceTrim.spaceTrim(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)
4094
+ throw new ParseError(spaceTrim.spaceTrim(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)
4018
4095
  .map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
4019
4096
  .join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
4020
4097
  }
@@ -4552,6 +4629,8 @@
4552
4629
  throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4553
4630
  }
4554
4631
  parameterValue = valueToString(parameterValue);
4632
+ // Escape curly braces in parameter values to prevent prompt-injection
4633
+ parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
4555
4634
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
4556
4635
  parameterValue = parameterValue
4557
4636
  .split('\n')
@@ -4911,7 +4990,7 @@
4911
4990
  promptTitle: task.title,
4912
4991
  promptMessage: templateParameters(task.description || '', parameters),
4913
4992
  defaultValue: templateParameters(preparedContent, parameters),
4914
- // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4993
+ // TODO: [🧠] Figure out how to define placeholder in .book.md file
4915
4994
  placeholder: undefined,
4916
4995
  priority: priority,
4917
4996
  }))];
@@ -5901,6 +5980,7 @@
5901
5980
  mimeTypes: ['text/markdown', 'text/plain'],
5902
5981
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
5903
5982
  isAvilableInBrowser: true,
5983
+ // <- 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
5904
5984
  requiredExecutables: [],
5905
5985
  }); /* <- Note: [🤛] */
5906
5986
  /**
@@ -5909,6 +5989,7 @@
5909
5989
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
5910
5990
  *
5911
5991
  * @public exported from `@promptbook/core`
5992
+ * @public exported from `@promptbook/wizzard`
5912
5993
  * @public exported from `@promptbook/cli`
5913
5994
  */
5914
5995
  $scrapersMetadataRegister.register(markdownScraperMetadata);
@@ -5994,12 +6075,12 @@
5994
6075
  outputParameters = result.outputParameters;
5995
6076
  knowledgePiecesRaw = outputParameters.knowledgePieces;
5996
6077
  knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
5997
- // <- TODO: [main] !! Smarter split and filter out empty pieces
6078
+ // <- TODO: [main] Smarter split and filter out empty pieces
5998
6079
  if (isVerbose) {
5999
6080
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
6000
6081
  }
6001
6082
  return [4 /*yield*/, Promise.all(
6002
- // TODO: [🪂] !! Do not send all at once but in chunks
6083
+ // TODO: [🪂] Do not send all at once but in chunks
6003
6084
  knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
6004
6085
  var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
6005
6086
  return __generator(this, function (_c) {
@@ -6104,6 +6185,7 @@
6104
6185
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6105
6186
  *
6106
6187
  * @public exported from `@promptbook/markdown-utils`
6188
+ * @public exported from `@promptbook/wizzard`
6107
6189
  * @public exported from `@promptbook/cli`
6108
6190
  */
6109
6191
  var _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownScraper);
@@ -6113,13 +6195,13 @@
6113
6195
  */
6114
6196
 
6115
6197
  /**
6116
- * Removes HTML or Markdown comments from a string.
6198
+ * Removes Markdown (or HTML) comments
6117
6199
  *
6118
6200
  * @param {string} content - The string to remove comments from.
6119
6201
  * @returns {string} The input string with all comments removed.
6120
6202
  * @public exported from `@promptbook/markdown-utils`
6121
6203
  */
6122
- function removeContentComments(content) {
6204
+ function removeMarkdownComments(content) {
6123
6205
  return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
6124
6206
  }
6125
6207
 
@@ -6138,7 +6220,7 @@
6138
6220
  return content.replace(sectionRegex, contentToInsert);
6139
6221
  }
6140
6222
  // Note: Following is the case when the section is not found in the file so we add it there
6141
- var placeForSection = removeContentComments(content).match(/^##.*$/im);
6223
+ var placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
6142
6224
  if (placeForSection !== null) {
6143
6225
  var _a = __read(placeForSection, 1), heading_1 = _a[0];
6144
6226
  return content.replace(heading_1, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(contentToInsert), "\n\n ").concat(block(heading_1), "\n "); }));
@@ -6318,7 +6400,7 @@
6318
6400
  return;
6319
6401
  }
6320
6402
  if (!section.startsWith('#')) {
6321
- section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
6403
+ section = "# ".concat(DEFAULT_BOOK_TITLE, "\n\n").concat(section);
6322
6404
  }
6323
6405
  sections.push(section);
6324
6406
  buffer = [];
@@ -6373,7 +6455,7 @@
6373
6455
  /**
6374
6456
  * Normalizes the markdown by flattening the structure
6375
6457
  *
6376
- * - It always have h1 - if there is no h1 in the markdown, it will be added "# Untitled"
6458
+ * - It always have h1 - if there is no h1 in the markdown, it will be added `DEFAULT_BOOK_TITLE`
6377
6459
  * - All other headings are normalized to h2
6378
6460
  *
6379
6461
  * @public exported from `@promptbook/markdown-utils`
@@ -6382,7 +6464,7 @@
6382
6464
  var e_1, _a;
6383
6465
  var sections = splitMarkdownIntoSections(markdown);
6384
6466
  if (sections.length === 0) {
6385
- return "# ".concat(DEFAULT_TITLE);
6467
+ return "# ".concat(DEFAULT_BOOK_TITLE);
6386
6468
  }
6387
6469
  var flattenedMarkdown = '';
6388
6470
  var parsedSections = sections.map(parseMarkdownSection);
@@ -6393,7 +6475,7 @@
6393
6475
  }
6394
6476
  else {
6395
6477
  parsedSections.unshift(firstSection);
6396
- flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
6478
+ flattenedMarkdown += "# ".concat(DEFAULT_BOOK_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
6397
6479
  }
6398
6480
  try {
6399
6481
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
@@ -6452,7 +6534,7 @@
6452
6534
  exports.extractOneBlockFromMarkdown = extractOneBlockFromMarkdown;
6453
6535
  exports.flattenMarkdown = flattenMarkdown;
6454
6536
  exports.parseMarkdownSection = parseMarkdownSection;
6455
- exports.removeContentComments = removeContentComments;
6537
+ exports.removeMarkdownComments = removeMarkdownComments;
6456
6538
  exports.removeMarkdownFormatting = removeMarkdownFormatting;
6457
6539
  exports.splitMarkdownIntoSections = splitMarkdownIntoSections;
6458
6540