@promptbook/markdown-utils 0.80.0 → 0.81.0-11
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 +7 -0
- package/esm/index.es.js +149 -40
- 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 +10 -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 +21 -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 +7 -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/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/version.d.ts +7 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +51 -0
- package/package.json +1 -1
- package/umd/index.umd.js +149 -40
- package/umd/index.umd.js.map +1 -1
- 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-10';
|
|
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
|
*
|
|
@@ -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
|
*
|
|
@@ -3402,6 +3498,30 @@
|
|
|
3402
3498
|
return false;
|
|
3403
3499
|
}
|
|
3404
3500
|
|
|
3501
|
+
/**
|
|
3502
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
3503
|
+
*
|
|
3504
|
+
* @private as default `fetch` function used in Promptbook scrapers
|
|
3505
|
+
*/
|
|
3506
|
+
var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3507
|
+
var error_1;
|
|
3508
|
+
return __generator(this, function (_a) {
|
|
3509
|
+
switch (_a.label) {
|
|
3510
|
+
case 0:
|
|
3511
|
+
_a.trys.push([0, 2, , 3]);
|
|
3512
|
+
return [4 /*yield*/, fetch(url, init)];
|
|
3513
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3514
|
+
case 2:
|
|
3515
|
+
error_1 = _a.sent();
|
|
3516
|
+
if (!(error_1 instanceof Error)) {
|
|
3517
|
+
throw error_1;
|
|
3518
|
+
}
|
|
3519
|
+
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 "); }));
|
|
3520
|
+
case 3: return [2 /*return*/];
|
|
3521
|
+
}
|
|
3522
|
+
});
|
|
3523
|
+
}); };
|
|
3524
|
+
|
|
3405
3525
|
/**
|
|
3406
3526
|
* @@@
|
|
3407
3527
|
*
|
|
@@ -3410,13 +3530,14 @@
|
|
|
3410
3530
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3411
3531
|
var _a;
|
|
3412
3532
|
return __awaiter(this, void 0, void 0, function () {
|
|
3413
|
-
var sourceContent, name,
|
|
3414
|
-
return __generator(this, function (
|
|
3415
|
-
switch (
|
|
3533
|
+
var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3534
|
+
return __generator(this, function (_f) {
|
|
3535
|
+
switch (_f.label) {
|
|
3416
3536
|
case 0:
|
|
3537
|
+
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3417
3538
|
sourceContent = knowledgeSource.sourceContent;
|
|
3418
3539
|
name = knowledgeSource.name;
|
|
3419
|
-
|
|
3540
|
+
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3420
3541
|
if (!name) {
|
|
3421
3542
|
name = sourceContentToName(sourceContent);
|
|
3422
3543
|
}
|
|
@@ -3424,7 +3545,7 @@
|
|
|
3424
3545
|
url = sourceContent;
|
|
3425
3546
|
return [4 /*yield*/, fetch(url)];
|
|
3426
3547
|
case 1:
|
|
3427
|
-
response_1 =
|
|
3548
|
+
response_1 = _f.sent();
|
|
3428
3549
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
3429
3550
|
return [2 /*return*/, {
|
|
3430
3551
|
source: name,
|
|
@@ -3481,7 +3602,7 @@
|
|
|
3481
3602
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3482
3603
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3483
3604
|
case 3:
|
|
3484
|
-
if (!(
|
|
3605
|
+
if (!(_f.sent())) {
|
|
3485
3606
|
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 "); }));
|
|
3486
3607
|
}
|
|
3487
3608
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -4375,13 +4496,16 @@
|
|
|
4375
4496
|
/**
|
|
4376
4497
|
* Replaces parameters in template with values from parameters object
|
|
4377
4498
|
*
|
|
4499
|
+
* Note: This function is not places strings into string,
|
|
4500
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
4501
|
+
*
|
|
4378
4502
|
* @param template the template with parameters in {curly} braces
|
|
4379
4503
|
* @param parameters the object with parameters
|
|
4380
4504
|
* @returns the template with replaced parameters
|
|
4381
4505
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
4382
4506
|
* @public exported from `@promptbook/utils`
|
|
4383
4507
|
*/
|
|
4384
|
-
function
|
|
4508
|
+
function templateParameters(template, parameters) {
|
|
4385
4509
|
var e_1, _a;
|
|
4386
4510
|
try {
|
|
4387
4511
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -4407,7 +4531,7 @@
|
|
|
4407
4531
|
var loopLimit = LOOP_LIMIT;
|
|
4408
4532
|
var _loop_1 = function () {
|
|
4409
4533
|
if (loopLimit-- < 0) {
|
|
4410
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
4534
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
4411
4535
|
}
|
|
4412
4536
|
var precol = match.groups.precol;
|
|
4413
4537
|
var parameterName = match.groups.parameterName;
|
|
@@ -4424,7 +4548,7 @@
|
|
|
4424
4548
|
if (parameterValue === undefined) {
|
|
4425
4549
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4426
4550
|
}
|
|
4427
|
-
parameterValue = parameterValue
|
|
4551
|
+
parameterValue = valueToString(parameterValue);
|
|
4428
4552
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
4429
4553
|
parameterValue = parameterValue
|
|
4430
4554
|
.split('\n')
|
|
@@ -4659,7 +4783,7 @@
|
|
|
4659
4783
|
}
|
|
4660
4784
|
return [3 /*break*/, 24];
|
|
4661
4785
|
case 2:
|
|
4662
|
-
$ongoingTaskResult.$resultString =
|
|
4786
|
+
$ongoingTaskResult.$resultString = templateParameters(preparedContent, parameters);
|
|
4663
4787
|
return [3 /*break*/, 25];
|
|
4664
4788
|
case 3:
|
|
4665
4789
|
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
@@ -4782,8 +4906,8 @@
|
|
|
4782
4906
|
_j = $ongoingTaskResult;
|
|
4783
4907
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
4784
4908
|
promptTitle: task.title,
|
|
4785
|
-
promptMessage:
|
|
4786
|
-
defaultValue:
|
|
4909
|
+
promptMessage: templateParameters(task.description || '', parameters),
|
|
4910
|
+
defaultValue: templateParameters(preparedContent, parameters),
|
|
4787
4911
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4788
4912
|
placeholder: undefined,
|
|
4789
4913
|
priority: priority,
|
|
@@ -4907,7 +5031,7 @@
|
|
|
4907
5031
|
if (!isJokerAttempt &&
|
|
4908
5032
|
task.taskType === 'PROMPT_TASK' &&
|
|
4909
5033
|
$ongoingTaskResult.$prompt
|
|
4910
|
-
// <- Note: [2] When some expected parameter is not defined, error will occur in
|
|
5034
|
+
// <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
4911
5035
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
4912
5036
|
) {
|
|
4913
5037
|
// TODO: [🧠] Maybe put other taskTypes into report
|
|
@@ -5484,7 +5608,10 @@
|
|
|
5484
5608
|
finally { if (e_2) throw e_2.error; }
|
|
5485
5609
|
return [7 /*endfinally*/];
|
|
5486
5610
|
case 19:
|
|
5487
|
-
parametersToPass = inputParameters
|
|
5611
|
+
parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
|
|
5612
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
5613
|
+
return [key, valueToString(value)];
|
|
5614
|
+
}));
|
|
5488
5615
|
_g.label = 20;
|
|
5489
5616
|
case 20:
|
|
5490
5617
|
_g.trys.push([20, 25, , 28]);
|
|
@@ -5779,6 +5906,7 @@
|
|
|
5779
5906
|
* 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
5907
|
*
|
|
5781
5908
|
* @public exported from `@promptbook/core`
|
|
5909
|
+
* @public exported from `@promptbook/wizzard`
|
|
5782
5910
|
* @public exported from `@promptbook/cli`
|
|
5783
5911
|
*/
|
|
5784
5912
|
$scrapersMetadataRegister.register(markdownScraperMetadata);
|
|
@@ -5974,6 +6102,7 @@
|
|
|
5974
6102
|
* 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
6103
|
*
|
|
5976
6104
|
* @public exported from `@promptbook/markdown-utils`
|
|
6105
|
+
* @public exported from `@promptbook/wizzard`
|
|
5977
6106
|
* @public exported from `@promptbook/cli`
|
|
5978
6107
|
*/
|
|
5979
6108
|
var _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownScraper);
|
|
@@ -6021,26 +6150,6 @@
|
|
|
6021
6150
|
* TODO: [🏛] This can be part of markdown builder
|
|
6022
6151
|
*/
|
|
6023
6152
|
|
|
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
6153
|
/**
|
|
6045
6154
|
* Create a markdown table from a 2D array of strings
|
|
6046
6155
|
*
|
|
@@ -6100,7 +6209,7 @@
|
|
|
6100
6209
|
}
|
|
6101
6210
|
finally { if (e_1) throw e_1.error; }
|
|
6102
6211
|
}
|
|
6103
|
-
var legend = "_Note: Each \u2588 represents ".concat(
|
|
6212
|
+
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
6213
|
return createMarkdownTable(table) + '\n\n' + legend;
|
|
6105
6214
|
}
|
|
6106
6215
|
/**
|