@promptbook/core 0.81.0-5 → 0.81.0-6
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/esm/index.es.js +121 -28
- 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 -0
- package/esm/typings/src/_packages/templates.index.d.ts +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +8 -0
- package/esm/typings/src/config.d.ts +26 -0
- package/esm/typings/src/high-level-abstractions/index.d.ts +10 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +12 -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/utils/editable/types/PipelineEditableSerialized.d.ts +0 -15
- package/esm/typings/src/utils/parameters/numberToString.d.ts +7 -0
- package/esm/typings/src/utils/parameters/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/package.json +1 -1
- package/umd/index.umd.js +121 -27
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/utils/formatNumber.d.ts +0 -6
- package/esm/typings/src/utils/getBookTemplate.d.ts +0 -12
- /package/esm/typings/src/utils/{formatNumber.test.d.ts → parameters/numberToString.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
26
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-5';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -509,6 +509,26 @@ var DEFAULT_TITLE = "Untitled";
|
|
|
509
509
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
510
510
|
*/
|
|
511
511
|
var LOOP_LIMIT = 1000;
|
|
512
|
+
/**
|
|
513
|
+
* Strings to represent various values in the context of parameter values
|
|
514
|
+
*
|
|
515
|
+
* @public exported from `@promptbook/utils`
|
|
516
|
+
*/
|
|
517
|
+
var VALUE_STRINGS = {
|
|
518
|
+
empty: '(nothing; empty string)',
|
|
519
|
+
null: '(no value; null)',
|
|
520
|
+
undefined: '(unknown value; undefined)',
|
|
521
|
+
nan: '(not a number; NaN)',
|
|
522
|
+
infinity: '(infinity; ∞)',
|
|
523
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
524
|
+
unserializable: '(unserializable value)',
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* Small number limit
|
|
528
|
+
*
|
|
529
|
+
* @public exported from `@promptbook/utils`
|
|
530
|
+
*/
|
|
531
|
+
var SMALL_NUMBER = 0.001;
|
|
512
532
|
/**
|
|
513
533
|
* Short time interval to prevent race conditions in milliseconds
|
|
514
534
|
*
|
|
@@ -638,6 +658,12 @@ function SET_IS_VERBOSE(isVerbose) {
|
|
|
638
658
|
* @public exported from `@promptbook/core`
|
|
639
659
|
*/
|
|
640
660
|
var DEFAULT_IS_AUTO_INSTALLED = false;
|
|
661
|
+
/**
|
|
662
|
+
* Function name for generated function via `ptbk make` to get the pipeline collection
|
|
663
|
+
*
|
|
664
|
+
* @public exported from `@promptbook/core`
|
|
665
|
+
*/
|
|
666
|
+
var DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = "getPipelineCollection";
|
|
641
667
|
/**
|
|
642
668
|
* @@@
|
|
643
669
|
*
|
|
@@ -924,6 +950,7 @@ function exportJson(options) {
|
|
|
924
950
|
* @public exported from `@promptbook/core`
|
|
925
951
|
*/
|
|
926
952
|
var ORDER_OF_PIPELINE_JSON = [
|
|
953
|
+
// Note: [🍙] In this order will be pipeline serialized
|
|
927
954
|
'title',
|
|
928
955
|
'pipelineUrl',
|
|
929
956
|
'bookVersion',
|
|
@@ -935,6 +962,7 @@ var ORDER_OF_PIPELINE_JSON = [
|
|
|
935
962
|
'preparations',
|
|
936
963
|
'knowledgeSources',
|
|
937
964
|
'knowledgePieces',
|
|
965
|
+
'sources', // <- TODO: [🧠] Where should the `sources` be
|
|
938
966
|
];
|
|
939
967
|
/**
|
|
940
968
|
* Nonce which is used for replacing things in strings
|
|
@@ -2464,7 +2492,7 @@ function joinLlmExecutionTools() {
|
|
|
2464
2492
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2465
2493
|
*/
|
|
2466
2494
|
|
|
2467
|
-
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"}];
|
|
2495
|
+
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"}];
|
|
2468
2496
|
|
|
2469
2497
|
/**
|
|
2470
2498
|
* This error indicates problems parsing the format value
|
|
@@ -3443,9 +3471,87 @@ function arrayableToArray(input) {
|
|
|
3443
3471
|
return [input];
|
|
3444
3472
|
}
|
|
3445
3473
|
|
|
3474
|
+
/**
|
|
3475
|
+
* Format either small or big number
|
|
3476
|
+
*
|
|
3477
|
+
* @public exported from `@promptbook/utils`
|
|
3478
|
+
*/
|
|
3479
|
+
function numberToString(value) {
|
|
3480
|
+
if (value === 0) {
|
|
3481
|
+
return '0';
|
|
3482
|
+
}
|
|
3483
|
+
else if (Number.isNaN(value)) {
|
|
3484
|
+
return VALUE_STRINGS.nan;
|
|
3485
|
+
}
|
|
3486
|
+
else if (value === Infinity) {
|
|
3487
|
+
return VALUE_STRINGS.infinity;
|
|
3488
|
+
}
|
|
3489
|
+
else if (value === -Infinity) {
|
|
3490
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
3491
|
+
}
|
|
3492
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
3493
|
+
var factor = Math.pow(10, exponent);
|
|
3494
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
3495
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
3496
|
+
return valueRounded.toFixed(exponent);
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
return value.toString();
|
|
3500
|
+
}
|
|
3501
|
+
|
|
3502
|
+
/**
|
|
3503
|
+
* Function `valueToString` will convert the given value to string
|
|
3504
|
+
* This is useful and used in the `templateParameters` function
|
|
3505
|
+
*
|
|
3506
|
+
* Note: This function is not just calling `toString` method
|
|
3507
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
3508
|
+
* See `VALUE_STRINGS`
|
|
3509
|
+
*
|
|
3510
|
+
* Note: There are 2 similar functions
|
|
3511
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
3512
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
3513
|
+
*
|
|
3514
|
+
* @public exported from `@promptbook/utils`
|
|
3515
|
+
*/
|
|
3516
|
+
function valueToString(value) {
|
|
3517
|
+
try {
|
|
3518
|
+
if (value === '') {
|
|
3519
|
+
return VALUE_STRINGS.empty;
|
|
3520
|
+
}
|
|
3521
|
+
else if (value === null) {
|
|
3522
|
+
return VALUE_STRINGS.null;
|
|
3523
|
+
}
|
|
3524
|
+
else if (value === undefined) {
|
|
3525
|
+
return VALUE_STRINGS.undefined;
|
|
3526
|
+
}
|
|
3527
|
+
else if (typeof value === 'string') {
|
|
3528
|
+
return value;
|
|
3529
|
+
}
|
|
3530
|
+
else if (typeof value === 'number') {
|
|
3531
|
+
return numberToString(value);
|
|
3532
|
+
}
|
|
3533
|
+
else if (value instanceof Date) {
|
|
3534
|
+
return value.toISOString();
|
|
3535
|
+
}
|
|
3536
|
+
else {
|
|
3537
|
+
return JSON.stringify(value);
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
catch (error) {
|
|
3541
|
+
if (!(error instanceof Error)) {
|
|
3542
|
+
throw error;
|
|
3543
|
+
}
|
|
3544
|
+
console.error(error);
|
|
3545
|
+
return VALUE_STRINGS.unserializable;
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
|
|
3446
3549
|
/**
|
|
3447
3550
|
* Replaces parameters in template with values from parameters object
|
|
3448
3551
|
*
|
|
3552
|
+
* Note: This function is not places strings into string,
|
|
3553
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
3554
|
+
*
|
|
3449
3555
|
* @param template the template with parameters in {curly} braces
|
|
3450
3556
|
* @param parameters the object with parameters
|
|
3451
3557
|
* @returns the template with replaced parameters
|
|
@@ -3495,7 +3601,7 @@ function templateParameters(template, parameters) {
|
|
|
3495
3601
|
if (parameterValue === undefined) {
|
|
3496
3602
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
3497
3603
|
}
|
|
3498
|
-
parameterValue = parameterValue
|
|
3604
|
+
parameterValue = valueToString(parameterValue);
|
|
3499
3605
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
3500
3606
|
parameterValue = parameterValue
|
|
3501
3607
|
.split('\n')
|
|
@@ -9001,6 +9107,14 @@ function precompilePipeline(pipelineString) {
|
|
|
9001
9107
|
knowledgePieces: [],
|
|
9002
9108
|
personas: [],
|
|
9003
9109
|
preparations: [],
|
|
9110
|
+
sources: [
|
|
9111
|
+
{
|
|
9112
|
+
type: 'BOOK',
|
|
9113
|
+
path: null,
|
|
9114
|
+
// <- TODO: !!!!!! Pass here path of the file
|
|
9115
|
+
content: pipelineString,
|
|
9116
|
+
},
|
|
9117
|
+
],
|
|
9004
9118
|
};
|
|
9005
9119
|
function getPipelineIdentification() {
|
|
9006
9120
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -9408,7 +9522,6 @@ function precompilePipeline(pipelineString) {
|
|
|
9408
9522
|
$pipelineJson.formfactorName = 'GENERIC';
|
|
9409
9523
|
}
|
|
9410
9524
|
// =============================================================
|
|
9411
|
-
// TODO: [🍙] Maybe do reorder of `$pipelineJson` here
|
|
9412
9525
|
return exportJson({
|
|
9413
9526
|
name: 'pipelineJson',
|
|
9414
9527
|
message: "Result of `precompilePipeline`",
|
|
@@ -9667,26 +9780,6 @@ function embeddingVectorToString(embeddingVector) {
|
|
|
9667
9780
|
return "[EmbeddingVector; ".concat(embeddingVector.length, " dimensions; length: ").concat(vectorLength.toFixed(2), "; ").concat(embeddingVector.slice(0, 3).join(', '), "...]");
|
|
9668
9781
|
}
|
|
9669
9782
|
|
|
9670
|
-
/**
|
|
9671
|
-
* Format either small or big number
|
|
9672
|
-
*
|
|
9673
|
-
* @private within the repository
|
|
9674
|
-
*/
|
|
9675
|
-
function formatNumber(value) {
|
|
9676
|
-
if (value === 0) {
|
|
9677
|
-
return '0';
|
|
9678
|
-
}
|
|
9679
|
-
for (var exponent = 0; exponent < 15; exponent++) {
|
|
9680
|
-
var factor = Math.pow(10, exponent);
|
|
9681
|
-
var valueRounded = Math.round(value * factor) / factor;
|
|
9682
|
-
if (Math.abs(value - valueRounded) / value <
|
|
9683
|
-
0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
|
|
9684
|
-
return valueRounded.toFixed(exponent);
|
|
9685
|
-
}
|
|
9686
|
-
}
|
|
9687
|
-
return value.toString();
|
|
9688
|
-
}
|
|
9689
|
-
|
|
9690
9783
|
/**
|
|
9691
9784
|
* Create a markdown table from a 2D array of strings
|
|
9692
9785
|
*
|
|
@@ -9746,7 +9839,7 @@ function createMarkdownChart(options) {
|
|
|
9746
9839
|
}
|
|
9747
9840
|
finally { if (e_1) throw e_1.error; }
|
|
9748
9841
|
}
|
|
9749
|
-
var legend = "_Note: Each \u2588 represents ".concat(
|
|
9842
|
+
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_");
|
|
9750
9843
|
return createMarkdownTable(table) + '\n\n' + legend;
|
|
9751
9844
|
}
|
|
9752
9845
|
/**
|
|
@@ -9865,7 +9958,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
9865
9958
|
headerList.push("COMPLETED AT ".concat(moment(completedAt).format("YYYY-MM-DD HH:mm:ss")));
|
|
9866
9959
|
headerList.push("TOTAL DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
9867
9960
|
headerList.push("TOTAL LLM DURATION ".concat(llmDuration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
9868
|
-
headerList.push("TOTAL COST $".concat(
|
|
9961
|
+
headerList.push("TOTAL COST $".concat(numberToString(cost * (1 + taxRate))) +
|
|
9869
9962
|
(executionsWithKnownCost.length === executionReportJson.promptExecutions.length
|
|
9870
9963
|
? ''
|
|
9871
9964
|
: " *(Some cost is unknown)*") +
|
|
@@ -9923,7 +10016,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
9923
10016
|
// > taskList.push(`STARTED AT ${moment(startedAt).calendar()}`);
|
|
9924
10017
|
taskList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
9925
10018
|
if (typeof ((_g = (_f = promptExecution.result) === null || _f === void 0 ? void 0 : _f.usage) === null || _g === void 0 ? void 0 : _g.price) === 'number') {
|
|
9926
|
-
taskList.push("COST $".concat(
|
|
10019
|
+
taskList.push("COST $".concat(numberToString(promptExecution.result.usage.price * (1 + taxRate))) +
|
|
9927
10020
|
(taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
|
|
9928
10021
|
}
|
|
9929
10022
|
else {
|
|
@@ -10985,5 +11078,5 @@ var PrefixStorage = /** @class */ (function () {
|
|
|
10985
11078
|
return PrefixStorage;
|
|
10986
11079
|
}());
|
|
10987
11080
|
|
|
10988
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, compilePipeline, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, precompilePipeline, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
11081
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, compilePipeline, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, precompilePipeline, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
10989
11082
|
//# sourceMappingURL=index.es.js.map
|