@promptbook/core 0.61.0-28 → 0.61.0-30
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 +34 -32
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/execution/PipelineExecutor.d.ts +16 -4
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +10 -2
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +34 -32
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/execution/PipelineExecutor.d.ts +16 -4
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +10 -2
- package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -1517,7 +1517,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1517
1517
|
});
|
|
1518
1518
|
}
|
|
1519
1519
|
|
|
1520
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1520
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-29",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-29",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-29",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-29",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-29",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-29",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-29",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-29",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
1521
|
|
|
1522
1522
|
var defaultDiacriticsRemovalMap = [
|
|
1523
1523
|
{
|
|
@@ -2522,7 +2522,7 @@ function union() {
|
|
|
2522
2522
|
/**
|
|
2523
2523
|
* The version of the Promptbook library
|
|
2524
2524
|
*/
|
|
2525
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2525
|
+
var PROMPTBOOK_VERSION = '0.61.0-29';
|
|
2526
2526
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2527
2527
|
|
|
2528
2528
|
/**
|
|
@@ -2664,17 +2664,16 @@ function isPassingExpectations(expectations, value) {
|
|
|
2664
2664
|
*/
|
|
2665
2665
|
function createPipelineExecutor(options) {
|
|
2666
2666
|
var _this = this;
|
|
2667
|
-
var
|
|
2668
|
-
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.isVerbose, isVerbose = _d === void 0 ? false : _d;
|
|
2669
|
-
validatePipeline(
|
|
2667
|
+
var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
2668
|
+
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.isVerbose, isVerbose = _d === void 0 ? false : _d, _e = settings.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _e === void 0 ? false : _e;
|
|
2669
|
+
validatePipeline(pipeline);
|
|
2670
2670
|
var llmTools = joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(arrayableToArray(tools.llm)), false));
|
|
2671
|
-
var
|
|
2672
|
-
if (isPipelinePrepared(
|
|
2673
|
-
|
|
2671
|
+
var preparedPipeline;
|
|
2672
|
+
if (isPipelinePrepared(pipeline)) {
|
|
2673
|
+
preparedPipeline = pipeline;
|
|
2674
2674
|
}
|
|
2675
|
-
else {
|
|
2676
|
-
|
|
2677
|
-
console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n ").concat(rawPipeline.sourceFile, "\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
|
|
2675
|
+
else if (isNotPreparedWarningSupressed !== true) {
|
|
2676
|
+
console.warn(spaceTrim$1("\n Pipeline ".concat(pipeline.pipelineUrl || pipeline.sourceFile || pipeline.title, " is not prepared\n\n ").concat(pipeline.sourceFile, "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
|
|
2678
2677
|
}
|
|
2679
2678
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2680
2679
|
// TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
|
|
@@ -2691,9 +2690,9 @@ function createPipelineExecutor(options) {
|
|
|
2691
2690
|
template) {
|
|
2692
2691
|
return __awaiter(this, void 0, void 0, function () {
|
|
2693
2692
|
return __generator(this, function (_a) {
|
|
2694
|
-
// TODO: [♨] Implement Better - use real index and keyword search
|
|
2693
|
+
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {samples}
|
|
2695
2694
|
TODO_USE(template);
|
|
2696
|
-
return [2 /*return*/,
|
|
2695
|
+
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
2697
2696
|
var content = _a.content;
|
|
2698
2697
|
return "- ".concat(content);
|
|
2699
2698
|
}).join('\n')];
|
|
@@ -2766,7 +2765,7 @@ function createPipelineExecutor(options) {
|
|
|
2766
2765
|
case 0:
|
|
2767
2766
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
2768
2767
|
title = currentTemplate.title;
|
|
2769
|
-
priority =
|
|
2768
|
+
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
2770
2769
|
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
2771
2770
|
return [4 /*yield*/, onProgress({
|
|
2772
2771
|
name: name,
|
|
@@ -2870,13 +2869,13 @@ function createPipelineExecutor(options) {
|
|
|
2870
2869
|
case 7:
|
|
2871
2870
|
prompt = {
|
|
2872
2871
|
title: currentTemplate.title,
|
|
2873
|
-
pipelineUrl: "".concat(
|
|
2874
|
-
?
|
|
2872
|
+
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
2873
|
+
? preparedPipeline.pipelineUrl
|
|
2875
2874
|
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
|
|
2876
2875
|
parameters: parameters,
|
|
2877
2876
|
content: preparedContent,
|
|
2878
2877
|
modelRequirements: currentTemplate.modelRequirements,
|
|
2879
|
-
expectations: __assign(__assign({}, (
|
|
2878
|
+
expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
|
|
2880
2879
|
var name = _a.name;
|
|
2881
2880
|
return name === currentTemplate.personaName;
|
|
2882
2881
|
}) || {})), currentTemplate.expectations),
|
|
@@ -3168,7 +3167,7 @@ function createPipelineExecutor(options) {
|
|
|
3168
3167
|
) {
|
|
3169
3168
|
// TODO: [🧠] Maybe put other blockTypes into report
|
|
3170
3169
|
executionReport.promptExecutions.push({
|
|
3171
|
-
prompt: __assign(
|
|
3170
|
+
prompt: __assign({}, prompt),
|
|
3172
3171
|
result: result || undefined,
|
|
3173
3172
|
error: expectError || undefined,
|
|
3174
3173
|
});
|
|
@@ -3209,7 +3208,7 @@ function createPipelineExecutor(options) {
|
|
|
3209
3208
|
var outputParameters = {};
|
|
3210
3209
|
try {
|
|
3211
3210
|
// Note: Filter ONLY output parameters
|
|
3212
|
-
for (var _b = __values(
|
|
3211
|
+
for (var _b = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
3213
3212
|
var isOutput = _a.isOutput;
|
|
3214
3213
|
return isOutput;
|
|
3215
3214
|
})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -3236,29 +3235,29 @@ function createPipelineExecutor(options) {
|
|
|
3236
3235
|
return __generator(this, function (_g) {
|
|
3237
3236
|
switch (_g.label) {
|
|
3238
3237
|
case 0:
|
|
3239
|
-
if (!(
|
|
3240
|
-
return [4 /*yield*/, preparePipeline(
|
|
3238
|
+
if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
|
|
3239
|
+
return [4 /*yield*/, preparePipeline(pipeline, {
|
|
3241
3240
|
llmTools: llmTools,
|
|
3242
3241
|
isVerbose: isVerbose,
|
|
3243
3242
|
maxParallelCount: maxParallelCount,
|
|
3244
3243
|
})];
|
|
3245
3244
|
case 1:
|
|
3246
|
-
|
|
3245
|
+
preparedPipeline = _g.sent();
|
|
3247
3246
|
_g.label = 2;
|
|
3248
3247
|
case 2:
|
|
3249
3248
|
errors = [];
|
|
3250
3249
|
warnings = [];
|
|
3251
3250
|
executionReport = {
|
|
3252
|
-
pipelineUrl:
|
|
3253
|
-
title:
|
|
3251
|
+
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
3252
|
+
title: preparedPipeline.title,
|
|
3254
3253
|
promptbookUsedVersion: PROMPTBOOK_VERSION,
|
|
3255
|
-
promptbookRequestedVersion:
|
|
3256
|
-
description:
|
|
3254
|
+
promptbookRequestedVersion: preparedPipeline.promptbookVersion,
|
|
3255
|
+
description: preparedPipeline.description,
|
|
3257
3256
|
promptExecutions: [],
|
|
3258
3257
|
};
|
|
3259
3258
|
try {
|
|
3260
3259
|
// Note: Check that all input input parameters are defined
|
|
3261
|
-
for (_a = __values(
|
|
3260
|
+
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
3262
3261
|
var isInput = _a.isInput;
|
|
3263
3262
|
return isInput;
|
|
3264
3263
|
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
@@ -3273,6 +3272,7 @@ function createPipelineExecutor(options) {
|
|
|
3273
3272
|
executionReport: executionReport,
|
|
3274
3273
|
outputParameters: {},
|
|
3275
3274
|
usage: ZERO_USAGE,
|
|
3275
|
+
preparedPipeline: preparedPipeline,
|
|
3276
3276
|
})];
|
|
3277
3277
|
}
|
|
3278
3278
|
}
|
|
@@ -3285,7 +3285,7 @@ function createPipelineExecutor(options) {
|
|
|
3285
3285
|
finally { if (e_1) throw e_1.error; }
|
|
3286
3286
|
}
|
|
3287
3287
|
_loop_1 = function (parameterName) {
|
|
3288
|
-
var parameter =
|
|
3288
|
+
var parameter = preparedPipeline.parameters.find(function (_a) {
|
|
3289
3289
|
var name = _a.name;
|
|
3290
3290
|
return name === parameterName;
|
|
3291
3291
|
});
|
|
@@ -3302,6 +3302,7 @@ function createPipelineExecutor(options) {
|
|
|
3302
3302
|
executionReport: executionReport,
|
|
3303
3303
|
outputParameters: {},
|
|
3304
3304
|
usage: ZERO_USAGE,
|
|
3305
|
+
preparedPipeline: preparedPipeline,
|
|
3305
3306
|
}) };
|
|
3306
3307
|
}
|
|
3307
3308
|
};
|
|
@@ -3325,7 +3326,7 @@ function createPipelineExecutor(options) {
|
|
|
3325
3326
|
_g.label = 3;
|
|
3326
3327
|
case 3:
|
|
3327
3328
|
_g.trys.push([3, 8, , 9]);
|
|
3328
|
-
resovedParameterNames_1 =
|
|
3329
|
+
resovedParameterNames_1 = preparedPipeline.parameters
|
|
3329
3330
|
.filter(function (_a) {
|
|
3330
3331
|
var isInput = _a.isInput;
|
|
3331
3332
|
return isInput;
|
|
@@ -3334,7 +3335,7 @@ function createPipelineExecutor(options) {
|
|
|
3334
3335
|
var name = _a.name;
|
|
3335
3336
|
return name;
|
|
3336
3337
|
});
|
|
3337
|
-
unresovedTemplates_1 = __spreadArray([], __read(
|
|
3338
|
+
unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.promptTemplates), false);
|
|
3338
3339
|
resolving_1 = [];
|
|
3339
3340
|
loopLimit = LOOP_LIMIT;
|
|
3340
3341
|
_loop_2 = function () {
|
|
@@ -3411,6 +3412,7 @@ function createPipelineExecutor(options) {
|
|
|
3411
3412
|
usage: usage_1,
|
|
3412
3413
|
executionReport: executionReport,
|
|
3413
3414
|
outputParameters: outputParameters_1,
|
|
3415
|
+
preparedPipeline: preparedPipeline,
|
|
3414
3416
|
})];
|
|
3415
3417
|
case 9:
|
|
3416
3418
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
@@ -3425,6 +3427,7 @@ function createPipelineExecutor(options) {
|
|
|
3425
3427
|
usage: usage,
|
|
3426
3428
|
executionReport: executionReport,
|
|
3427
3429
|
outputParameters: outputParameters,
|
|
3430
|
+
preparedPipeline: preparedPipeline,
|
|
3428
3431
|
})];
|
|
3429
3432
|
}
|
|
3430
3433
|
});
|
|
@@ -3432,8 +3435,6 @@ function createPipelineExecutor(options) {
|
|
|
3432
3435
|
return pipelineExecutor;
|
|
3433
3436
|
}
|
|
3434
3437
|
/**
|
|
3435
|
-
* TODO: !!!!! return `preparedPipeline` from execution
|
|
3436
|
-
* TODO: !!!!! `isNotPreparedWarningSupressed`
|
|
3437
3438
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
3438
3439
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
3439
3440
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
@@ -3493,6 +3494,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
|
|
|
3493
3494
|
outputParameters = result.outputParameters;
|
|
3494
3495
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
3495
3496
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
3497
|
+
// <- TODO: !!!!! Smarter split and filter out empty pieces
|
|
3496
3498
|
if (isVerbose) {
|
|
3497
3499
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
3498
3500
|
}
|