@promptbook/node 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 +91 -37
- 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 +91 -37
- 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
|
@@ -55,4 +55,5 @@ export {};
|
|
|
55
55
|
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
56
56
|
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
57
57
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
58
|
+
* TODO: [💷] !!!! `assertsExecutionSuccessful` should be the method of `PipelineExecutor` result
|
|
58
59
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.61.0-
|
|
3
|
+
"version": "0.61.0-21",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
],
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.61.0-
|
|
54
|
+
"@promptbook/core": "0.61.0-21"
|
|
55
55
|
},
|
|
56
56
|
"main": "./umd/index.umd.js",
|
|
57
57
|
"module": "./esm/index.es.js",
|
package/umd/index.umd.js
CHANGED
|
@@ -643,7 +643,7 @@
|
|
|
643
643
|
});
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
646
|
+
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"}];
|
|
647
647
|
|
|
648
648
|
/**
|
|
649
649
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1006,7 +1006,9 @@
|
|
|
1006
1006
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1007
1007
|
});
|
|
1008
1008
|
if (currentlyResovedTemplates.length === 0) {
|
|
1009
|
-
throw new PipelineLogicError(
|
|
1009
|
+
throw new PipelineLogicError(
|
|
1010
|
+
// TODO: [🐎] DRY
|
|
1011
|
+
spaceTrim.spaceTrim(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
|
|
1010
1012
|
.map(function (_a) {
|
|
1011
1013
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1012
1014
|
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
@@ -2186,7 +2188,7 @@
|
|
|
2186
2188
|
/**
|
|
2187
2189
|
* The version of the Promptbook library
|
|
2188
2190
|
*/
|
|
2189
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2191
|
+
var PROMPTBOOK_VERSION = '0.61.0-20';
|
|
2190
2192
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2191
2193
|
|
|
2192
2194
|
/**
|
|
@@ -2819,7 +2821,34 @@
|
|
|
2819
2821
|
});
|
|
2820
2822
|
});
|
|
2821
2823
|
}
|
|
2822
|
-
|
|
2824
|
+
function filterJustOutputParameters() {
|
|
2825
|
+
var e_9, _a;
|
|
2826
|
+
var outputParameters = {};
|
|
2827
|
+
try {
|
|
2828
|
+
// Note: Filter ONLY output parameters
|
|
2829
|
+
for (var _b = __values(pipeline.parameters.filter(function (_a) {
|
|
2830
|
+
var isOutput = _a.isOutput;
|
|
2831
|
+
return isOutput;
|
|
2832
|
+
})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2833
|
+
var parameter = _c.value;
|
|
2834
|
+
if (parametersToPass[parameter.name] === undefined) {
|
|
2835
|
+
// [4]
|
|
2836
|
+
errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an output parameter but not set in the pipeline")));
|
|
2837
|
+
continue;
|
|
2838
|
+
}
|
|
2839
|
+
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
2843
|
+
finally {
|
|
2844
|
+
try {
|
|
2845
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2846
|
+
}
|
|
2847
|
+
finally { if (e_9) throw e_9.error; }
|
|
2848
|
+
}
|
|
2849
|
+
return outputParameters;
|
|
2850
|
+
}
|
|
2851
|
+
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;
|
|
2823
2852
|
var e_1, _e, e_2, _f;
|
|
2824
2853
|
return __generator(this, function (_g) {
|
|
2825
2854
|
switch (_g.label) {
|
|
@@ -2844,9 +2873,12 @@
|
|
|
2844
2873
|
};
|
|
2845
2874
|
try {
|
|
2846
2875
|
// Note: Check that all input input parameters are defined
|
|
2847
|
-
for (_a = __values(pipeline.parameters
|
|
2876
|
+
for (_a = __values(pipeline.parameters.filter(function (_a) {
|
|
2877
|
+
var isInput = _a.isInput;
|
|
2878
|
+
return isInput;
|
|
2879
|
+
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
2848
2880
|
parameter = _b.value;
|
|
2849
|
-
if (
|
|
2881
|
+
if (inputParameters[parameter.name] === undefined) {
|
|
2850
2882
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
2851
2883
|
isSuccessful: false,
|
|
2852
2884
|
errors: [
|
|
@@ -2867,6 +2899,44 @@
|
|
|
2867
2899
|
}
|
|
2868
2900
|
finally { if (e_1) throw e_1.error; }
|
|
2869
2901
|
}
|
|
2902
|
+
errors = [];
|
|
2903
|
+
_loop_1 = function (parameterName) {
|
|
2904
|
+
var parameter = pipeline.parameters.find(function (_a) {
|
|
2905
|
+
var name = _a.name;
|
|
2906
|
+
return name === parameterName;
|
|
2907
|
+
});
|
|
2908
|
+
if (parameter === undefined) {
|
|
2909
|
+
errors.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is passed as input parameter")));
|
|
2910
|
+
}
|
|
2911
|
+
else if (parameter.isInput === false) {
|
|
2912
|
+
return { value: deepFreezeWithSameType({
|
|
2913
|
+
isSuccessful: false,
|
|
2914
|
+
errors: [
|
|
2915
|
+
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but is not input")),
|
|
2916
|
+
// <- TODO: !!!!! Test this error
|
|
2917
|
+
],
|
|
2918
|
+
executionReport: executionReport,
|
|
2919
|
+
outputParameters: {},
|
|
2920
|
+
usage: ZERO_USAGE,
|
|
2921
|
+
}) };
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
try {
|
|
2925
|
+
// Note: Check that no extra input parameters are passed
|
|
2926
|
+
for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2927
|
+
parameterName = _d.value;
|
|
2928
|
+
state_1 = _loop_1(parameterName);
|
|
2929
|
+
if (typeof state_1 === "object")
|
|
2930
|
+
return [2 /*return*/, state_1.value];
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2934
|
+
finally {
|
|
2935
|
+
try {
|
|
2936
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
2937
|
+
}
|
|
2938
|
+
finally { if (e_2) throw e_2.error; }
|
|
2939
|
+
}
|
|
2870
2940
|
parametersToPass = inputParameters;
|
|
2871
2941
|
_g.label = 3;
|
|
2872
2942
|
case 3:
|
|
@@ -2883,7 +2953,7 @@
|
|
|
2883
2953
|
unresovedTemplates_1 = __spreadArray([], __read(pipeline.promptTemplates), false);
|
|
2884
2954
|
resolving_1 = [];
|
|
2885
2955
|
loopLimit = LOOP_LIMIT;
|
|
2886
|
-
|
|
2956
|
+
_loop_2 = function () {
|
|
2887
2957
|
var currentTemplate, work_1;
|
|
2888
2958
|
return __generator(this, function (_h) {
|
|
2889
2959
|
switch (_h.label) {
|
|
@@ -2896,12 +2966,16 @@
|
|
|
2896
2966
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
2897
2967
|
});
|
|
2898
2968
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
2899
|
-
throw new UnexpectedError(
|
|
2969
|
+
throw new UnexpectedError(
|
|
2970
|
+
// TODO: [🐎] DRY
|
|
2971
|
+
spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n Can not resolve:\n ".concat(block(unresovedTemplates_1
|
|
2900
2972
|
.map(function (_a) {
|
|
2901
|
-
var resultingParameterName = _a.resultingParameterName;
|
|
2902
|
-
return "- {".concat(resultingParameterName, "}")
|
|
2973
|
+
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
2974
|
+
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
2975
|
+
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
2976
|
+
.join(' and '));
|
|
2903
2977
|
})
|
|
2904
|
-
.join('\n')), "\n\n Resolved
|
|
2978
|
+
.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 "); }));
|
|
2905
2979
|
case 1:
|
|
2906
2980
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
2907
2981
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -2926,7 +3000,7 @@
|
|
|
2926
3000
|
_g.label = 4;
|
|
2927
3001
|
case 4:
|
|
2928
3002
|
if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 6];
|
|
2929
|
-
return [5 /*yield**/,
|
|
3003
|
+
return [5 /*yield**/, _loop_2()];
|
|
2930
3004
|
case 5:
|
|
2931
3005
|
_g.sent();
|
|
2932
3006
|
return [3 /*break*/, 4];
|
|
@@ -2943,41 +3017,20 @@
|
|
|
2943
3017
|
var result = _a.result;
|
|
2944
3018
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
2945
3019
|
})), false));
|
|
3020
|
+
outputParameters_1 = filterJustOutputParameters();
|
|
2946
3021
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
2947
3022
|
isSuccessful: false,
|
|
2948
|
-
errors: [error_1],
|
|
3023
|
+
errors: __spreadArray([error_1], __read(errors), false),
|
|
2949
3024
|
usage: usage_1,
|
|
2950
3025
|
executionReport: executionReport,
|
|
2951
|
-
outputParameters:
|
|
3026
|
+
outputParameters: outputParameters_1,
|
|
2952
3027
|
})];
|
|
2953
3028
|
case 9:
|
|
2954
|
-
outputParameters = {};
|
|
2955
|
-
errors = [];
|
|
2956
|
-
try {
|
|
2957
|
-
// Note: Filter ONLY output parameters
|
|
2958
|
-
for (_c = __values(pipeline.parameters.filter(function (_a) {
|
|
2959
|
-
var isOutput = _a.isOutput;
|
|
2960
|
-
return isOutput;
|
|
2961
|
-
})), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2962
|
-
parameter = _d.value;
|
|
2963
|
-
if (parametersToPass[parameter.name] === undefined) {
|
|
2964
|
-
errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an output parameter but not set in the pipeline")));
|
|
2965
|
-
continue;
|
|
2966
|
-
}
|
|
2967
|
-
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2971
|
-
finally {
|
|
2972
|
-
try {
|
|
2973
|
-
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
2974
|
-
}
|
|
2975
|
-
finally { if (e_2) throw e_2.error; }
|
|
2976
|
-
}
|
|
2977
3029
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
2978
3030
|
var result = _a.result;
|
|
2979
3031
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
2980
3032
|
})), false));
|
|
3033
|
+
outputParameters = filterJustOutputParameters();
|
|
2981
3034
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
2982
3035
|
isSuccessful: true,
|
|
2983
3036
|
errors: errors,
|
|
@@ -2999,6 +3052,7 @@
|
|
|
2999
3052
|
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
3000
3053
|
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
3001
3054
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3055
|
+
* TODO: [💷] !!!! `assertsExecutionSuccessful` should be the method of `PipelineExecutor` result
|
|
3002
3056
|
*/
|
|
3003
3057
|
|
|
3004
3058
|
/**
|