@promptbook/cli 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 +184 -80
- 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 +184 -80
- 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
|
@@ -37,7 +37,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
37
37
|
*
|
|
38
38
|
* @see https://github.com/webgptorg/promptbook
|
|
39
39
|
*/
|
|
40
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
40
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-5';
|
|
41
41
|
/**
|
|
42
42
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
43
43
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -235,6 +235,26 @@ var GENERATOR_WARNING_BY_PROMPTBOOK_CLI = "\u26A0\uFE0F WARNING: This code has b
|
|
|
235
235
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
236
236
|
*/
|
|
237
237
|
var LOOP_LIMIT = 1000;
|
|
238
|
+
/**
|
|
239
|
+
* Strings to represent various values in the context of parameter values
|
|
240
|
+
*
|
|
241
|
+
* @public exported from `@promptbook/utils`
|
|
242
|
+
*/
|
|
243
|
+
var VALUE_STRINGS = {
|
|
244
|
+
empty: '(nothing; empty string)',
|
|
245
|
+
null: '(no value; null)',
|
|
246
|
+
undefined: '(unknown value; undefined)',
|
|
247
|
+
nan: '(not a number; NaN)',
|
|
248
|
+
infinity: '(infinity; ∞)',
|
|
249
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
250
|
+
unserializable: '(unserializable value)',
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Small number limit
|
|
254
|
+
*
|
|
255
|
+
* @public exported from `@promptbook/utils`
|
|
256
|
+
*/
|
|
257
|
+
var SMALL_NUMBER = 0.001;
|
|
238
258
|
/**
|
|
239
259
|
* Timeout for the connections in milliseconds
|
|
240
260
|
*
|
|
@@ -353,6 +373,12 @@ var DEFAULT_IS_VERBOSE = false;
|
|
|
353
373
|
* @public exported from `@promptbook/core`
|
|
354
374
|
*/
|
|
355
375
|
var DEFAULT_IS_AUTO_INSTALLED = false;
|
|
376
|
+
/**
|
|
377
|
+
* Function name for generated function via `ptbk make` to get the pipeline collection
|
|
378
|
+
*
|
|
379
|
+
* @public exported from `@promptbook/core`
|
|
380
|
+
*/
|
|
381
|
+
var DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = "getPipelineCollection";
|
|
356
382
|
/**
|
|
357
383
|
* @@@
|
|
358
384
|
*
|
|
@@ -760,6 +786,7 @@ function exportJson(options) {
|
|
|
760
786
|
* @public exported from `@promptbook/core`
|
|
761
787
|
*/
|
|
762
788
|
var ORDER_OF_PIPELINE_JSON = [
|
|
789
|
+
// Note: [🍙] In this order will be pipeline serialized
|
|
763
790
|
'title',
|
|
764
791
|
'pipelineUrl',
|
|
765
792
|
'bookVersion',
|
|
@@ -771,6 +798,7 @@ var ORDER_OF_PIPELINE_JSON = [
|
|
|
771
798
|
'preparations',
|
|
772
799
|
'knowledgeSources',
|
|
773
800
|
'knowledgePieces',
|
|
801
|
+
'sources', // <- TODO: [🧠] Where should the `sources` be
|
|
774
802
|
];
|
|
775
803
|
/**
|
|
776
804
|
* Nonce which is used for replacing things in strings
|
|
@@ -2744,7 +2772,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
2744
2772
|
});
|
|
2745
2773
|
}
|
|
2746
2774
|
|
|
2747
|
-
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"}];
|
|
2775
|
+
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"}];
|
|
2748
2776
|
|
|
2749
2777
|
/**
|
|
2750
2778
|
* Prettify the html code
|
|
@@ -4581,9 +4609,87 @@ function arrayableToArray(input) {
|
|
|
4581
4609
|
return [input];
|
|
4582
4610
|
}
|
|
4583
4611
|
|
|
4612
|
+
/**
|
|
4613
|
+
* Format either small or big number
|
|
4614
|
+
*
|
|
4615
|
+
* @public exported from `@promptbook/utils`
|
|
4616
|
+
*/
|
|
4617
|
+
function numberToString(value) {
|
|
4618
|
+
if (value === 0) {
|
|
4619
|
+
return '0';
|
|
4620
|
+
}
|
|
4621
|
+
else if (Number.isNaN(value)) {
|
|
4622
|
+
return VALUE_STRINGS.nan;
|
|
4623
|
+
}
|
|
4624
|
+
else if (value === Infinity) {
|
|
4625
|
+
return VALUE_STRINGS.infinity;
|
|
4626
|
+
}
|
|
4627
|
+
else if (value === -Infinity) {
|
|
4628
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
4629
|
+
}
|
|
4630
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
4631
|
+
var factor = Math.pow(10, exponent);
|
|
4632
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
4633
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
4634
|
+
return valueRounded.toFixed(exponent);
|
|
4635
|
+
}
|
|
4636
|
+
}
|
|
4637
|
+
return value.toString();
|
|
4638
|
+
}
|
|
4639
|
+
|
|
4640
|
+
/**
|
|
4641
|
+
* Function `valueToString` will convert the given value to string
|
|
4642
|
+
* This is useful and used in the `templateParameters` function
|
|
4643
|
+
*
|
|
4644
|
+
* Note: This function is not just calling `toString` method
|
|
4645
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
4646
|
+
* See `VALUE_STRINGS`
|
|
4647
|
+
*
|
|
4648
|
+
* Note: There are 2 similar functions
|
|
4649
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
4650
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
4651
|
+
*
|
|
4652
|
+
* @public exported from `@promptbook/utils`
|
|
4653
|
+
*/
|
|
4654
|
+
function valueToString(value) {
|
|
4655
|
+
try {
|
|
4656
|
+
if (value === '') {
|
|
4657
|
+
return VALUE_STRINGS.empty;
|
|
4658
|
+
}
|
|
4659
|
+
else if (value === null) {
|
|
4660
|
+
return VALUE_STRINGS.null;
|
|
4661
|
+
}
|
|
4662
|
+
else if (value === undefined) {
|
|
4663
|
+
return VALUE_STRINGS.undefined;
|
|
4664
|
+
}
|
|
4665
|
+
else if (typeof value === 'string') {
|
|
4666
|
+
return value;
|
|
4667
|
+
}
|
|
4668
|
+
else if (typeof value === 'number') {
|
|
4669
|
+
return numberToString(value);
|
|
4670
|
+
}
|
|
4671
|
+
else if (value instanceof Date) {
|
|
4672
|
+
return value.toISOString();
|
|
4673
|
+
}
|
|
4674
|
+
else {
|
|
4675
|
+
return JSON.stringify(value);
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4678
|
+
catch (error) {
|
|
4679
|
+
if (!(error instanceof Error)) {
|
|
4680
|
+
throw error;
|
|
4681
|
+
}
|
|
4682
|
+
console.error(error);
|
|
4683
|
+
return VALUE_STRINGS.unserializable;
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
|
|
4584
4687
|
/**
|
|
4585
4688
|
* Replaces parameters in template with values from parameters object
|
|
4586
4689
|
*
|
|
4690
|
+
* Note: This function is not places strings into string,
|
|
4691
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
4692
|
+
*
|
|
4587
4693
|
* @param template the template with parameters in {curly} braces
|
|
4588
4694
|
* @param parameters the object with parameters
|
|
4589
4695
|
* @returns the template with replaced parameters
|
|
@@ -4633,7 +4739,7 @@ function templateParameters(template, parameters) {
|
|
|
4633
4739
|
if (parameterValue === undefined) {
|
|
4634
4740
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4635
4741
|
}
|
|
4636
|
-
parameterValue = parameterValue
|
|
4742
|
+
parameterValue = valueToString(parameterValue);
|
|
4637
4743
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
4638
4744
|
parameterValue = parameterValue
|
|
4639
4745
|
.split('\n')
|
|
@@ -9547,6 +9653,14 @@ function precompilePipeline(pipelineString) {
|
|
|
9547
9653
|
knowledgePieces: [],
|
|
9548
9654
|
personas: [],
|
|
9549
9655
|
preparations: [],
|
|
9656
|
+
sources: [
|
|
9657
|
+
{
|
|
9658
|
+
type: 'BOOK',
|
|
9659
|
+
path: null,
|
|
9660
|
+
// <- TODO: !!!!!! Pass here path of the file
|
|
9661
|
+
content: pipelineString,
|
|
9662
|
+
},
|
|
9663
|
+
],
|
|
9550
9664
|
};
|
|
9551
9665
|
function getPipelineIdentification() {
|
|
9552
9666
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -9954,7 +10068,6 @@ function precompilePipeline(pipelineString) {
|
|
|
9954
10068
|
$pipelineJson.formfactorName = 'GENERIC';
|
|
9955
10069
|
}
|
|
9956
10070
|
// =============================================================
|
|
9957
|
-
// TODO: [🍙] Maybe do reorder of `$pipelineJson` here
|
|
9958
10071
|
return exportJson({
|
|
9959
10072
|
name: 'pipelineJson',
|
|
9960
10073
|
message: "Result of `precompilePipeline`",
|
|
@@ -11086,11 +11199,9 @@ function createCollectionFromDirectory(path, tools, options) {
|
|
|
11086
11199
|
, ".json"));
|
|
11087
11200
|
return [4 /*yield*/, isFileExisting(makedLibraryFilePath, tools.fs)];
|
|
11088
11201
|
case 3:
|
|
11089
|
-
if (!(_f.sent()))
|
|
11090
|
-
console.info(colors.yellow("Tip: Prebuild your pipeline collection (file with supposed prebuild ".concat(makedLibraryFilePath, " not found) with CLI util \"ptbk make\" to speed up the collection creation.")));
|
|
11091
|
-
}
|
|
11202
|
+
if (!(_f.sent())) ;
|
|
11092
11203
|
else {
|
|
11093
|
-
colors.green("(In future, not implemented yet) Using your
|
|
11204
|
+
colors.green("(In future, not implemented yet) Using your compiled pipeline collection ".concat(makedLibraryFilePath));
|
|
11094
11205
|
// TODO: !! Implement;
|
|
11095
11206
|
// TODO: [🌗]
|
|
11096
11207
|
}
|
|
@@ -11110,10 +11221,10 @@ function createCollectionFromDirectory(path, tools, options) {
|
|
|
11110
11221
|
// Note: First load all .book.json and then .book.md files
|
|
11111
11222
|
// .book.json can be prepared so it is faster to load
|
|
11112
11223
|
fileNames.sort(function (a, b) {
|
|
11113
|
-
if (a.endsWith('.
|
|
11224
|
+
if (a.endsWith('.json') && b.endsWith('.md')) {
|
|
11114
11225
|
return -1;
|
|
11115
11226
|
}
|
|
11116
|
-
if (a.endsWith('.
|
|
11227
|
+
if (a.endsWith('.md') && b.endsWith('.json')) {
|
|
11117
11228
|
return 1;
|
|
11118
11229
|
}
|
|
11119
11230
|
return 0;
|
|
@@ -11162,7 +11273,7 @@ function createCollectionFromDirectory(path, tools, options) {
|
|
|
11162
11273
|
// TODO: [👠] DRY
|
|
11163
11274
|
if (pipeline.pipelineUrl === undefined) {
|
|
11164
11275
|
if (isVerbose) {
|
|
11165
|
-
console.info(colors.
|
|
11276
|
+
console.info(colors.yellow("Can not load pipeline from ".concat(fileName
|
|
11166
11277
|
.split('\\')
|
|
11167
11278
|
.join('/'), " because of missing URL")));
|
|
11168
11279
|
}
|
|
@@ -11340,16 +11451,21 @@ function initializeMakeCommand(program) {
|
|
|
11340
11451
|
makeCommand.option('--validation', "Types of validations separated by comma (options \"logic\",\"imports\")", 'logic,imports');
|
|
11341
11452
|
makeCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
|
|
11342
11453
|
makeCommand.option('-v, --verbose', "Is output verbose", false);
|
|
11343
|
-
makeCommand.option('-o, --
|
|
11454
|
+
makeCommand.option('-o, --output <path>', spaceTrim("\n Where to save the builded collection\n\n Note: If you keep it \"".concat(DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, "\" it will be saved in the root of the promptbook directory\n If you set it to a path, it will be saved in that path\n BUT you can use only one format and set correct extension\n ")), DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME);
|
|
11455
|
+
makeCommand.option('-fn, --function-name <functionName>', spaceTrim("\n Name of the function to get pipeline collection\n\n Note: This can be used only with \"javascript\" or \"typescript\" format\n\n "), DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME);
|
|
11344
11456
|
makeCommand.action(function (path, _a) {
|
|
11345
|
-
var projectName = _a.projectName, format = _a.format, validation = _a.validation, isCacheReloaded = _a.reload, isVerbose = _a.verbose,
|
|
11457
|
+
var projectName = _a.projectName, format = _a.format, functionName = _a.functionName, validation = _a.validation, isCacheReloaded = _a.reload, isVerbose = _a.verbose, output = _a.output;
|
|
11346
11458
|
return __awaiter(_this, void 0, void 0, function () {
|
|
11347
|
-
var formats, validations, prepareAndScrapeOptions, fs, llm, executables, tools, collection, validations_1, validations_1_1, validation_1,
|
|
11348
|
-
var
|
|
11459
|
+
var formats, validations, prepareAndScrapeOptions, fs, llm, executables, tools, collection, pipelinesUrls, validations_1, validations_1_1, validation_1, pipelinesUrls_1, pipelinesUrls_1_1, pipelineUrl, pipeline, e_1_1, e_2_1, collectionJson, collectionJsonString, collectionJsonItems, saveFile;
|
|
11460
|
+
var _b, e_2, _c, e_1, _d;
|
|
11349
11461
|
var _this = this;
|
|
11350
|
-
return __generator(this, function (
|
|
11351
|
-
switch (
|
|
11462
|
+
return __generator(this, function (_e) {
|
|
11463
|
+
switch (_e.label) {
|
|
11352
11464
|
case 0:
|
|
11465
|
+
if (!isValidJavascriptName(functionName)) {
|
|
11466
|
+
console.error(colors.red("Function name \"".concat(functionName, "\" is not valid javascript name")));
|
|
11467
|
+
return [2 /*return*/, process.exit(1)];
|
|
11468
|
+
}
|
|
11353
11469
|
formats = (format || '')
|
|
11354
11470
|
.split(',')
|
|
11355
11471
|
.map(function (_) { return _.trim(); })
|
|
@@ -11358,7 +11474,7 @@ function initializeMakeCommand(program) {
|
|
|
11358
11474
|
.split(',')
|
|
11359
11475
|
.map(function (_) { return _.trim(); })
|
|
11360
11476
|
.filter(function (_) { return _ !== ''; });
|
|
11361
|
-
if (
|
|
11477
|
+
if (output !== DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME && formats.length !== 1) {
|
|
11362
11478
|
console.error(colors.red("You can only use one format if you specify --out-file"));
|
|
11363
11479
|
return [2 /*return*/, process.exit(1)];
|
|
11364
11480
|
}
|
|
@@ -11370,85 +11486,89 @@ function initializeMakeCommand(program) {
|
|
|
11370
11486
|
llm = $provideLlmToolsForCli(prepareAndScrapeOptions);
|
|
11371
11487
|
return [4 /*yield*/, $provideExecutablesForNode(prepareAndScrapeOptions)];
|
|
11372
11488
|
case 1:
|
|
11373
|
-
executables =
|
|
11374
|
-
|
|
11489
|
+
executables = _e.sent();
|
|
11490
|
+
_b = {
|
|
11375
11491
|
llm: llm,
|
|
11376
11492
|
fs: fs
|
|
11377
11493
|
};
|
|
11378
11494
|
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, prepareAndScrapeOptions)];
|
|
11379
11495
|
case 2:
|
|
11380
|
-
tools = (
|
|
11381
|
-
|
|
11496
|
+
tools = (_b.scrapers = _e.sent(),
|
|
11497
|
+
_b.script = [
|
|
11382
11498
|
/*new JavascriptExecutionTools(options)*/
|
|
11383
11499
|
],
|
|
11384
|
-
|
|
11500
|
+
_b);
|
|
11385
11501
|
return [4 /*yield*/, createCollectionFromDirectory(path, tools, {
|
|
11386
11502
|
isVerbose: isVerbose,
|
|
11387
11503
|
isRecursive: true,
|
|
11388
11504
|
// <- TODO: [🍖] Add `intermediateFilesStrategy`
|
|
11389
11505
|
})];
|
|
11390
11506
|
case 3:
|
|
11391
|
-
collection =
|
|
11392
|
-
|
|
11507
|
+
collection = _e.sent();
|
|
11508
|
+
return [4 /*yield*/, collection.listPipelines()];
|
|
11393
11509
|
case 4:
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11510
|
+
pipelinesUrls = _e.sent();
|
|
11511
|
+
if (pipelinesUrls.length === 0) {
|
|
11512
|
+
console.error(colors.red("No books found in \"".concat(path, "\"")));
|
|
11513
|
+
return [2 /*return*/, process.exit(1)];
|
|
11514
|
+
}
|
|
11515
|
+
_e.label = 5;
|
|
11397
11516
|
case 5:
|
|
11517
|
+
_e.trys.push([5, 16, 17, 18]);
|
|
11518
|
+
validations_1 = __values(validations), validations_1_1 = validations_1.next();
|
|
11519
|
+
_e.label = 6;
|
|
11520
|
+
case 6:
|
|
11398
11521
|
if (!!validations_1_1.done) return [3 /*break*/, 15];
|
|
11399
11522
|
validation_1 = validations_1_1.value;
|
|
11400
|
-
|
|
11401
|
-
case 6:
|
|
11402
|
-
_g.trys.push([6, 12, 13, 14]);
|
|
11403
|
-
e_1 = void 0;
|
|
11404
|
-
return [4 /*yield*/, collection.listPipelines()];
|
|
11523
|
+
_e.label = 7;
|
|
11405
11524
|
case 7:
|
|
11406
|
-
|
|
11407
|
-
|
|
11525
|
+
_e.trys.push([7, 12, 13, 14]);
|
|
11526
|
+
pipelinesUrls_1 = (e_1 = void 0, __values(pipelinesUrls)), pipelinesUrls_1_1 = pipelinesUrls_1.next();
|
|
11527
|
+
_e.label = 8;
|
|
11408
11528
|
case 8:
|
|
11409
|
-
if (!!
|
|
11410
|
-
pipelineUrl =
|
|
11529
|
+
if (!!pipelinesUrls_1_1.done) return [3 /*break*/, 11];
|
|
11530
|
+
pipelineUrl = pipelinesUrls_1_1.value;
|
|
11411
11531
|
return [4 /*yield*/, collection.getPipelineByUrl(pipelineUrl)];
|
|
11412
11532
|
case 9:
|
|
11413
|
-
pipeline =
|
|
11533
|
+
pipeline = _e.sent();
|
|
11414
11534
|
if (validation_1 === 'logic') {
|
|
11415
11535
|
validatePipeline(pipeline);
|
|
11416
11536
|
if (isVerbose) {
|
|
11417
11537
|
console.info(colors.cyan("Validated logic of ".concat(pipeline.pipelineUrl)));
|
|
11418
11538
|
}
|
|
11419
11539
|
}
|
|
11420
|
-
|
|
11540
|
+
_e.label = 10;
|
|
11421
11541
|
case 10:
|
|
11422
|
-
|
|
11542
|
+
pipelinesUrls_1_1 = pipelinesUrls_1.next();
|
|
11423
11543
|
return [3 /*break*/, 8];
|
|
11424
11544
|
case 11: return [3 /*break*/, 14];
|
|
11425
11545
|
case 12:
|
|
11426
|
-
e_1_1 =
|
|
11546
|
+
e_1_1 = _e.sent();
|
|
11427
11547
|
e_1 = { error: e_1_1 };
|
|
11428
11548
|
return [3 /*break*/, 14];
|
|
11429
11549
|
case 13:
|
|
11430
11550
|
try {
|
|
11431
|
-
if (
|
|
11551
|
+
if (pipelinesUrls_1_1 && !pipelinesUrls_1_1.done && (_d = pipelinesUrls_1.return)) _d.call(pipelinesUrls_1);
|
|
11432
11552
|
}
|
|
11433
11553
|
finally { if (e_1) throw e_1.error; }
|
|
11434
11554
|
return [7 /*endfinally*/];
|
|
11435
11555
|
case 14:
|
|
11436
11556
|
validations_1_1 = validations_1.next();
|
|
11437
|
-
return [3 /*break*/,
|
|
11557
|
+
return [3 /*break*/, 6];
|
|
11438
11558
|
case 15: return [3 /*break*/, 18];
|
|
11439
11559
|
case 16:
|
|
11440
|
-
e_2_1 =
|
|
11560
|
+
e_2_1 = _e.sent();
|
|
11441
11561
|
e_2 = { error: e_2_1 };
|
|
11442
11562
|
return [3 /*break*/, 18];
|
|
11443
11563
|
case 17:
|
|
11444
11564
|
try {
|
|
11445
|
-
if (validations_1_1 && !validations_1_1.done && (
|
|
11565
|
+
if (validations_1_1 && !validations_1_1.done && (_c = validations_1.return)) _c.call(validations_1);
|
|
11446
11566
|
}
|
|
11447
11567
|
finally { if (e_2) throw e_2.error; }
|
|
11448
11568
|
return [7 /*endfinally*/];
|
|
11449
11569
|
case 18: return [4 /*yield*/, collectionToJson(collection)];
|
|
11450
11570
|
case 19:
|
|
11451
|
-
collectionJson =
|
|
11571
|
+
collectionJson = _e.sent();
|
|
11452
11572
|
collectionJsonString = stringifyPipelineJson(collectionJson).trim();
|
|
11453
11573
|
collectionJsonItems = (function () {
|
|
11454
11574
|
var firstChar = collectionJsonString.charAt(0);
|
|
@@ -11466,10 +11586,10 @@ function initializeMakeCommand(program) {
|
|
|
11466
11586
|
return __generator(this, function (_a) {
|
|
11467
11587
|
switch (_a.label) {
|
|
11468
11588
|
case 0:
|
|
11469
|
-
filename =
|
|
11470
|
-
?
|
|
11589
|
+
filename = output !== DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME
|
|
11590
|
+
? output
|
|
11471
11591
|
: join(path, "".concat(DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, ".").concat(extension));
|
|
11472
|
-
if (!
|
|
11592
|
+
if (!output.endsWith(".".concat(extension))) {
|
|
11473
11593
|
console.warn(colors.yellow("Warning: Extension of output file should be \"".concat(extension, "\"")));
|
|
11474
11594
|
}
|
|
11475
11595
|
return [4 /*yield*/, mkdir(dirname(filename), { recursive: true })];
|
|
@@ -11488,22 +11608,22 @@ function initializeMakeCommand(program) {
|
|
|
11488
11608
|
formats = formats.filter(function (format) { return format !== 'json'; });
|
|
11489
11609
|
return [4 /*yield*/, saveFile('json', collectionJsonString)];
|
|
11490
11610
|
case 20:
|
|
11491
|
-
|
|
11492
|
-
|
|
11611
|
+
_e.sent();
|
|
11612
|
+
_e.label = 21;
|
|
11493
11613
|
case 21:
|
|
11494
11614
|
if (!(formats.includes('javascript') || formats.includes('js'))) return [3 /*break*/, 23];
|
|
11495
11615
|
formats = formats.filter(function (format) { return format !== 'javascript' && format !== 'js'; });
|
|
11496
|
-
return [4 /*yield*/, saveFile('js', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `
|
|
11616
|
+
return [4 /*yield*/, saveFile('js', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @private internal cache for `").concat(functionName, "`\n */\n let pipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(){\n if(pipelineCollection===null){\n pipelineCollection = createCollectionFromJson(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }))];
|
|
11497
11617
|
case 22:
|
|
11498
|
-
(
|
|
11499
|
-
|
|
11618
|
+
(_e.sent()) + '\n';
|
|
11619
|
+
_e.label = 23;
|
|
11500
11620
|
case 23:
|
|
11501
11621
|
if (!(formats.includes('typescript') || formats.includes('ts'))) return [3 /*break*/, 25];
|
|
11502
11622
|
formats = formats.filter(function (format) { return format !== 'typescript' && format !== 'ts'; });
|
|
11503
|
-
return [4 /*yield*/, saveFile('ts', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n import type { PipelineCollection } from '@promptbook/types';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `
|
|
11623
|
+
return [4 /*yield*/, saveFile('ts', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n import type { PipelineCollection } from '@promptbook/types';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `").concat(functionName, "`\n * @generated\n */\n let pipelineCollection: null | PipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(): PipelineCollection{\n if(pipelineCollection===null){\n\n // TODO: !!!!!! Use book string literal notation\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pipelineCollection = (createCollectionFromJson as (_: any) => PipelineCollection)(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }) + '\n')];
|
|
11504
11624
|
case 24:
|
|
11505
|
-
|
|
11506
|
-
|
|
11625
|
+
_e.sent();
|
|
11626
|
+
_e.label = 25;
|
|
11507
11627
|
case 25:
|
|
11508
11628
|
if (formats.length > 0) {
|
|
11509
11629
|
console.warn(colors.yellow("Format ".concat(formats.join(' and '), " is not supported")));
|
|
@@ -11753,26 +11873,6 @@ function initializePrettifyCommand(program) {
|
|
|
11753
11873
|
* TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
|
|
11754
11874
|
*/
|
|
11755
11875
|
|
|
11756
|
-
/**
|
|
11757
|
-
* Format either small or big number
|
|
11758
|
-
*
|
|
11759
|
-
* @private within the repository
|
|
11760
|
-
*/
|
|
11761
|
-
function formatNumber(value) {
|
|
11762
|
-
if (value === 0) {
|
|
11763
|
-
return '0';
|
|
11764
|
-
}
|
|
11765
|
-
for (var exponent = 0; exponent < 15; exponent++) {
|
|
11766
|
-
var factor = Math.pow(10, exponent);
|
|
11767
|
-
var valueRounded = Math.round(value * factor) / factor;
|
|
11768
|
-
if (Math.abs(value - valueRounded) / value <
|
|
11769
|
-
0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
|
|
11770
|
-
return valueRounded.toFixed(exponent);
|
|
11771
|
-
}
|
|
11772
|
-
}
|
|
11773
|
-
return value.toString();
|
|
11774
|
-
}
|
|
11775
|
-
|
|
11776
11876
|
/**
|
|
11777
11877
|
* Create a markdown table from a 2D array of strings
|
|
11778
11878
|
*
|
|
@@ -11832,7 +11932,7 @@ function createMarkdownChart(options) {
|
|
|
11832
11932
|
}
|
|
11833
11933
|
finally { if (e_1) throw e_1.error; }
|
|
11834
11934
|
}
|
|
11835
|
-
var legend = "_Note: Each \u2588 represents ".concat(
|
|
11935
|
+
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_");
|
|
11836
11936
|
return createMarkdownTable(table) + '\n\n' + legend;
|
|
11837
11937
|
}
|
|
11838
11938
|
/**
|
|
@@ -11961,7 +12061,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
11961
12061
|
headerList.push("COMPLETED AT ".concat(moment(completedAt).format("YYYY-MM-DD HH:mm:ss")));
|
|
11962
12062
|
headerList.push("TOTAL DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
11963
12063
|
headerList.push("TOTAL LLM DURATION ".concat(llmDuration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
11964
|
-
headerList.push("TOTAL COST $".concat(
|
|
12064
|
+
headerList.push("TOTAL COST $".concat(numberToString(cost * (1 + taxRate))) +
|
|
11965
12065
|
(executionsWithKnownCost.length === executionReportJson.promptExecutions.length
|
|
11966
12066
|
? ''
|
|
11967
12067
|
: " *(Some cost is unknown)*") +
|
|
@@ -12019,7 +12119,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
12019
12119
|
// > taskList.push(`STARTED AT ${moment(startedAt).calendar()}`);
|
|
12020
12120
|
taskList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
12021
12121
|
if (typeof ((_g = (_f = promptExecution.result) === null || _f === void 0 ? void 0 : _f.usage) === null || _g === void 0 ? void 0 : _g.price) === 'number') {
|
|
12022
|
-
taskList.push("COST $".concat(
|
|
12122
|
+
taskList.push("COST $".concat(numberToString(promptExecution.result.usage.price * (1 + taxRate))) +
|
|
12023
12123
|
(taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
|
|
12024
12124
|
}
|
|
12025
12125
|
else {
|
|
@@ -14323,6 +14423,10 @@ var _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
14323
14423
|
* For example:
|
|
14324
14424
|
* - `Date` objects will be converted to string
|
|
14325
14425
|
*
|
|
14426
|
+
* Note: There are 2 similar functions
|
|
14427
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
14428
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
14429
|
+
*
|
|
14326
14430
|
* @private Internal helper function
|
|
14327
14431
|
*/
|
|
14328
14432
|
function asSerializable(value) {
|