@promptbook/core 0.61.0 → 0.62.0-0
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 +137 -16
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -1
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +2 -1
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -0
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +15 -0
- package/esm/typings/src/execution/utils/usageToHuman.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +3 -2
- package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +3 -2
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +7 -4
- package/esm/typings/src/llm-providers/_common/utils/{count-total-cost/LlmExecutionToolsWithTotalCost.d.ts → count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts} +5 -2
- package/{umd/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts → esm/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts} +5 -2
- package/esm/typings/src/llm-providers/_common/utils/{count-total-cost/limitTotalCost.d.ts → count-total-usage/limitTotalUsage.d.ts} +8 -5
- package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +3 -0
- package/esm/typings/src/prepare/preparePipeline.d.ts +0 -1
- package/package.json +2 -2
- package/umd/index.umd.js +137 -15
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/core.index.d.ts +2 -1
- package/umd/typings/src/conversion/pipelineJsonToString.d.ts +2 -1
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +1 -0
- package/umd/typings/src/execution/utils/usageToHuman.d.ts +15 -0
- package/umd/typings/src/execution/utils/usageToHuman.test.d.ts +1 -0
- package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +1 -0
- package/umd/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +3 -2
- package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +3 -2
- package/umd/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +7 -4
- package/umd/typings/src/llm-providers/_common/utils/{count-total-cost/LlmExecutionToolsWithTotalCost.d.ts → count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts} +5 -2
- package/{esm/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts → umd/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts} +5 -2
- package/umd/typings/src/llm-providers/_common/utils/{count-total-cost/limitTotalCost.d.ts → count-total-usage/limitTotalUsage.d.ts} +8 -5
- package/umd/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +3 -0
- package/umd/typings/src/prepare/preparePipeline.d.ts +0 -1
package/esm/index.es.js
CHANGED
|
@@ -387,7 +387,8 @@ function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
|
|
|
387
387
|
/**
|
|
388
388
|
* TODO: !!!! Implement new features and commands into `promptTemplateParameterJsonToString`
|
|
389
389
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
390
|
-
* TODO:
|
|
390
|
+
* TODO: [🏛] Maybe make some markdown builder
|
|
391
|
+
* TODO: [🏛] Escape all
|
|
391
392
|
*/
|
|
392
393
|
|
|
393
394
|
/**
|
|
@@ -1517,7 +1518,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1517
1518
|
});
|
|
1518
1519
|
}
|
|
1519
1520
|
|
|
1520
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0
|
|
1521
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\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### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `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### Option `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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1521
1522
|
|
|
1522
1523
|
var defaultDiacriticsRemovalMap = [
|
|
1523
1524
|
{
|
|
@@ -2287,6 +2288,9 @@ function joinLlmExecutionTools() {
|
|
|
2287
2288
|
}
|
|
2288
2289
|
return new (MultipleLlmExecutionTools.bind.apply(MultipleLlmExecutionTools, __spreadArray([void 0], __read(llmExecutionTools), false)))();
|
|
2289
2290
|
}
|
|
2291
|
+
/**
|
|
2292
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2293
|
+
*/
|
|
2290
2294
|
|
|
2291
2295
|
/**
|
|
2292
2296
|
* Determine if the pipeline is fully prepared
|
|
@@ -2522,7 +2526,7 @@ function union() {
|
|
|
2522
2526
|
/**
|
|
2523
2527
|
* The version of the Promptbook library
|
|
2524
2528
|
*/
|
|
2525
|
-
var PROMPTBOOK_VERSION = '0.61.0
|
|
2529
|
+
var PROMPTBOOK_VERSION = '0.61.0';
|
|
2526
2530
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2527
2531
|
|
|
2528
2532
|
/**
|
|
@@ -3436,6 +3440,7 @@ function createPipelineExecutor(options) {
|
|
|
3436
3440
|
}
|
|
3437
3441
|
/**
|
|
3438
3442
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
3443
|
+
* TODO: [🧠] Use here `countTotalUsage` and put preparation and prepared pipiline to report
|
|
3439
3444
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
3440
3445
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
3441
3446
|
* TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
|
|
@@ -3644,6 +3649,85 @@ TODO: [🧊] This is how it can look in future
|
|
|
3644
3649
|
* [ ] One piece can have multiple sources
|
|
3645
3650
|
*/
|
|
3646
3651
|
|
|
3652
|
+
/**
|
|
3653
|
+
* Intercepts LLM tools and counts total usage of the tools
|
|
3654
|
+
*
|
|
3655
|
+
* @param llmTools LLM tools to be intercepted with usage counting
|
|
3656
|
+
* @returns LLM tools with same functionality with added total cost counting
|
|
3657
|
+
*/
|
|
3658
|
+
function countTotalUsage(llmTools) {
|
|
3659
|
+
var _this = this;
|
|
3660
|
+
var totalUsage = ZERO_USAGE;
|
|
3661
|
+
var proxyTools = {
|
|
3662
|
+
get title() {
|
|
3663
|
+
// TODO: [🧠] Maybe put here some suffix
|
|
3664
|
+
return llmTools.title;
|
|
3665
|
+
},
|
|
3666
|
+
get description() {
|
|
3667
|
+
// TODO: [🧠] Maybe put here some suffix
|
|
3668
|
+
return llmTools.description;
|
|
3669
|
+
},
|
|
3670
|
+
listModels: function () {
|
|
3671
|
+
return /* not await */ llmTools.listModels();
|
|
3672
|
+
},
|
|
3673
|
+
get totalUsage() {
|
|
3674
|
+
return totalUsage;
|
|
3675
|
+
},
|
|
3676
|
+
};
|
|
3677
|
+
if (llmTools.callChatModel !== undefined) {
|
|
3678
|
+
proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
3679
|
+
var promptResult;
|
|
3680
|
+
return __generator(this, function (_a) {
|
|
3681
|
+
switch (_a.label) {
|
|
3682
|
+
case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
|
|
3683
|
+
case 1:
|
|
3684
|
+
promptResult = _a.sent();
|
|
3685
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3686
|
+
return [2 /*return*/, promptResult];
|
|
3687
|
+
}
|
|
3688
|
+
});
|
|
3689
|
+
}); };
|
|
3690
|
+
}
|
|
3691
|
+
if (llmTools.callCompletionModel !== undefined) {
|
|
3692
|
+
proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
3693
|
+
var promptResult;
|
|
3694
|
+
return __generator(this, function (_a) {
|
|
3695
|
+
switch (_a.label) {
|
|
3696
|
+
case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
|
|
3697
|
+
case 1:
|
|
3698
|
+
promptResult = _a.sent();
|
|
3699
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3700
|
+
return [2 /*return*/, promptResult];
|
|
3701
|
+
}
|
|
3702
|
+
});
|
|
3703
|
+
}); };
|
|
3704
|
+
}
|
|
3705
|
+
if (llmTools.callEmbeddingModel !== undefined) {
|
|
3706
|
+
proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
3707
|
+
var promptResult;
|
|
3708
|
+
return __generator(this, function (_a) {
|
|
3709
|
+
switch (_a.label) {
|
|
3710
|
+
case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
|
|
3711
|
+
case 1:
|
|
3712
|
+
promptResult = _a.sent();
|
|
3713
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3714
|
+
return [2 /*return*/, promptResult];
|
|
3715
|
+
}
|
|
3716
|
+
});
|
|
3717
|
+
}); };
|
|
3718
|
+
}
|
|
3719
|
+
// <- Note: [🤖]
|
|
3720
|
+
return proxyTools;
|
|
3721
|
+
}
|
|
3722
|
+
/**
|
|
3723
|
+
* TODO: [🔼] !!! Export via `@promptbookcore/`
|
|
3724
|
+
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
3725
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
3726
|
+
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
3727
|
+
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
3728
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3729
|
+
*/
|
|
3730
|
+
|
|
3647
3731
|
/**
|
|
3648
3732
|
* Prepares the persona for the pipeline
|
|
3649
3733
|
*
|
|
@@ -3767,18 +3851,19 @@ function prepareTemplates(pipeline, options) {
|
|
|
3767
3851
|
*/
|
|
3768
3852
|
function preparePipeline(pipeline, options) {
|
|
3769
3853
|
return __awaiter(this, void 0, void 0, function () {
|
|
3770
|
-
var _a, maxParallelCount, parameters, promptTemplates,
|
|
3854
|
+
var llmTools, _a, maxParallelCount, _b, isVerbose, parameters, promptTemplates,
|
|
3771
3855
|
/*
|
|
3772
3856
|
<- TODO: [🧠][0] `promptbookVersion` */
|
|
3773
3857
|
knowledgeSources /*
|
|
3774
3858
|
<- TODO: [🧊] `knowledgePieces` */, personas /*
|
|
3775
|
-
<- TODO: [🧊] `preparations` */, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, promptTemplatesPrepared /* TODO: parameters: parametersPrepared*/;
|
|
3859
|
+
<- TODO: [🧊] `preparations` */, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, promptTemplatesPrepared /* TODO: parameters: parametersPrepared*/;
|
|
3776
3860
|
var _this = this;
|
|
3777
|
-
return __generator(this, function (
|
|
3778
|
-
switch (
|
|
3861
|
+
return __generator(this, function (_c) {
|
|
3862
|
+
switch (_c.label) {
|
|
3779
3863
|
case 0:
|
|
3780
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
|
|
3864
|
+
llmTools = options.llmTools, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? false : _b;
|
|
3781
3865
|
parameters = pipeline.parameters, promptTemplates = pipeline.promptTemplates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
3866
|
+
llmToolsWithUsage = countTotalUsage(llmTools);
|
|
3782
3867
|
currentPreparation = {
|
|
3783
3868
|
id: 1,
|
|
3784
3869
|
// TODO: [🍥]> date: $currentDate(),
|
|
@@ -3795,7 +3880,11 @@ function preparePipeline(pipeline, options) {
|
|
|
3795
3880
|
var modelRequirements, preparedPersona;
|
|
3796
3881
|
return __generator(this, function (_a) {
|
|
3797
3882
|
switch (_a.label) {
|
|
3798
|
-
case 0: return [4 /*yield*/, preparePersona(persona.description,
|
|
3883
|
+
case 0: return [4 /*yield*/, preparePersona(persona.description, {
|
|
3884
|
+
llmTools: llmToolsWithUsage,
|
|
3885
|
+
maxParallelCount: maxParallelCount /* <- TODO: [🪂] */,
|
|
3886
|
+
isVerbose: isVerbose,
|
|
3887
|
+
})];
|
|
3799
3888
|
case 1:
|
|
3800
3889
|
modelRequirements = _a.sent();
|
|
3801
3890
|
preparedPersona = __assign(__assign({}, persona), { modelRequirements: modelRequirements, preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] });
|
|
@@ -3805,20 +3894,30 @@ function preparePipeline(pipeline, options) {
|
|
|
3805
3894
|
});
|
|
3806
3895
|
}); })];
|
|
3807
3896
|
case 1:
|
|
3808
|
-
|
|
3897
|
+
_c.sent();
|
|
3809
3898
|
knowledgeSourcesPrepared = knowledgeSources.map(function (source) { return (__assign(__assign({}, source), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
|
|
3810
|
-
return [4 /*yield*/, prepareKnowledgePieces(knowledgeSources /* <- TODO: [🧊] {knowledgeSources, knowledgePieces} */,
|
|
3899
|
+
return [4 /*yield*/, prepareKnowledgePieces(knowledgeSources /* <- TODO: [🧊] {knowledgeSources, knowledgePieces} */, {
|
|
3900
|
+
llmTools: llmToolsWithUsage,
|
|
3901
|
+
maxParallelCount: maxParallelCount /* <- TODO: [🪂] */,
|
|
3902
|
+
isVerbose: isVerbose,
|
|
3903
|
+
})];
|
|
3811
3904
|
case 2:
|
|
3812
|
-
partialknowledgePiecesPrepared =
|
|
3905
|
+
partialknowledgePiecesPrepared = _c.sent();
|
|
3813
3906
|
knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
|
|
3814
3907
|
return [4 /*yield*/, prepareTemplates({
|
|
3815
3908
|
parameters: parameters,
|
|
3816
3909
|
promptTemplates: promptTemplates,
|
|
3817
3910
|
knowledgePiecesCount: knowledgePiecesPrepared.length,
|
|
3818
|
-
},
|
|
3911
|
+
}, {
|
|
3912
|
+
llmTools: llmToolsWithUsage,
|
|
3913
|
+
maxParallelCount: maxParallelCount /* <- TODO: [🪂] */,
|
|
3914
|
+
isVerbose: isVerbose,
|
|
3915
|
+
})];
|
|
3819
3916
|
case 3:
|
|
3820
|
-
promptTemplatesPrepared = (
|
|
3917
|
+
promptTemplatesPrepared = (_c.sent()).promptTemplatesPrepared;
|
|
3821
3918
|
// ----- /Templates preparation -----
|
|
3919
|
+
// Note: Count total usage
|
|
3920
|
+
currentPreparation.modelUsage = llmToolsWithUsage.totalUsage;
|
|
3822
3921
|
return [2 /*return*/, __assign(__assign({}, pipeline), { promptTemplates: promptTemplatesPrepared, knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations })];
|
|
3823
3922
|
}
|
|
3824
3923
|
});
|
|
@@ -3829,7 +3928,6 @@ function preparePipeline(pipeline, options) {
|
|
|
3829
3928
|
* TODO: Write tests for `preparePipeline`
|
|
3830
3929
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3831
3930
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
3832
|
-
* TODO: [🎐] !!!!! Use here countTotalUsage
|
|
3833
3931
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3834
3932
|
*/
|
|
3835
3933
|
|
|
@@ -6029,6 +6127,29 @@ function usageToWorktime(usage) {
|
|
|
6029
6127
|
return uncertainNumber;
|
|
6030
6128
|
}
|
|
6031
6129
|
|
|
6130
|
+
/**
|
|
6131
|
+
* Function `usageToHuman` will take usage and convert it to human readable report
|
|
6132
|
+
*/
|
|
6133
|
+
function usageToHuman(usage) {
|
|
6134
|
+
var report = 'Usage:';
|
|
6135
|
+
var uncertainNumberToHuman = function (_a) {
|
|
6136
|
+
var value = _a.value, isUncertain = _a.isUncertain;
|
|
6137
|
+
return "".concat(isUncertain ? 'approximately ' : '').concat(Math.round(value * 100) / 100);
|
|
6138
|
+
};
|
|
6139
|
+
report += '\n' + "- Cost ".concat(uncertainNumberToHuman(usage.price), " USD");
|
|
6140
|
+
report += '\n' + "- Saved ".concat(uncertainNumberToHuman(usageToWorktime(usage)), " hours of human time");
|
|
6141
|
+
return spaceTrim(report);
|
|
6142
|
+
}
|
|
6143
|
+
/**
|
|
6144
|
+
* TODO: Use "$1" not "1 USD"
|
|
6145
|
+
* TODO: Use markdown formatting like "Cost approximately **$1**"
|
|
6146
|
+
* TODO: Report in minutes, seconds, days NOT 0.1 hours
|
|
6147
|
+
* TODO: [🧠] Maybe make from `uncertainNumberToHuman` separate exported utility
|
|
6148
|
+
* TODO: When negligible usage, report "Negligible" or just don't report it
|
|
6149
|
+
* TODO: [🧠] Maybe use "~" instead of "approximately"
|
|
6150
|
+
* TODO: [🏛] Maybe make some markdown builder
|
|
6151
|
+
*/
|
|
6152
|
+
|
|
6032
6153
|
/**
|
|
6033
6154
|
* Delagates the user interaction to a async callback function
|
|
6034
6155
|
* You need to provide your own implementation of this callback function and its bind to UI.
|
|
@@ -6407,5 +6528,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
6407
6528
|
* TODO: [🧠] Allow to filter out some parts of the report by options
|
|
6408
6529
|
*/
|
|
6409
6530
|
|
|
6410
|
-
export { BlockTypes, CallbackInterfaceTools, CollectionError, ExecutionReportStringOptionsDefaults, ExpectError, NotFoundError, PROMPTBOOK_VERSION, ParsingError, PipelineExecutionError, PipelineLogicError, RESERVED_PARAMETER_NAMES, ReferenceError$1 as ReferenceError, SimplePromptInterfaceTools, UnexpectedError, VersionMismatchError, addUsage, assertsExecutionSuccessful, checkExpectations, collectionToJson, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, joinLlmExecutionTools, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, preparePipeline, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToWorktime, validatePipeline };
|
|
6531
|
+
export { BlockTypes, CallbackInterfaceTools, CollectionError, ExecutionReportStringOptionsDefaults, ExpectError, NotFoundError, PROMPTBOOK_VERSION, ParsingError, PipelineExecutionError, PipelineLogicError, RESERVED_PARAMETER_NAMES, ReferenceError$1 as ReferenceError, SimplePromptInterfaceTools, UnexpectedError, VersionMismatchError, addUsage, assertsExecutionSuccessful, checkExpectations, collectionToJson, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, joinLlmExecutionTools, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, preparePipeline, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
6411
6532
|
//# sourceMappingURL=index.es.js.map
|