@promptbook/cli 0.61.0-20 → 0.61.0-21
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 +93 -39
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -0
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +93 -39
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/execution/PipelineExecutor.d.ts +1 -0
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +1 -0
package/esm/index.es.js
CHANGED
|
@@ -150,7 +150,7 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
|
|
|
150
150
|
/**
|
|
151
151
|
* The version of the Promptbook library
|
|
152
152
|
*/
|
|
153
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
153
|
+
var PROMPTBOOK_VERSION = '0.61.0-20';
|
|
154
154
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
155
155
|
|
|
156
156
|
/**
|
|
@@ -735,7 +735,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
735
735
|
});
|
|
736
736
|
}
|
|
737
737
|
|
|
738
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
738
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-20",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",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> {content}",dependentParameterNames:["content"],resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-20",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-20",parameters:[{name:"content",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> {content}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-20",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-20",parameters:[{name:"content",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> {content}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-20",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-20",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-20",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"}];
|
|
739
739
|
|
|
740
740
|
/**
|
|
741
741
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1098,7 +1098,9 @@ function validatePipeline(pipeline) {
|
|
|
1098
1098
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1099
1099
|
});
|
|
1100
1100
|
if (currentlyResovedTemplates.length === 0) {
|
|
1101
|
-
throw new PipelineLogicError(
|
|
1101
|
+
throw new PipelineLogicError(
|
|
1102
|
+
// TODO: [🐎] DRY
|
|
1103
|
+
spaceTrim$1(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n Can not resolve:\n ".concat(block(unresovedTemplates
|
|
1102
1104
|
.map(function (_a) {
|
|
1103
1105
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1104
1106
|
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
@@ -2905,7 +2907,34 @@ function createPipelineExecutor(options) {
|
|
|
2905
2907
|
});
|
|
2906
2908
|
});
|
|
2907
2909
|
}
|
|
2908
|
-
|
|
2910
|
+
function filterJustOutputParameters() {
|
|
2911
|
+
var e_9, _a;
|
|
2912
|
+
var outputParameters = {};
|
|
2913
|
+
try {
|
|
2914
|
+
// Note: Filter ONLY output parameters
|
|
2915
|
+
for (var _b = __values(pipeline.parameters.filter(function (_a) {
|
|
2916
|
+
var isOutput = _a.isOutput;
|
|
2917
|
+
return isOutput;
|
|
2918
|
+
})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2919
|
+
var parameter = _c.value;
|
|
2920
|
+
if (parametersToPass[parameter.name] === undefined) {
|
|
2921
|
+
// [4]
|
|
2922
|
+
errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an output parameter but not set in the pipeline")));
|
|
2923
|
+
continue;
|
|
2924
|
+
}
|
|
2925
|
+
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
2929
|
+
finally {
|
|
2930
|
+
try {
|
|
2931
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2932
|
+
}
|
|
2933
|
+
finally { if (e_9) throw e_9.error; }
|
|
2934
|
+
}
|
|
2935
|
+
return outputParameters;
|
|
2936
|
+
}
|
|
2937
|
+
var executionReport, _a, _b, parameter, errors, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameters_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
2909
2938
|
var e_1, _e, e_2, _f;
|
|
2910
2939
|
return __generator(this, function (_g) {
|
|
2911
2940
|
switch (_g.label) {
|
|
@@ -2930,9 +2959,12 @@ function createPipelineExecutor(options) {
|
|
|
2930
2959
|
};
|
|
2931
2960
|
try {
|
|
2932
2961
|
// Note: Check that all input input parameters are defined
|
|
2933
|
-
for (_a = __values(pipeline.parameters
|
|
2962
|
+
for (_a = __values(pipeline.parameters.filter(function (_a) {
|
|
2963
|
+
var isInput = _a.isInput;
|
|
2964
|
+
return isInput;
|
|
2965
|
+
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
2934
2966
|
parameter = _b.value;
|
|
2935
|
-
if (
|
|
2967
|
+
if (inputParameters[parameter.name] === undefined) {
|
|
2936
2968
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
2937
2969
|
isSuccessful: false,
|
|
2938
2970
|
errors: [
|
|
@@ -2953,6 +2985,44 @@ function createPipelineExecutor(options) {
|
|
|
2953
2985
|
}
|
|
2954
2986
|
finally { if (e_1) throw e_1.error; }
|
|
2955
2987
|
}
|
|
2988
|
+
errors = [];
|
|
2989
|
+
_loop_1 = function (parameterName) {
|
|
2990
|
+
var parameter = pipeline.parameters.find(function (_a) {
|
|
2991
|
+
var name = _a.name;
|
|
2992
|
+
return name === parameterName;
|
|
2993
|
+
});
|
|
2994
|
+
if (parameter === undefined) {
|
|
2995
|
+
errors.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is passed as input parameter")));
|
|
2996
|
+
}
|
|
2997
|
+
else if (parameter.isInput === false) {
|
|
2998
|
+
return { value: deepFreezeWithSameType({
|
|
2999
|
+
isSuccessful: false,
|
|
3000
|
+
errors: [
|
|
3001
|
+
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but is not input")),
|
|
3002
|
+
// <- TODO: !!!!! Test this error
|
|
3003
|
+
],
|
|
3004
|
+
executionReport: executionReport,
|
|
3005
|
+
outputParameters: {},
|
|
3006
|
+
usage: ZERO_USAGE,
|
|
3007
|
+
}) };
|
|
3008
|
+
}
|
|
3009
|
+
};
|
|
3010
|
+
try {
|
|
3011
|
+
// Note: Check that no extra input parameters are passed
|
|
3012
|
+
for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3013
|
+
parameterName = _d.value;
|
|
3014
|
+
state_1 = _loop_1(parameterName);
|
|
3015
|
+
if (typeof state_1 === "object")
|
|
3016
|
+
return [2 /*return*/, state_1.value];
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3020
|
+
finally {
|
|
3021
|
+
try {
|
|
3022
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
3023
|
+
}
|
|
3024
|
+
finally { if (e_2) throw e_2.error; }
|
|
3025
|
+
}
|
|
2956
3026
|
parametersToPass = inputParameters;
|
|
2957
3027
|
_g.label = 3;
|
|
2958
3028
|
case 3:
|
|
@@ -2969,7 +3039,7 @@ function createPipelineExecutor(options) {
|
|
|
2969
3039
|
unresovedTemplates_1 = __spreadArray([], __read(pipeline.promptTemplates), false);
|
|
2970
3040
|
resolving_1 = [];
|
|
2971
3041
|
loopLimit = LOOP_LIMIT;
|
|
2972
|
-
|
|
3042
|
+
_loop_2 = function () {
|
|
2973
3043
|
var currentTemplate, work_1;
|
|
2974
3044
|
return __generator(this, function (_h) {
|
|
2975
3045
|
switch (_h.label) {
|
|
@@ -2982,12 +3052,16 @@ function createPipelineExecutor(options) {
|
|
|
2982
3052
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
2983
3053
|
});
|
|
2984
3054
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
2985
|
-
throw new UnexpectedError(
|
|
3055
|
+
throw new UnexpectedError(
|
|
3056
|
+
// TODO: [🐎] DRY
|
|
3057
|
+
spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n Can not resolve:\n ".concat(block(unresovedTemplates_1
|
|
2986
3058
|
.map(function (_a) {
|
|
2987
|
-
var resultingParameterName = _a.resultingParameterName;
|
|
2988
|
-
return "- {".concat(resultingParameterName, "}")
|
|
3059
|
+
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
3060
|
+
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
3061
|
+
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
3062
|
+
.join(' and '));
|
|
2989
3063
|
})
|
|
2990
|
-
.join('\n')), "\n\n Resolved
|
|
3064
|
+
.join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
|
|
2991
3065
|
case 1:
|
|
2992
3066
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
2993
3067
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -3012,7 +3086,7 @@ function createPipelineExecutor(options) {
|
|
|
3012
3086
|
_g.label = 4;
|
|
3013
3087
|
case 4:
|
|
3014
3088
|
if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 6];
|
|
3015
|
-
return [5 /*yield**/,
|
|
3089
|
+
return [5 /*yield**/, _loop_2()];
|
|
3016
3090
|
case 5:
|
|
3017
3091
|
_g.sent();
|
|
3018
3092
|
return [3 /*break*/, 4];
|
|
@@ -3029,41 +3103,20 @@ function createPipelineExecutor(options) {
|
|
|
3029
3103
|
var result = _a.result;
|
|
3030
3104
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3031
3105
|
})), false));
|
|
3106
|
+
outputParameters_1 = filterJustOutputParameters();
|
|
3032
3107
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
3033
3108
|
isSuccessful: false,
|
|
3034
|
-
errors: [error_1],
|
|
3109
|
+
errors: __spreadArray([error_1], __read(errors), false),
|
|
3035
3110
|
usage: usage_1,
|
|
3036
3111
|
executionReport: executionReport,
|
|
3037
|
-
outputParameters:
|
|
3112
|
+
outputParameters: outputParameters_1,
|
|
3038
3113
|
})];
|
|
3039
3114
|
case 9:
|
|
3040
|
-
outputParameters = {};
|
|
3041
|
-
errors = [];
|
|
3042
|
-
try {
|
|
3043
|
-
// Note: Filter ONLY output parameters
|
|
3044
|
-
for (_c = __values(pipeline.parameters.filter(function (_a) {
|
|
3045
|
-
var isOutput = _a.isOutput;
|
|
3046
|
-
return isOutput;
|
|
3047
|
-
})), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3048
|
-
parameter = _d.value;
|
|
3049
|
-
if (parametersToPass[parameter.name] === undefined) {
|
|
3050
|
-
errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an output parameter but not set in the pipeline")));
|
|
3051
|
-
continue;
|
|
3052
|
-
}
|
|
3053
|
-
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
3054
|
-
}
|
|
3055
|
-
}
|
|
3056
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3057
|
-
finally {
|
|
3058
|
-
try {
|
|
3059
|
-
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
3060
|
-
}
|
|
3061
|
-
finally { if (e_2) throw e_2.error; }
|
|
3062
|
-
}
|
|
3063
3115
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
3064
3116
|
var result = _a.result;
|
|
3065
3117
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3066
3118
|
})), false));
|
|
3119
|
+
outputParameters = filterJustOutputParameters();
|
|
3067
3120
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
3068
3121
|
isSuccessful: true,
|
|
3069
3122
|
errors: errors,
|
|
@@ -3085,6 +3138,7 @@ function createPipelineExecutor(options) {
|
|
|
3085
3138
|
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
3086
3139
|
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
3087
3140
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3141
|
+
* TODO: [💷] !!!! `assertsExecutionSuccessful` should be the method of `PipelineExecutor` result
|
|
3088
3142
|
*/
|
|
3089
3143
|
|
|
3090
3144
|
/**
|
|
@@ -7514,8 +7568,8 @@ function initializePrettifyCommand(program) {
|
|
|
7514
7568
|
throw error_1;
|
|
7515
7569
|
}
|
|
7516
7570
|
console.info(colors.red("Prettify ".concat(error_1.name, " ").concat(filePath)));
|
|
7517
|
-
console.error(colors.bgRed(error_1.name));
|
|
7518
|
-
console.error(error_1);
|
|
7571
|
+
console.error(colors.bgRed(error_1.name /* <- 11:11 */));
|
|
7572
|
+
console.error(colors.red(error_1.stack || error_1.message));
|
|
7519
7573
|
process.exit(1);
|
|
7520
7574
|
return [3 /*break*/, 9];
|
|
7521
7575
|
case 9:
|