@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.
- package/README.md +8 -1
- package/esm/index.es.js +179 -44
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +15 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -6
- package/esm/typings/src/_packages/editable.index.d.ts +10 -0
- package/esm/typings/src/_packages/templates.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +6 -0
- package/esm/typings/src/_packages/utils.index.d.ts +12 -2
- package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
- package/esm/typings/src/config.d.ts +26 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
- package/esm/typings/src/execution/PromptbookFetch.d.ts +5 -0
- package/esm/typings/src/execution/PromptbookFetch.test-type.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
- package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +2 -1
- package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +2 -1
- package/esm/typings/src/high-level-abstractions/index.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
- package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +19 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +10 -0
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +10 -0
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +10 -0
- package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +8 -0
- package/esm/typings/src/utils/editable/types/PipelineEditableSerialized.d.ts +27 -0
- package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.d.ts +2 -2
- package/esm/typings/src/utils/parameters/numberToString.d.ts +7 -0
- package/esm/typings/src/utils/parameters/{replaceParameters.d.ts → templateParameters.d.ts} +6 -2
- package/esm/typings/src/utils/parameters/valueToString.d.ts +17 -0
- package/esm/typings/src/utils/parameters/valueToString.test.d.ts +1 -0
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +4 -0
- package/esm/typings/src/utils/validators/filePath/isPathRoot.d.ts +12 -0
- package/esm/typings/src/utils/validators/filePath/isPathRoot.test.d.ts +4 -0
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +3 -0
- package/esm/typings/src/version.d.ts +7 -0
- package/esm/typings/src/wizzard/$getCompiledBook.d.ts +16 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +51 -0
- package/package.json +1 -1
- package/umd/index.umd.js +179 -44
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +0 -8
- package/esm/typings/src/utils/formatNumber.d.ts +0 -6
- /package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.test.d.ts +0 -0
- /package/esm/typings/src/utils/{formatNumber.test.d.ts → parameters/numberToString.test.d.ts} +0 -0
- /package/esm/typings/src/utils/parameters/{replaceParameters.test.d.ts → templateParameters.test.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
/**
|
|
15
15
|
* The version of the Book language
|
|
16
16
|
*
|
|
17
|
+
* @generated
|
|
17
18
|
* @see https://github.com/webgptorg/book
|
|
18
19
|
*/
|
|
19
20
|
var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
20
21
|
/**
|
|
21
22
|
* The version of the Promptbook engine
|
|
22
23
|
*
|
|
24
|
+
* @generated
|
|
23
25
|
* @see https://github.com/webgptorg/promptbook
|
|
24
26
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
27
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-11';
|
|
26
28
|
/**
|
|
27
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -358,7 +360,7 @@
|
|
|
358
360
|
* TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
|
|
359
361
|
*/
|
|
360
362
|
|
|
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:[],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"}];
|
|
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"}];
|
|
362
364
|
|
|
363
365
|
/**
|
|
364
366
|
* Prettify the html code
|
|
@@ -660,6 +662,26 @@
|
|
|
660
662
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
661
663
|
*/
|
|
662
664
|
var LOOP_LIMIT = 1000;
|
|
665
|
+
/**
|
|
666
|
+
* Strings to represent various values in the context of parameter values
|
|
667
|
+
*
|
|
668
|
+
* @public exported from `@promptbook/utils`
|
|
669
|
+
*/
|
|
670
|
+
var VALUE_STRINGS = {
|
|
671
|
+
empty: '(nothing; empty string)',
|
|
672
|
+
null: '(no value; null)',
|
|
673
|
+
undefined: '(unknown value; undefined)',
|
|
674
|
+
nan: '(not a number; NaN)',
|
|
675
|
+
infinity: '(infinity; ∞)',
|
|
676
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
677
|
+
unserializable: '(unserializable value)',
|
|
678
|
+
};
|
|
679
|
+
/**
|
|
680
|
+
* Small number limit
|
|
681
|
+
*
|
|
682
|
+
* @public exported from `@promptbook/utils`
|
|
683
|
+
*/
|
|
684
|
+
var SMALL_NUMBER = 0.001;
|
|
663
685
|
/**
|
|
664
686
|
* Short time interval to prevent race conditions in milliseconds
|
|
665
687
|
*
|
|
@@ -905,7 +927,7 @@
|
|
|
905
927
|
if (!(error instanceof Error)) {
|
|
906
928
|
throw error;
|
|
907
929
|
}
|
|
908
|
-
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.
|
|
930
|
+
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 "); }));
|
|
909
931
|
}
|
|
910
932
|
/*
|
|
911
933
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -1003,6 +1025,7 @@
|
|
|
1003
1025
|
* @public exported from `@promptbook/core`
|
|
1004
1026
|
*/
|
|
1005
1027
|
var ORDER_OF_PIPELINE_JSON = [
|
|
1028
|
+
// Note: [🍙] In this order will be pipeline serialized
|
|
1006
1029
|
'title',
|
|
1007
1030
|
'pipelineUrl',
|
|
1008
1031
|
'bookVersion',
|
|
@@ -1014,6 +1037,7 @@
|
|
|
1014
1037
|
'preparations',
|
|
1015
1038
|
'knowledgeSources',
|
|
1016
1039
|
'knowledgePieces',
|
|
1040
|
+
'sources', // <- TODO: [🧠] Where should the `sources` be
|
|
1017
1041
|
];
|
|
1018
1042
|
/**
|
|
1019
1043
|
* Nonce which is used for replacing things in strings
|
|
@@ -1211,9 +1235,6 @@
|
|
|
1211
1235
|
if (!url.startsWith('https://')) {
|
|
1212
1236
|
return false;
|
|
1213
1237
|
}
|
|
1214
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
1215
|
-
return false;
|
|
1216
|
-
}
|
|
1217
1238
|
if (url.includes('#')) {
|
|
1218
1239
|
// TODO: [🐠]
|
|
1219
1240
|
return false;
|
|
@@ -2007,6 +2028,81 @@
|
|
|
2007
2028
|
* - [♨] Are tasks prepared
|
|
2008
2029
|
*/
|
|
2009
2030
|
|
|
2031
|
+
/**
|
|
2032
|
+
* Format either small or big number
|
|
2033
|
+
*
|
|
2034
|
+
* @public exported from `@promptbook/utils`
|
|
2035
|
+
*/
|
|
2036
|
+
function numberToString(value) {
|
|
2037
|
+
if (value === 0) {
|
|
2038
|
+
return '0';
|
|
2039
|
+
}
|
|
2040
|
+
else if (Number.isNaN(value)) {
|
|
2041
|
+
return VALUE_STRINGS.nan;
|
|
2042
|
+
}
|
|
2043
|
+
else if (value === Infinity) {
|
|
2044
|
+
return VALUE_STRINGS.infinity;
|
|
2045
|
+
}
|
|
2046
|
+
else if (value === -Infinity) {
|
|
2047
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
2048
|
+
}
|
|
2049
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
2050
|
+
var factor = Math.pow(10, exponent);
|
|
2051
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
2052
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
2053
|
+
return valueRounded.toFixed(exponent);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
return value.toString();
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* Function `valueToString` will convert the given value to string
|
|
2061
|
+
* This is useful and used in the `templateParameters` function
|
|
2062
|
+
*
|
|
2063
|
+
* Note: This function is not just calling `toString` method
|
|
2064
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
2065
|
+
* See `VALUE_STRINGS`
|
|
2066
|
+
*
|
|
2067
|
+
* Note: There are 2 similar functions
|
|
2068
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
2069
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
2070
|
+
*
|
|
2071
|
+
* @public exported from `@promptbook/utils`
|
|
2072
|
+
*/
|
|
2073
|
+
function valueToString(value) {
|
|
2074
|
+
try {
|
|
2075
|
+
if (value === '') {
|
|
2076
|
+
return VALUE_STRINGS.empty;
|
|
2077
|
+
}
|
|
2078
|
+
else if (value === null) {
|
|
2079
|
+
return VALUE_STRINGS.null;
|
|
2080
|
+
}
|
|
2081
|
+
else if (value === undefined) {
|
|
2082
|
+
return VALUE_STRINGS.undefined;
|
|
2083
|
+
}
|
|
2084
|
+
else if (typeof value === 'string') {
|
|
2085
|
+
return value;
|
|
2086
|
+
}
|
|
2087
|
+
else if (typeof value === 'number') {
|
|
2088
|
+
return numberToString(value);
|
|
2089
|
+
}
|
|
2090
|
+
else if (value instanceof Date) {
|
|
2091
|
+
return value.toISOString();
|
|
2092
|
+
}
|
|
2093
|
+
else {
|
|
2094
|
+
return JSON.stringify(value);
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
catch (error) {
|
|
2098
|
+
if (!(error instanceof Error)) {
|
|
2099
|
+
throw error;
|
|
2100
|
+
}
|
|
2101
|
+
console.error(error);
|
|
2102
|
+
return VALUE_STRINGS.unserializable;
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2010
2106
|
/**
|
|
2011
2107
|
* Serializes an error into a [🚉] JSON-serializable object
|
|
2012
2108
|
*
|
|
@@ -3386,21 +3482,71 @@
|
|
|
3386
3482
|
if (typeof filename !== 'string') {
|
|
3387
3483
|
return false;
|
|
3388
3484
|
}
|
|
3485
|
+
if (filename.split('\n').length > 1) {
|
|
3486
|
+
return false;
|
|
3487
|
+
}
|
|
3488
|
+
if (filename.split(' ').length >
|
|
3489
|
+
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
3490
|
+
return false;
|
|
3491
|
+
}
|
|
3389
3492
|
var filenameSlashes = filename.split('\\').join('/');
|
|
3390
3493
|
// Absolute Unix path: /hello.txt
|
|
3391
3494
|
if (/^(\/)/i.test(filenameSlashes)) {
|
|
3495
|
+
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
3392
3496
|
return true;
|
|
3393
3497
|
}
|
|
3394
3498
|
// Absolute Windows path: /hello.txt
|
|
3395
3499
|
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
3500
|
+
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
3396
3501
|
return true;
|
|
3397
3502
|
}
|
|
3398
3503
|
// Relative path: ./hello.txt
|
|
3399
3504
|
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
3505
|
+
// console.log(filename, 'Relative path: ./hello.txt');
|
|
3506
|
+
return true;
|
|
3507
|
+
}
|
|
3508
|
+
// Allow paths like foo/hello
|
|
3509
|
+
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
3510
|
+
// console.log(filename, 'Allow paths like foo/hello');
|
|
3511
|
+
return true;
|
|
3512
|
+
}
|
|
3513
|
+
// Allow paths like hello.book
|
|
3514
|
+
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
3515
|
+
// console.log(filename, 'Allow paths like hello.book');
|
|
3400
3516
|
return true;
|
|
3401
3517
|
}
|
|
3402
3518
|
return false;
|
|
3403
3519
|
}
|
|
3520
|
+
/**
|
|
3521
|
+
* TODO: [🍏] Implement for MacOs
|
|
3522
|
+
*/
|
|
3523
|
+
|
|
3524
|
+
/**
|
|
3525
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
3526
|
+
*
|
|
3527
|
+
* @private as default `fetch` function used in Promptbook scrapers
|
|
3528
|
+
*/
|
|
3529
|
+
var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3530
|
+
var error_1;
|
|
3531
|
+
return __generator(this, function (_a) {
|
|
3532
|
+
switch (_a.label) {
|
|
3533
|
+
case 0:
|
|
3534
|
+
_a.trys.push([0, 2, , 3]);
|
|
3535
|
+
return [4 /*yield*/, fetch(url, init)];
|
|
3536
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3537
|
+
case 2:
|
|
3538
|
+
error_1 = _a.sent();
|
|
3539
|
+
if (!(error_1 instanceof Error)) {
|
|
3540
|
+
throw error_1;
|
|
3541
|
+
}
|
|
3542
|
+
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Can not fetch \"".concat(url, "\"\n\n Fetch error:\n ").concat(block(error_1.message), "\n\n "); }));
|
|
3543
|
+
case 3: return [2 /*return*/];
|
|
3544
|
+
}
|
|
3545
|
+
});
|
|
3546
|
+
}); };
|
|
3547
|
+
/**
|
|
3548
|
+
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
3549
|
+
*/
|
|
3404
3550
|
|
|
3405
3551
|
/**
|
|
3406
3552
|
* @@@
|
|
@@ -3410,13 +3556,14 @@
|
|
|
3410
3556
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3411
3557
|
var _a;
|
|
3412
3558
|
return __awaiter(this, void 0, void 0, function () {
|
|
3413
|
-
var sourceContent, name,
|
|
3414
|
-
return __generator(this, function (
|
|
3415
|
-
switch (
|
|
3559
|
+
var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3560
|
+
return __generator(this, function (_f) {
|
|
3561
|
+
switch (_f.label) {
|
|
3416
3562
|
case 0:
|
|
3563
|
+
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3417
3564
|
sourceContent = knowledgeSource.sourceContent;
|
|
3418
3565
|
name = knowledgeSource.name;
|
|
3419
|
-
|
|
3566
|
+
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3420
3567
|
if (!name) {
|
|
3421
3568
|
name = sourceContentToName(sourceContent);
|
|
3422
3569
|
}
|
|
@@ -3424,7 +3571,7 @@
|
|
|
3424
3571
|
url = sourceContent;
|
|
3425
3572
|
return [4 /*yield*/, fetch(url)];
|
|
3426
3573
|
case 1:
|
|
3427
|
-
response_1 =
|
|
3574
|
+
response_1 = _f.sent();
|
|
3428
3575
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
3429
3576
|
return [2 /*return*/, {
|
|
3430
3577
|
source: name,
|
|
@@ -3467,7 +3614,7 @@
|
|
|
3467
3614
|
},
|
|
3468
3615
|
}];
|
|
3469
3616
|
case 2:
|
|
3470
|
-
if (!
|
|
3617
|
+
if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
|
|
3471
3618
|
if (tools.fs === undefined) {
|
|
3472
3619
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3473
3620
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3481,8 +3628,8 @@
|
|
|
3481
3628
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3482
3629
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3483
3630
|
case 3:
|
|
3484
|
-
if (!(
|
|
3485
|
-
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 "); }));
|
|
3631
|
+
if (!(_f.sent())) {
|
|
3632
|
+
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 "); }));
|
|
3486
3633
|
}
|
|
3487
3634
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3488
3635
|
return [2 /*return*/, {
|
|
@@ -3890,7 +4037,7 @@
|
|
|
3890
4037
|
if (!(error instanceof Error)) {
|
|
3891
4038
|
throw error;
|
|
3892
4039
|
}
|
|
3893
|
-
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n
|
|
4040
|
+
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)
|
|
3894
4041
|
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
3895
4042
|
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
3896
4043
|
}
|
|
@@ -4375,13 +4522,16 @@
|
|
|
4375
4522
|
/**
|
|
4376
4523
|
* Replaces parameters in template with values from parameters object
|
|
4377
4524
|
*
|
|
4525
|
+
* Note: This function is not places strings into string,
|
|
4526
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
4527
|
+
*
|
|
4378
4528
|
* @param template the template with parameters in {curly} braces
|
|
4379
4529
|
* @param parameters the object with parameters
|
|
4380
4530
|
* @returns the template with replaced parameters
|
|
4381
4531
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
4382
4532
|
* @public exported from `@promptbook/utils`
|
|
4383
4533
|
*/
|
|
4384
|
-
function
|
|
4534
|
+
function templateParameters(template, parameters) {
|
|
4385
4535
|
var e_1, _a;
|
|
4386
4536
|
try {
|
|
4387
4537
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -4407,7 +4557,7 @@
|
|
|
4407
4557
|
var loopLimit = LOOP_LIMIT;
|
|
4408
4558
|
var _loop_1 = function () {
|
|
4409
4559
|
if (loopLimit-- < 0) {
|
|
4410
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
4560
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
4411
4561
|
}
|
|
4412
4562
|
var precol = match.groups.precol;
|
|
4413
4563
|
var parameterName = match.groups.parameterName;
|
|
@@ -4424,7 +4574,7 @@
|
|
|
4424
4574
|
if (parameterValue === undefined) {
|
|
4425
4575
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4426
4576
|
}
|
|
4427
|
-
parameterValue = parameterValue
|
|
4577
|
+
parameterValue = valueToString(parameterValue);
|
|
4428
4578
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
4429
4579
|
parameterValue = parameterValue
|
|
4430
4580
|
.split('\n')
|
|
@@ -4659,7 +4809,7 @@
|
|
|
4659
4809
|
}
|
|
4660
4810
|
return [3 /*break*/, 24];
|
|
4661
4811
|
case 2:
|
|
4662
|
-
$ongoingTaskResult.$resultString =
|
|
4812
|
+
$ongoingTaskResult.$resultString = templateParameters(preparedContent, parameters);
|
|
4663
4813
|
return [3 /*break*/, 25];
|
|
4664
4814
|
case 3:
|
|
4665
4815
|
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
@@ -4782,8 +4932,8 @@
|
|
|
4782
4932
|
_j = $ongoingTaskResult;
|
|
4783
4933
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
4784
4934
|
promptTitle: task.title,
|
|
4785
|
-
promptMessage:
|
|
4786
|
-
defaultValue:
|
|
4935
|
+
promptMessage: templateParameters(task.description || '', parameters),
|
|
4936
|
+
defaultValue: templateParameters(preparedContent, parameters),
|
|
4787
4937
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4788
4938
|
placeholder: undefined,
|
|
4789
4939
|
priority: priority,
|
|
@@ -4907,7 +5057,7 @@
|
|
|
4907
5057
|
if (!isJokerAttempt &&
|
|
4908
5058
|
task.taskType === 'PROMPT_TASK' &&
|
|
4909
5059
|
$ongoingTaskResult.$prompt
|
|
4910
|
-
// <- Note: [2] When some expected parameter is not defined, error will occur in
|
|
5060
|
+
// <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
4911
5061
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
4912
5062
|
) {
|
|
4913
5063
|
// TODO: [🧠] Maybe put other taskTypes into report
|
|
@@ -5484,7 +5634,10 @@
|
|
|
5484
5634
|
finally { if (e_2) throw e_2.error; }
|
|
5485
5635
|
return [7 /*endfinally*/];
|
|
5486
5636
|
case 19:
|
|
5487
|
-
parametersToPass = inputParameters
|
|
5637
|
+
parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
|
|
5638
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
5639
|
+
return [key, valueToString(value)];
|
|
5640
|
+
}));
|
|
5488
5641
|
_g.label = 20;
|
|
5489
5642
|
case 20:
|
|
5490
5643
|
_g.trys.push([20, 25, , 28]);
|
|
@@ -5779,6 +5932,7 @@
|
|
|
5779
5932
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
5780
5933
|
*
|
|
5781
5934
|
* @public exported from `@promptbook/core`
|
|
5935
|
+
* @public exported from `@promptbook/wizzard`
|
|
5782
5936
|
* @public exported from `@promptbook/cli`
|
|
5783
5937
|
*/
|
|
5784
5938
|
$scrapersMetadataRegister.register(markdownScraperMetadata);
|
|
@@ -5974,6 +6128,7 @@
|
|
|
5974
6128
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
5975
6129
|
*
|
|
5976
6130
|
* @public exported from `@promptbook/markdown-utils`
|
|
6131
|
+
* @public exported from `@promptbook/wizzard`
|
|
5977
6132
|
* @public exported from `@promptbook/cli`
|
|
5978
6133
|
*/
|
|
5979
6134
|
var _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownScraper);
|
|
@@ -6021,26 +6176,6 @@
|
|
|
6021
6176
|
* TODO: [🏛] This can be part of markdown builder
|
|
6022
6177
|
*/
|
|
6023
6178
|
|
|
6024
|
-
/**
|
|
6025
|
-
* Format either small or big number
|
|
6026
|
-
*
|
|
6027
|
-
* @private within the repository
|
|
6028
|
-
*/
|
|
6029
|
-
function formatNumber(value) {
|
|
6030
|
-
if (value === 0) {
|
|
6031
|
-
return '0';
|
|
6032
|
-
}
|
|
6033
|
-
for (var exponent = 0; exponent < 15; exponent++) {
|
|
6034
|
-
var factor = Math.pow(10, exponent);
|
|
6035
|
-
var valueRounded = Math.round(value * factor) / factor;
|
|
6036
|
-
if (Math.abs(value - valueRounded) / value <
|
|
6037
|
-
0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
|
|
6038
|
-
return valueRounded.toFixed(exponent);
|
|
6039
|
-
}
|
|
6040
|
-
}
|
|
6041
|
-
return value.toString();
|
|
6042
|
-
}
|
|
6043
|
-
|
|
6044
6179
|
/**
|
|
6045
6180
|
* Create a markdown table from a 2D array of strings
|
|
6046
6181
|
*
|
|
@@ -6100,7 +6235,7 @@
|
|
|
6100
6235
|
}
|
|
6101
6236
|
finally { if (e_1) throw e_1.error; }
|
|
6102
6237
|
}
|
|
6103
|
-
var legend = "_Note: Each \u2588 represents ".concat(
|
|
6238
|
+
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_");
|
|
6104
6239
|
return createMarkdownTable(table) + '\n\n' + legend;
|
|
6105
6240
|
}
|
|
6106
6241
|
/**
|