@promptbook/markdown-utils 0.80.0 → 0.81.0-12

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 (70) hide show
  1. package/README.md +8 -1
  2. package/esm/index.es.js +179 -44
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +15 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +2 -6
  6. package/esm/typings/src/_packages/editable.index.d.ts +10 -0
  7. package/esm/typings/src/_packages/templates.index.d.ts +4 -0
  8. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  9. package/esm/typings/src/_packages/utils.index.d.ts +12 -2
  10. package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
  11. package/esm/typings/src/config.d.ts +26 -0
  12. package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
  13. package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
  14. package/esm/typings/src/execution/PromptbookFetch.d.ts +5 -0
  15. package/esm/typings/src/execution/PromptbookFetch.test-type.d.ts +5 -0
  16. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
  17. package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +2 -1
  18. package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +2 -1
  19. package/esm/typings/src/high-level-abstractions/index.d.ts +10 -0
  20. package/esm/typings/src/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
  21. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
  22. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
  23. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
  24. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
  25. package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
  26. package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
  27. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
  28. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
  29. package/esm/typings/src/other/templates/getBookTemplate.d.ts +19 -0
  30. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +10 -0
  31. package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +10 -0
  32. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  33. package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +10 -0
  34. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
  35. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
  36. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
  37. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
  38. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
  39. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
  40. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
  41. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -0
  42. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
  43. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
  44. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -0
  45. package/esm/typings/src/types/typeAliases.d.ts +8 -0
  46. package/esm/typings/src/utils/editable/types/PipelineEditableSerialized.d.ts +27 -0
  47. package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.d.ts +3 -3
  48. package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.d.ts +3 -3
  49. package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.d.ts +2 -2
  50. package/esm/typings/src/utils/parameters/numberToString.d.ts +7 -0
  51. package/esm/typings/src/utils/parameters/{replaceParameters.d.ts → templateParameters.d.ts} +6 -2
  52. package/esm/typings/src/utils/parameters/valueToString.d.ts +17 -0
  53. package/esm/typings/src/utils/parameters/valueToString.test.d.ts +1 -0
  54. package/esm/typings/src/utils/serialization/asSerializable.d.ts +4 -0
  55. package/esm/typings/src/utils/validators/filePath/isPathRoot.d.ts +12 -0
  56. package/esm/typings/src/utils/validators/filePath/isPathRoot.test.d.ts +4 -0
  57. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +3 -0
  58. package/esm/typings/src/version.d.ts +7 -0
  59. package/esm/typings/src/wizzard/$getCompiledBook.d.ts +16 -0
  60. package/esm/typings/src/wizzard/wizzard.d.ts +51 -0
  61. package/package.json +1 -1
  62. package/umd/index.umd.js +179 -44
  63. package/umd/index.umd.js.map +1 -1
  64. package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +0 -8
  65. package/esm/typings/src/utils/formatNumber.d.ts +0 -6
  66. /package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.test.d.ts +0 -0
  67. /package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.test.d.ts +0 -0
  68. /package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.test.d.ts +0 -0
  69. /package/esm/typings/src/utils/{formatNumber.test.d.ts → parameters/numberToString.test.d.ts} +0 -0
  70. /package/esm/typings/src/utils/parameters/{replaceParameters.test.d.ts → templateParameters.test.d.ts} +0 -0
package/README.md CHANGED
@@ -23,6 +23,10 @@
23
23
 
24
24
 
25
25
 
26
+ <blockquote style="color: #ff8811">
27
+ <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
28
+ </blockquote>
29
+
26
30
  ## 📦 Package `@promptbook/markdown-utils`
27
31
 
28
32
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -227,6 +231,7 @@ Or you can install them separately:
227
231
 
228
232
  - ⭐ **[ptbk](https://www.npmjs.com/package/ptbk)** - Bundle of all packages, when you want to install everything and you don't care about the size
229
233
  - **[promptbook](https://www.npmjs.com/package/promptbook)** - Same as `ptbk`
234
+ - ⭐🧙‍♂️ **[@promptbook/wizzard](https://www.npmjs.com/package/@promptbook/wizzard)** - Wizzard to just run the books in node without any struggle
230
235
  - **[@promptbook/core](https://www.npmjs.com/package/@promptbook/core)** - Core of the library, it contains the main logic for promptbooks
231
236
  - **[@promptbook/node](https://www.npmjs.com/package/@promptbook/node)** - Core of the library for Node.js environment
232
237
  - **[@promptbook/browser](https://www.npmjs.com/package/@promptbook/browser)** - Core of the library for browser environment
@@ -247,8 +252,10 @@ Or you can install them separately:
247
252
  - **[@promptbook/documents](https://www.npmjs.com/package/@promptbook/documents)** - Read knowledge from documents like `.docx`, `.odt`,…
248
253
  - **[@promptbook/legacy-documents](https://www.npmjs.com/package/@promptbook/legacy-documents)** - Read knowledge from legacy documents like `.doc`, `.rtf`,…
249
254
  - **[@promptbook/website-crawler](https://www.npmjs.com/package/@promptbook/website-crawler)** - Crawl knowledge from the web
255
+ - **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
256
+ - **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Usefull templates and examples of books which can be used as a starting point
250
257
  - **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
251
- - **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
258
+ - **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
252
259
 
253
260
 
254
261
 
package/esm/index.es.js CHANGED
@@ -12,15 +12,17 @@ import { unparse, parse } from 'papaparse';
12
12
  /**
13
13
  * The version of the Book language
14
14
  *
15
+ * @generated
15
16
  * @see https://github.com/webgptorg/book
16
17
  */
17
18
  var BOOK_LANGUAGE_VERSION = '1.0.0';
18
19
  /**
19
20
  * The version of the Promptbook engine
20
21
  *
22
+ * @generated
21
23
  * @see https://github.com/webgptorg/promptbook
22
24
  */
23
- var PROMPTBOOK_ENGINE_VERSION = '0.80.0-1';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-11';
24
26
  /**
25
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -356,7 +358,7 @@ function extractJsonBlock(markdown) {
356
358
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
357
359
  */
358
360
 
359
- 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:[],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:[],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:[],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:[],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 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"}];
360
362
 
361
363
  /**
362
364
  * Prettify the html code
@@ -658,6 +660,26 @@ var DEFAULT_TITLE = "Untitled";
658
660
  * @private within the repository - too low-level in comparison with other `MAX_...`
659
661
  */
660
662
  var LOOP_LIMIT = 1000;
663
+ /**
664
+ * Strings to represent various values in the context of parameter values
665
+ *
666
+ * @public exported from `@promptbook/utils`
667
+ */
668
+ var VALUE_STRINGS = {
669
+ empty: '(nothing; empty string)',
670
+ null: '(no value; null)',
671
+ undefined: '(unknown value; undefined)',
672
+ nan: '(not a number; NaN)',
673
+ infinity: '(infinity; ∞)',
674
+ negativeInfinity: '(negative infinity; -∞)',
675
+ unserializable: '(unserializable value)',
676
+ };
677
+ /**
678
+ * Small number limit
679
+ *
680
+ * @public exported from `@promptbook/utils`
681
+ */
682
+ var SMALL_NUMBER = 0.001;
661
683
  /**
662
684
  * Short time interval to prevent race conditions in milliseconds
663
685
  *
@@ -903,7 +925,7 @@ function checkSerializableAsJson(options) {
903
925
  if (!(error instanceof Error)) {
904
926
  throw error;
905
927
  }
906
- 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 "); }));
928
+ 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 "); }));
907
929
  }
908
930
  /*
909
931
  TODO: [0] Is there some more elegant way to check circular references?
@@ -1001,6 +1023,7 @@ function exportJson(options) {
1001
1023
  * @public exported from `@promptbook/core`
1002
1024
  */
1003
1025
  var ORDER_OF_PIPELINE_JSON = [
1026
+ // Note: [🍙] In this order will be pipeline serialized
1004
1027
  'title',
1005
1028
  'pipelineUrl',
1006
1029
  'bookVersion',
@@ -1012,6 +1035,7 @@ var ORDER_OF_PIPELINE_JSON = [
1012
1035
  'preparations',
1013
1036
  'knowledgeSources',
1014
1037
  'knowledgePieces',
1038
+ 'sources', // <- TODO: [🧠] Where should the `sources` be
1015
1039
  ];
1016
1040
  /**
1017
1041
  * Nonce which is used for replacing things in strings
@@ -1209,9 +1233,6 @@ function isValidPipelineUrl(url) {
1209
1233
  if (!url.startsWith('https://')) {
1210
1234
  return false;
1211
1235
  }
1212
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
1213
- return false;
1214
- }
1215
1236
  if (url.includes('#')) {
1216
1237
  // TODO: [🐠]
1217
1238
  return false;
@@ -2005,6 +2026,81 @@ function isPipelinePrepared(pipeline) {
2005
2026
  * - [♨] Are tasks prepared
2006
2027
  */
2007
2028
 
2029
+ /**
2030
+ * Format either small or big number
2031
+ *
2032
+ * @public exported from `@promptbook/utils`
2033
+ */
2034
+ function numberToString(value) {
2035
+ if (value === 0) {
2036
+ return '0';
2037
+ }
2038
+ else if (Number.isNaN(value)) {
2039
+ return VALUE_STRINGS.nan;
2040
+ }
2041
+ else if (value === Infinity) {
2042
+ return VALUE_STRINGS.infinity;
2043
+ }
2044
+ else if (value === -Infinity) {
2045
+ return VALUE_STRINGS.negativeInfinity;
2046
+ }
2047
+ for (var exponent = 0; exponent < 15; exponent++) {
2048
+ var factor = Math.pow(10, exponent);
2049
+ var valueRounded = Math.round(value * factor) / factor;
2050
+ if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
2051
+ return valueRounded.toFixed(exponent);
2052
+ }
2053
+ }
2054
+ return value.toString();
2055
+ }
2056
+
2057
+ /**
2058
+ * Function `valueToString` will convert the given value to string
2059
+ * This is useful and used in the `templateParameters` function
2060
+ *
2061
+ * Note: This function is not just calling `toString` method
2062
+ * It's more complex and can handle this conversion specifically for LLM models
2063
+ * See `VALUE_STRINGS`
2064
+ *
2065
+ * Note: There are 2 similar functions
2066
+ * - `valueToString` converts value to string for LLM models as human-readable string
2067
+ * - `asSerializable` converts value to string to preserve full information to be able to convert it back
2068
+ *
2069
+ * @public exported from `@promptbook/utils`
2070
+ */
2071
+ function valueToString(value) {
2072
+ try {
2073
+ if (value === '') {
2074
+ return VALUE_STRINGS.empty;
2075
+ }
2076
+ else if (value === null) {
2077
+ return VALUE_STRINGS.null;
2078
+ }
2079
+ else if (value === undefined) {
2080
+ return VALUE_STRINGS.undefined;
2081
+ }
2082
+ else if (typeof value === 'string') {
2083
+ return value;
2084
+ }
2085
+ else if (typeof value === 'number') {
2086
+ return numberToString(value);
2087
+ }
2088
+ else if (value instanceof Date) {
2089
+ return value.toISOString();
2090
+ }
2091
+ else {
2092
+ return JSON.stringify(value);
2093
+ }
2094
+ }
2095
+ catch (error) {
2096
+ if (!(error instanceof Error)) {
2097
+ throw error;
2098
+ }
2099
+ console.error(error);
2100
+ return VALUE_STRINGS.unserializable;
2101
+ }
2102
+ }
2103
+
2008
2104
  /**
2009
2105
  * Serializes an error into a [🚉] JSON-serializable object
2010
2106
  *
@@ -3384,21 +3480,71 @@ function isValidFilePath(filename) {
3384
3480
  if (typeof filename !== 'string') {
3385
3481
  return false;
3386
3482
  }
3483
+ if (filename.split('\n').length > 1) {
3484
+ return false;
3485
+ }
3486
+ if (filename.split(' ').length >
3487
+ 5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
3488
+ return false;
3489
+ }
3387
3490
  var filenameSlashes = filename.split('\\').join('/');
3388
3491
  // Absolute Unix path: /hello.txt
3389
3492
  if (/^(\/)/i.test(filenameSlashes)) {
3493
+ // console.log(filename, 'Absolute Unix path: /hello.txt');
3390
3494
  return true;
3391
3495
  }
3392
3496
  // Absolute Windows path: /hello.txt
3393
3497
  if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
3498
+ // console.log(filename, 'Absolute Windows path: /hello.txt');
3394
3499
  return true;
3395
3500
  }
3396
3501
  // Relative path: ./hello.txt
3397
3502
  if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
3503
+ // console.log(filename, 'Relative path: ./hello.txt');
3504
+ return true;
3505
+ }
3506
+ // Allow paths like foo/hello
3507
+ if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
3508
+ // console.log(filename, 'Allow paths like foo/hello');
3509
+ return true;
3510
+ }
3511
+ // Allow paths like hello.book
3512
+ if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
3513
+ // console.log(filename, 'Allow paths like hello.book');
3398
3514
  return true;
3399
3515
  }
3400
3516
  return false;
3401
3517
  }
3518
+ /**
3519
+ * TODO: [🍏] Implement for MacOs
3520
+ */
3521
+
3522
+ /**
3523
+ * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
3524
+ *
3525
+ * @private as default `fetch` function used in Promptbook scrapers
3526
+ */
3527
+ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void 0, function () {
3528
+ var error_1;
3529
+ return __generator(this, function (_a) {
3530
+ switch (_a.label) {
3531
+ case 0:
3532
+ _a.trys.push([0, 2, , 3]);
3533
+ return [4 /*yield*/, fetch(url, init)];
3534
+ case 1: return [2 /*return*/, _a.sent()];
3535
+ case 2:
3536
+ error_1 = _a.sent();
3537
+ if (!(error_1 instanceof Error)) {
3538
+ throw error_1;
3539
+ }
3540
+ throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Can not fetch \"".concat(url, "\"\n\n Fetch error:\n ").concat(block(error_1.message), "\n\n "); }));
3541
+ case 3: return [2 /*return*/];
3542
+ }
3543
+ });
3544
+ }); };
3545
+ /**
3546
+ * TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
3547
+ */
3402
3548
 
3403
3549
  /**
3404
3550
  * @@@
@@ -3408,13 +3554,14 @@ function isValidFilePath(filename) {
3408
3554
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3409
3555
  var _a;
3410
3556
  return __awaiter(this, void 0, void 0, function () {
3411
- var sourceContent, name, _b, _c, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3412
- return __generator(this, function (_e) {
3413
- switch (_e.label) {
3557
+ var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3558
+ return __generator(this, function (_f) {
3559
+ switch (_f.label) {
3414
3560
  case 0:
3561
+ _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3415
3562
  sourceContent = knowledgeSource.sourceContent;
3416
3563
  name = knowledgeSource.name;
3417
- _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _b.isVerbose;
3564
+ _c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
3418
3565
  if (!name) {
3419
3566
  name = sourceContentToName(sourceContent);
3420
3567
  }
@@ -3422,7 +3569,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3422
3569
  url = sourceContent;
3423
3570
  return [4 /*yield*/, fetch(url)];
3424
3571
  case 1:
3425
- response_1 = _e.sent();
3572
+ response_1 = _f.sent();
3426
3573
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
3427
3574
  return [2 /*return*/, {
3428
3575
  source: name,
@@ -3465,7 +3612,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3465
3612
  },
3466
3613
  }];
3467
3614
  case 2:
3468
- if (!(isValidFilePath(sourceContent) || /\.[a-z]{1,10}$/i.exec(sourceContent))) return [3 /*break*/, 4];
3615
+ if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
3469
3616
  if (tools.fs === undefined) {
3470
3617
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
3471
3618
  // <- TODO: [🧠] What is the best error type here`
@@ -3479,8 +3626,8 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3479
3626
  mimeType = extensionToMimeType(fileExtension || '');
3480
3627
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3481
3628
  case 3:
3482
- if (!(_e.sent())) {
3483
- 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 "); }));
3629
+ if (!(_f.sent())) {
3630
+ 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 "); }));
3484
3631
  }
3485
3632
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
3486
3633
  return [2 /*return*/, {
@@ -3888,7 +4035,7 @@ function extractVariablesFromScript(script) {
3888
4035
  if (!(error instanceof Error)) {
3889
4036
  throw error;
3890
4037
  }
3891
- 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)
4038
+ 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)
3892
4039
  .map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
3893
4040
  .join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
3894
4041
  }
@@ -4373,13 +4520,16 @@ function mapAvailableToExpectedParameters(options) {
4373
4520
  /**
4374
4521
  * Replaces parameters in template with values from parameters object
4375
4522
  *
4523
+ * Note: This function is not places strings into string,
4524
+ * It's more complex and can handle this operation specifically for LLM models
4525
+ *
4376
4526
  * @param template the template with parameters in {curly} braces
4377
4527
  * @param parameters the object with parameters
4378
4528
  * @returns the template with replaced parameters
4379
4529
  * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
4380
4530
  * @public exported from `@promptbook/utils`
4381
4531
  */
4382
- function replaceParameters(template, parameters) {
4532
+ function templateParameters(template, parameters) {
4383
4533
  var e_1, _a;
4384
4534
  try {
4385
4535
  for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -4405,7 +4555,7 @@ function replaceParameters(template, parameters) {
4405
4555
  var loopLimit = LOOP_LIMIT;
4406
4556
  var _loop_1 = function () {
4407
4557
  if (loopLimit-- < 0) {
4408
- throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
4558
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
4409
4559
  }
4410
4560
  var precol = match.groups.precol;
4411
4561
  var parameterName = match.groups.parameterName;
@@ -4422,7 +4572,7 @@ function replaceParameters(template, parameters) {
4422
4572
  if (parameterValue === undefined) {
4423
4573
  throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4424
4574
  }
4425
- parameterValue = parameterValue.toString();
4575
+ parameterValue = valueToString(parameterValue);
4426
4576
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
4427
4577
  parameterValue = parameterValue
4428
4578
  .split('\n')
@@ -4657,7 +4807,7 @@ function executeAttempts(options) {
4657
4807
  }
4658
4808
  return [3 /*break*/, 24];
4659
4809
  case 2:
4660
- $ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
4810
+ $ongoingTaskResult.$resultString = templateParameters(preparedContent, parameters);
4661
4811
  return [3 /*break*/, 25];
4662
4812
  case 3:
4663
4813
  modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
@@ -4780,8 +4930,8 @@ function executeAttempts(options) {
4780
4930
  _j = $ongoingTaskResult;
4781
4931
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
4782
4932
  promptTitle: task.title,
4783
- promptMessage: replaceParameters(task.description || '', parameters),
4784
- defaultValue: replaceParameters(preparedContent, parameters),
4933
+ promptMessage: templateParameters(task.description || '', parameters),
4934
+ defaultValue: templateParameters(preparedContent, parameters),
4785
4935
  // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4786
4936
  placeholder: undefined,
4787
4937
  priority: priority,
@@ -4905,7 +5055,7 @@ function executeAttempts(options) {
4905
5055
  if (!isJokerAttempt &&
4906
5056
  task.taskType === 'PROMPT_TASK' &&
4907
5057
  $ongoingTaskResult.$prompt
4908
- // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
5058
+ // <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
4909
5059
  // In that case we don’t want to make a report about it because it’s not a llm execution error
4910
5060
  ) {
4911
5061
  // TODO: [🧠] Maybe put other taskTypes into report
@@ -5482,7 +5632,10 @@ function executePipeline(options) {
5482
5632
  finally { if (e_2) throw e_2.error; }
5483
5633
  return [7 /*endfinally*/];
5484
5634
  case 19:
5485
- parametersToPass = inputParameters;
5635
+ parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
5636
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
5637
+ return [key, valueToString(value)];
5638
+ }));
5486
5639
  _g.label = 20;
5487
5640
  case 20:
5488
5641
  _g.trys.push([20, 25, , 28]);
@@ -5777,6 +5930,7 @@ var markdownScraperMetadata = $deepFreeze({
5777
5930
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
5778
5931
  *
5779
5932
  * @public exported from `@promptbook/core`
5933
+ * @public exported from `@promptbook/wizzard`
5780
5934
  * @public exported from `@promptbook/cli`
5781
5935
  */
5782
5936
  $scrapersMetadataRegister.register(markdownScraperMetadata);
@@ -5972,6 +6126,7 @@ var createMarkdownScraper = Object.assign(function (tools, options) {
5972
6126
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
5973
6127
  *
5974
6128
  * @public exported from `@promptbook/markdown-utils`
6129
+ * @public exported from `@promptbook/wizzard`
5975
6130
  * @public exported from `@promptbook/cli`
5976
6131
  */
5977
6132
  var _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownScraper);
@@ -6019,26 +6174,6 @@ function addAutoGeneratedSection(content, options) {
6019
6174
  * TODO: [🏛] This can be part of markdown builder
6020
6175
  */
6021
6176
 
6022
- /**
6023
- * Format either small or big number
6024
- *
6025
- * @private within the repository
6026
- */
6027
- function formatNumber(value) {
6028
- if (value === 0) {
6029
- return '0';
6030
- }
6031
- for (var exponent = 0; exponent < 15; exponent++) {
6032
- var factor = Math.pow(10, exponent);
6033
- var valueRounded = Math.round(value * factor) / factor;
6034
- if (Math.abs(value - valueRounded) / value <
6035
- 0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
6036
- return valueRounded.toFixed(exponent);
6037
- }
6038
- }
6039
- return value.toString();
6040
- }
6041
-
6042
6177
  /**
6043
6178
  * Create a markdown table from a 2D array of strings
6044
6179
  *
@@ -6098,7 +6233,7 @@ function createMarkdownChart(options) {
6098
6233
  }
6099
6234
  finally { if (e_1) throw e_1.error; }
6100
6235
  }
6101
- var legend = "_Note: Each \u2588 represents ".concat(formatNumber(1 / scale), " ").concat(unitName, ", width of ").concat(valueHeader.toLowerCase(), " is ").concat(formatNumber(to - from), " ").concat(unitName, " = ").concat(width, " squares_");
6236
+ var legend = "_Note: Each \u2588 represents ".concat(numberToString(1 / scale), " ").concat(unitName, ", width of ").concat(valueHeader.toLowerCase(), " is ").concat(numberToString(to - from), " ").concat(unitName, " = ").concat(width, " squares_");
6102
6237
  return createMarkdownTable(table) + '\n\n' + legend;
6103
6238
  }
6104
6239
  /**