@promptbook/core 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 +1 -1
- 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
package/umd/index.umd.js
CHANGED
|
@@ -855,7 +855,9 @@
|
|
|
855
855
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
856
856
|
});
|
|
857
857
|
if (currentlyResovedTemplates.length === 0) {
|
|
858
|
-
throw new PipelineLogicError(
|
|
858
|
+
throw new PipelineLogicError(
|
|
859
|
+
// TODO: [🐎] DRY
|
|
860
|
+
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
|
|
859
861
|
.map(function (_a) {
|
|
860
862
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
861
863
|
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
@@ -1452,7 +1454,7 @@
|
|
|
1452
1454
|
});
|
|
1453
1455
|
}
|
|
1454
1456
|
|
|
1455
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1457
|
+
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"}];
|
|
1456
1458
|
|
|
1457
1459
|
var defaultDiacriticsRemovalMap = [
|
|
1458
1460
|
{
|
|
@@ -2446,7 +2448,7 @@
|
|
|
2446
2448
|
/**
|
|
2447
2449
|
* The version of the Promptbook library
|
|
2448
2450
|
*/
|
|
2449
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2451
|
+
var PROMPTBOOK_VERSION = '0.61.0-20';
|
|
2450
2452
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2451
2453
|
|
|
2452
2454
|
/**
|
|
@@ -3100,7 +3102,34 @@
|
|
|
3100
3102
|
});
|
|
3101
3103
|
});
|
|
3102
3104
|
}
|
|
3103
|
-
|
|
3105
|
+
function filterJustOutputParameters() {
|
|
3106
|
+
var e_9, _a;
|
|
3107
|
+
var outputParameters = {};
|
|
3108
|
+
try {
|
|
3109
|
+
// Note: Filter ONLY output parameters
|
|
3110
|
+
for (var _b = __values(pipeline.parameters.filter(function (_a) {
|
|
3111
|
+
var isOutput = _a.isOutput;
|
|
3112
|
+
return isOutput;
|
|
3113
|
+
})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3114
|
+
var parameter = _c.value;
|
|
3115
|
+
if (parametersToPass[parameter.name] === undefined) {
|
|
3116
|
+
// [4]
|
|
3117
|
+
errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an output parameter but not set in the pipeline")));
|
|
3118
|
+
continue;
|
|
3119
|
+
}
|
|
3120
|
+
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
3124
|
+
finally {
|
|
3125
|
+
try {
|
|
3126
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3127
|
+
}
|
|
3128
|
+
finally { if (e_9) throw e_9.error; }
|
|
3129
|
+
}
|
|
3130
|
+
return outputParameters;
|
|
3131
|
+
}
|
|
3132
|
+
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;
|
|
3104
3133
|
var e_1, _e, e_2, _f;
|
|
3105
3134
|
return __generator(this, function (_g) {
|
|
3106
3135
|
switch (_g.label) {
|
|
@@ -3125,9 +3154,12 @@
|
|
|
3125
3154
|
};
|
|
3126
3155
|
try {
|
|
3127
3156
|
// Note: Check that all input input parameters are defined
|
|
3128
|
-
for (_a = __values(pipeline.parameters
|
|
3157
|
+
for (_a = __values(pipeline.parameters.filter(function (_a) {
|
|
3158
|
+
var isInput = _a.isInput;
|
|
3159
|
+
return isInput;
|
|
3160
|
+
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
3129
3161
|
parameter = _b.value;
|
|
3130
|
-
if (
|
|
3162
|
+
if (inputParameters[parameter.name] === undefined) {
|
|
3131
3163
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
3132
3164
|
isSuccessful: false,
|
|
3133
3165
|
errors: [
|
|
@@ -3148,6 +3180,44 @@
|
|
|
3148
3180
|
}
|
|
3149
3181
|
finally { if (e_1) throw e_1.error; }
|
|
3150
3182
|
}
|
|
3183
|
+
errors = [];
|
|
3184
|
+
_loop_1 = function (parameterName) {
|
|
3185
|
+
var parameter = pipeline.parameters.find(function (_a) {
|
|
3186
|
+
var name = _a.name;
|
|
3187
|
+
return name === parameterName;
|
|
3188
|
+
});
|
|
3189
|
+
if (parameter === undefined) {
|
|
3190
|
+
errors.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is passed as input parameter")));
|
|
3191
|
+
}
|
|
3192
|
+
else if (parameter.isInput === false) {
|
|
3193
|
+
return { value: deepFreezeWithSameType({
|
|
3194
|
+
isSuccessful: false,
|
|
3195
|
+
errors: [
|
|
3196
|
+
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but is not input")),
|
|
3197
|
+
// <- TODO: !!!!! Test this error
|
|
3198
|
+
],
|
|
3199
|
+
executionReport: executionReport,
|
|
3200
|
+
outputParameters: {},
|
|
3201
|
+
usage: ZERO_USAGE,
|
|
3202
|
+
}) };
|
|
3203
|
+
}
|
|
3204
|
+
};
|
|
3205
|
+
try {
|
|
3206
|
+
// Note: Check that no extra input parameters are passed
|
|
3207
|
+
for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3208
|
+
parameterName = _d.value;
|
|
3209
|
+
state_1 = _loop_1(parameterName);
|
|
3210
|
+
if (typeof state_1 === "object")
|
|
3211
|
+
return [2 /*return*/, state_1.value];
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3215
|
+
finally {
|
|
3216
|
+
try {
|
|
3217
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
3218
|
+
}
|
|
3219
|
+
finally { if (e_2) throw e_2.error; }
|
|
3220
|
+
}
|
|
3151
3221
|
parametersToPass = inputParameters;
|
|
3152
3222
|
_g.label = 3;
|
|
3153
3223
|
case 3:
|
|
@@ -3164,7 +3234,7 @@
|
|
|
3164
3234
|
unresovedTemplates_1 = __spreadArray([], __read(pipeline.promptTemplates), false);
|
|
3165
3235
|
resolving_1 = [];
|
|
3166
3236
|
loopLimit = LOOP_LIMIT;
|
|
3167
|
-
|
|
3237
|
+
_loop_2 = function () {
|
|
3168
3238
|
var currentTemplate, work_1;
|
|
3169
3239
|
return __generator(this, function (_h) {
|
|
3170
3240
|
switch (_h.label) {
|
|
@@ -3177,12 +3247,16 @@
|
|
|
3177
3247
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
3178
3248
|
});
|
|
3179
3249
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
3180
|
-
throw new UnexpectedError(
|
|
3250
|
+
throw new UnexpectedError(
|
|
3251
|
+
// TODO: [🐎] DRY
|
|
3252
|
+
spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n Can not resolve:\n ".concat(block(unresovedTemplates_1
|
|
3181
3253
|
.map(function (_a) {
|
|
3182
|
-
var resultingParameterName = _a.resultingParameterName;
|
|
3183
|
-
return "- {".concat(resultingParameterName, "}")
|
|
3254
|
+
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
3255
|
+
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
3256
|
+
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
3257
|
+
.join(' and '));
|
|
3184
3258
|
})
|
|
3185
|
-
.join('\n')), "\n\n Resolved
|
|
3259
|
+
.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 "); }));
|
|
3186
3260
|
case 1:
|
|
3187
3261
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
3188
3262
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -3207,7 +3281,7 @@
|
|
|
3207
3281
|
_g.label = 4;
|
|
3208
3282
|
case 4:
|
|
3209
3283
|
if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 6];
|
|
3210
|
-
return [5 /*yield**/,
|
|
3284
|
+
return [5 /*yield**/, _loop_2()];
|
|
3211
3285
|
case 5:
|
|
3212
3286
|
_g.sent();
|
|
3213
3287
|
return [3 /*break*/, 4];
|
|
@@ -3224,41 +3298,20 @@
|
|
|
3224
3298
|
var result = _a.result;
|
|
3225
3299
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3226
3300
|
})), false));
|
|
3301
|
+
outputParameters_1 = filterJustOutputParameters();
|
|
3227
3302
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
3228
3303
|
isSuccessful: false,
|
|
3229
|
-
errors: [error_1],
|
|
3304
|
+
errors: __spreadArray([error_1], __read(errors), false),
|
|
3230
3305
|
usage: usage_1,
|
|
3231
3306
|
executionReport: executionReport,
|
|
3232
|
-
outputParameters:
|
|
3307
|
+
outputParameters: outputParameters_1,
|
|
3233
3308
|
})];
|
|
3234
3309
|
case 9:
|
|
3235
|
-
outputParameters = {};
|
|
3236
|
-
errors = [];
|
|
3237
|
-
try {
|
|
3238
|
-
// Note: Filter ONLY output parameters
|
|
3239
|
-
for (_c = __values(pipeline.parameters.filter(function (_a) {
|
|
3240
|
-
var isOutput = _a.isOutput;
|
|
3241
|
-
return isOutput;
|
|
3242
|
-
})), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3243
|
-
parameter = _d.value;
|
|
3244
|
-
if (parametersToPass[parameter.name] === undefined) {
|
|
3245
|
-
errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an output parameter but not set in the pipeline")));
|
|
3246
|
-
continue;
|
|
3247
|
-
}
|
|
3248
|
-
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
3249
|
-
}
|
|
3250
|
-
}
|
|
3251
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3252
|
-
finally {
|
|
3253
|
-
try {
|
|
3254
|
-
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
3255
|
-
}
|
|
3256
|
-
finally { if (e_2) throw e_2.error; }
|
|
3257
|
-
}
|
|
3258
3310
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
3259
3311
|
var result = _a.result;
|
|
3260
3312
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3261
3313
|
})), false));
|
|
3314
|
+
outputParameters = filterJustOutputParameters();
|
|
3262
3315
|
return [2 /*return*/, deepFreezeWithSameType({
|
|
3263
3316
|
isSuccessful: true,
|
|
3264
3317
|
errors: errors,
|
|
@@ -3280,6 +3333,7 @@
|
|
|
3280
3333
|
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
3281
3334
|
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
3282
3335
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3336
|
+
* TODO: [💷] !!!! `assertsExecutionSuccessful` should be the method of `PipelineExecutor` result
|
|
3283
3337
|
*/
|
|
3284
3338
|
|
|
3285
3339
|
/**
|