@promptbook/pdf 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 -23
- 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 +2 -2
- package/umd/index.umd.js +179 -23
- 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
|
|
@@ -176,7 +178,7 @@
|
|
|
176
178
|
function TODO_USE() {
|
|
177
179
|
}
|
|
178
180
|
|
|
179
|
-
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"}];
|
|
181
|
+
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"}];
|
|
180
182
|
|
|
181
183
|
/**
|
|
182
184
|
* Prettify the html code
|
|
@@ -475,6 +477,26 @@
|
|
|
475
477
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
476
478
|
*/
|
|
477
479
|
var LOOP_LIMIT = 1000;
|
|
480
|
+
/**
|
|
481
|
+
* Strings to represent various values in the context of parameter values
|
|
482
|
+
*
|
|
483
|
+
* @public exported from `@promptbook/utils`
|
|
484
|
+
*/
|
|
485
|
+
var VALUE_STRINGS = {
|
|
486
|
+
empty: '(nothing; empty string)',
|
|
487
|
+
null: '(no value; null)',
|
|
488
|
+
undefined: '(unknown value; undefined)',
|
|
489
|
+
nan: '(not a number; NaN)',
|
|
490
|
+
infinity: '(infinity; ∞)',
|
|
491
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
492
|
+
unserializable: '(unserializable value)',
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Small number limit
|
|
496
|
+
*
|
|
497
|
+
* @public exported from `@promptbook/utils`
|
|
498
|
+
*/
|
|
499
|
+
var SMALL_NUMBER = 0.001;
|
|
478
500
|
/**
|
|
479
501
|
* Short time interval to prevent race conditions in milliseconds
|
|
480
502
|
*
|
|
@@ -720,7 +742,7 @@
|
|
|
720
742
|
if (!(error instanceof Error)) {
|
|
721
743
|
throw error;
|
|
722
744
|
}
|
|
723
|
-
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.
|
|
745
|
+
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 "); }));
|
|
724
746
|
}
|
|
725
747
|
/*
|
|
726
748
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -818,6 +840,7 @@
|
|
|
818
840
|
* @public exported from `@promptbook/core`
|
|
819
841
|
*/
|
|
820
842
|
var ORDER_OF_PIPELINE_JSON = [
|
|
843
|
+
// Note: [🍙] In this order will be pipeline serialized
|
|
821
844
|
'title',
|
|
822
845
|
'pipelineUrl',
|
|
823
846
|
'bookVersion',
|
|
@@ -829,6 +852,7 @@
|
|
|
829
852
|
'preparations',
|
|
830
853
|
'knowledgeSources',
|
|
831
854
|
'knowledgePieces',
|
|
855
|
+
'sources', // <- TODO: [🧠] Where should the `sources` be
|
|
832
856
|
];
|
|
833
857
|
/**
|
|
834
858
|
* Nonce which is used for replacing things in strings
|
|
@@ -1045,9 +1069,6 @@
|
|
|
1045
1069
|
if (!url.startsWith('https://')) {
|
|
1046
1070
|
return false;
|
|
1047
1071
|
}
|
|
1048
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
1049
|
-
return false;
|
|
1050
|
-
}
|
|
1051
1072
|
if (url.includes('#')) {
|
|
1052
1073
|
// TODO: [🐠]
|
|
1053
1074
|
return false;
|
|
@@ -1825,6 +1846,81 @@
|
|
|
1825
1846
|
* - [♨] Are tasks prepared
|
|
1826
1847
|
*/
|
|
1827
1848
|
|
|
1849
|
+
/**
|
|
1850
|
+
* Format either small or big number
|
|
1851
|
+
*
|
|
1852
|
+
* @public exported from `@promptbook/utils`
|
|
1853
|
+
*/
|
|
1854
|
+
function numberToString(value) {
|
|
1855
|
+
if (value === 0) {
|
|
1856
|
+
return '0';
|
|
1857
|
+
}
|
|
1858
|
+
else if (Number.isNaN(value)) {
|
|
1859
|
+
return VALUE_STRINGS.nan;
|
|
1860
|
+
}
|
|
1861
|
+
else if (value === Infinity) {
|
|
1862
|
+
return VALUE_STRINGS.infinity;
|
|
1863
|
+
}
|
|
1864
|
+
else if (value === -Infinity) {
|
|
1865
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
1866
|
+
}
|
|
1867
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
1868
|
+
var factor = Math.pow(10, exponent);
|
|
1869
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
1870
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
1871
|
+
return valueRounded.toFixed(exponent);
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
return value.toString();
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
/**
|
|
1878
|
+
* Function `valueToString` will convert the given value to string
|
|
1879
|
+
* This is useful and used in the `templateParameters` function
|
|
1880
|
+
*
|
|
1881
|
+
* Note: This function is not just calling `toString` method
|
|
1882
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
1883
|
+
* See `VALUE_STRINGS`
|
|
1884
|
+
*
|
|
1885
|
+
* Note: There are 2 similar functions
|
|
1886
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
1887
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
1888
|
+
*
|
|
1889
|
+
* @public exported from `@promptbook/utils`
|
|
1890
|
+
*/
|
|
1891
|
+
function valueToString(value) {
|
|
1892
|
+
try {
|
|
1893
|
+
if (value === '') {
|
|
1894
|
+
return VALUE_STRINGS.empty;
|
|
1895
|
+
}
|
|
1896
|
+
else if (value === null) {
|
|
1897
|
+
return VALUE_STRINGS.null;
|
|
1898
|
+
}
|
|
1899
|
+
else if (value === undefined) {
|
|
1900
|
+
return VALUE_STRINGS.undefined;
|
|
1901
|
+
}
|
|
1902
|
+
else if (typeof value === 'string') {
|
|
1903
|
+
return value;
|
|
1904
|
+
}
|
|
1905
|
+
else if (typeof value === 'number') {
|
|
1906
|
+
return numberToString(value);
|
|
1907
|
+
}
|
|
1908
|
+
else if (value instanceof Date) {
|
|
1909
|
+
return value.toISOString();
|
|
1910
|
+
}
|
|
1911
|
+
else {
|
|
1912
|
+
return JSON.stringify(value);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
catch (error) {
|
|
1916
|
+
if (!(error instanceof Error)) {
|
|
1917
|
+
throw error;
|
|
1918
|
+
}
|
|
1919
|
+
console.error(error);
|
|
1920
|
+
return VALUE_STRINGS.unserializable;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1828
1924
|
/**
|
|
1829
1925
|
* Serializes an error into a [🚉] JSON-serializable object
|
|
1830
1926
|
*
|
|
@@ -3204,21 +3300,71 @@
|
|
|
3204
3300
|
if (typeof filename !== 'string') {
|
|
3205
3301
|
return false;
|
|
3206
3302
|
}
|
|
3303
|
+
if (filename.split('\n').length > 1) {
|
|
3304
|
+
return false;
|
|
3305
|
+
}
|
|
3306
|
+
if (filename.split(' ').length >
|
|
3307
|
+
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
3308
|
+
return false;
|
|
3309
|
+
}
|
|
3207
3310
|
var filenameSlashes = filename.split('\\').join('/');
|
|
3208
3311
|
// Absolute Unix path: /hello.txt
|
|
3209
3312
|
if (/^(\/)/i.test(filenameSlashes)) {
|
|
3313
|
+
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
3210
3314
|
return true;
|
|
3211
3315
|
}
|
|
3212
3316
|
// Absolute Windows path: /hello.txt
|
|
3213
3317
|
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
3318
|
+
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
3214
3319
|
return true;
|
|
3215
3320
|
}
|
|
3216
3321
|
// Relative path: ./hello.txt
|
|
3217
3322
|
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
3323
|
+
// console.log(filename, 'Relative path: ./hello.txt');
|
|
3324
|
+
return true;
|
|
3325
|
+
}
|
|
3326
|
+
// Allow paths like foo/hello
|
|
3327
|
+
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
3328
|
+
// console.log(filename, 'Allow paths like foo/hello');
|
|
3329
|
+
return true;
|
|
3330
|
+
}
|
|
3331
|
+
// Allow paths like hello.book
|
|
3332
|
+
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
3333
|
+
// console.log(filename, 'Allow paths like hello.book');
|
|
3218
3334
|
return true;
|
|
3219
3335
|
}
|
|
3220
3336
|
return false;
|
|
3221
3337
|
}
|
|
3338
|
+
/**
|
|
3339
|
+
* TODO: [🍏] Implement for MacOs
|
|
3340
|
+
*/
|
|
3341
|
+
|
|
3342
|
+
/**
|
|
3343
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
3344
|
+
*
|
|
3345
|
+
* @private as default `fetch` function used in Promptbook scrapers
|
|
3346
|
+
*/
|
|
3347
|
+
var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3348
|
+
var error_1;
|
|
3349
|
+
return __generator(this, function (_a) {
|
|
3350
|
+
switch (_a.label) {
|
|
3351
|
+
case 0:
|
|
3352
|
+
_a.trys.push([0, 2, , 3]);
|
|
3353
|
+
return [4 /*yield*/, fetch(url, init)];
|
|
3354
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3355
|
+
case 2:
|
|
3356
|
+
error_1 = _a.sent();
|
|
3357
|
+
if (!(error_1 instanceof Error)) {
|
|
3358
|
+
throw error_1;
|
|
3359
|
+
}
|
|
3360
|
+
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 "); }));
|
|
3361
|
+
case 3: return [2 /*return*/];
|
|
3362
|
+
}
|
|
3363
|
+
});
|
|
3364
|
+
}); };
|
|
3365
|
+
/**
|
|
3366
|
+
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
3367
|
+
*/
|
|
3222
3368
|
|
|
3223
3369
|
/**
|
|
3224
3370
|
* @@@
|
|
@@ -3228,13 +3374,14 @@
|
|
|
3228
3374
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3229
3375
|
var _a;
|
|
3230
3376
|
return __awaiter(this, void 0, void 0, function () {
|
|
3231
|
-
var sourceContent, name,
|
|
3232
|
-
return __generator(this, function (
|
|
3233
|
-
switch (
|
|
3377
|
+
var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3378
|
+
return __generator(this, function (_f) {
|
|
3379
|
+
switch (_f.label) {
|
|
3234
3380
|
case 0:
|
|
3381
|
+
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3235
3382
|
sourceContent = knowledgeSource.sourceContent;
|
|
3236
3383
|
name = knowledgeSource.name;
|
|
3237
|
-
|
|
3384
|
+
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3238
3385
|
if (!name) {
|
|
3239
3386
|
name = sourceContentToName(sourceContent);
|
|
3240
3387
|
}
|
|
@@ -3242,7 +3389,7 @@
|
|
|
3242
3389
|
url = sourceContent;
|
|
3243
3390
|
return [4 /*yield*/, fetch(url)];
|
|
3244
3391
|
case 1:
|
|
3245
|
-
response_1 =
|
|
3392
|
+
response_1 = _f.sent();
|
|
3246
3393
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
3247
3394
|
return [2 /*return*/, {
|
|
3248
3395
|
source: name,
|
|
@@ -3285,7 +3432,7 @@
|
|
|
3285
3432
|
},
|
|
3286
3433
|
}];
|
|
3287
3434
|
case 2:
|
|
3288
|
-
if (!
|
|
3435
|
+
if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
|
|
3289
3436
|
if (tools.fs === undefined) {
|
|
3290
3437
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3291
3438
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3299,8 +3446,8 @@
|
|
|
3299
3446
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3300
3447
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3301
3448
|
case 3:
|
|
3302
|
-
if (!(
|
|
3303
|
-
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 "); }));
|
|
3449
|
+
if (!(_f.sent())) {
|
|
3450
|
+
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 "); }));
|
|
3304
3451
|
}
|
|
3305
3452
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3306
3453
|
return [2 /*return*/, {
|
|
@@ -3708,7 +3855,7 @@
|
|
|
3708
3855
|
if (!(error instanceof Error)) {
|
|
3709
3856
|
throw error;
|
|
3710
3857
|
}
|
|
3711
|
-
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n
|
|
3858
|
+
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)
|
|
3712
3859
|
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
3713
3860
|
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
3714
3861
|
}
|
|
@@ -4330,13 +4477,16 @@
|
|
|
4330
4477
|
/**
|
|
4331
4478
|
* Replaces parameters in template with values from parameters object
|
|
4332
4479
|
*
|
|
4480
|
+
* Note: This function is not places strings into string,
|
|
4481
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
4482
|
+
*
|
|
4333
4483
|
* @param template the template with parameters in {curly} braces
|
|
4334
4484
|
* @param parameters the object with parameters
|
|
4335
4485
|
* @returns the template with replaced parameters
|
|
4336
4486
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
4337
4487
|
* @public exported from `@promptbook/utils`
|
|
4338
4488
|
*/
|
|
4339
|
-
function
|
|
4489
|
+
function templateParameters(template, parameters) {
|
|
4340
4490
|
var e_1, _a;
|
|
4341
4491
|
try {
|
|
4342
4492
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -4362,7 +4512,7 @@
|
|
|
4362
4512
|
var loopLimit = LOOP_LIMIT;
|
|
4363
4513
|
var _loop_1 = function () {
|
|
4364
4514
|
if (loopLimit-- < 0) {
|
|
4365
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
4515
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
4366
4516
|
}
|
|
4367
4517
|
var precol = match.groups.precol;
|
|
4368
4518
|
var parameterName = match.groups.parameterName;
|
|
@@ -4379,7 +4529,7 @@
|
|
|
4379
4529
|
if (parameterValue === undefined) {
|
|
4380
4530
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4381
4531
|
}
|
|
4382
|
-
parameterValue = parameterValue
|
|
4532
|
+
parameterValue = valueToString(parameterValue);
|
|
4383
4533
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
4384
4534
|
parameterValue = parameterValue
|
|
4385
4535
|
.split('\n')
|
|
@@ -4614,7 +4764,7 @@
|
|
|
4614
4764
|
}
|
|
4615
4765
|
return [3 /*break*/, 24];
|
|
4616
4766
|
case 2:
|
|
4617
|
-
$ongoingTaskResult.$resultString =
|
|
4767
|
+
$ongoingTaskResult.$resultString = templateParameters(preparedContent, parameters);
|
|
4618
4768
|
return [3 /*break*/, 25];
|
|
4619
4769
|
case 3:
|
|
4620
4770
|
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
@@ -4737,8 +4887,8 @@
|
|
|
4737
4887
|
_j = $ongoingTaskResult;
|
|
4738
4888
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
4739
4889
|
promptTitle: task.title,
|
|
4740
|
-
promptMessage:
|
|
4741
|
-
defaultValue:
|
|
4890
|
+
promptMessage: templateParameters(task.description || '', parameters),
|
|
4891
|
+
defaultValue: templateParameters(preparedContent, parameters),
|
|
4742
4892
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4743
4893
|
placeholder: undefined,
|
|
4744
4894
|
priority: priority,
|
|
@@ -4862,7 +5012,7 @@
|
|
|
4862
5012
|
if (!isJokerAttempt &&
|
|
4863
5013
|
task.taskType === 'PROMPT_TASK' &&
|
|
4864
5014
|
$ongoingTaskResult.$prompt
|
|
4865
|
-
// <- Note: [2] When some expected parameter is not defined, error will occur in
|
|
5015
|
+
// <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
4866
5016
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
4867
5017
|
) {
|
|
4868
5018
|
// TODO: [🧠] Maybe put other taskTypes into report
|
|
@@ -5439,7 +5589,10 @@
|
|
|
5439
5589
|
finally { if (e_2) throw e_2.error; }
|
|
5440
5590
|
return [7 /*endfinally*/];
|
|
5441
5591
|
case 19:
|
|
5442
|
-
parametersToPass = inputParameters
|
|
5592
|
+
parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
|
|
5593
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
5594
|
+
return [key, valueToString(value)];
|
|
5595
|
+
}));
|
|
5443
5596
|
_g.label = 20;
|
|
5444
5597
|
case 20:
|
|
5445
5598
|
_g.trys.push([20, 25, , 28]);
|
|
@@ -5734,6 +5887,7 @@
|
|
|
5734
5887
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
5735
5888
|
*
|
|
5736
5889
|
* @public exported from `@promptbook/core`
|
|
5890
|
+
* @public exported from `@promptbook/wizzard`
|
|
5737
5891
|
* @public exported from `@promptbook/cli`
|
|
5738
5892
|
*/
|
|
5739
5893
|
$scrapersMetadataRegister.register(markdownScraperMetadata);
|
|
@@ -5931,6 +6085,7 @@
|
|
|
5931
6085
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
5932
6086
|
*
|
|
5933
6087
|
* @public exported from `@promptbook/core`
|
|
6088
|
+
* @public exported from `@promptbook/wizzard`
|
|
5934
6089
|
* @public exported from `@promptbook/cli`
|
|
5935
6090
|
*/
|
|
5936
6091
|
$scrapersMetadataRegister.register(pdfScraperMetadata);
|
|
@@ -6015,6 +6170,7 @@
|
|
|
6015
6170
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
6016
6171
|
*
|
|
6017
6172
|
* @public exported from `@promptbook/pdf`
|
|
6173
|
+
* @public exported from `@promptbook/wizzard`
|
|
6018
6174
|
* @public exported from `@promptbook/cli`
|
|
6019
6175
|
*/
|
|
6020
6176
|
var _PdfScraperRegistration = $scrapersRegister.register(createPdfScraper);
|