@promptbook/core 0.61.0-28 → 0.61.0-29
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 +35 -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 +35 -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-28",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-28",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-28",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-28",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-28",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-28",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-28",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-28",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-28';
|
|
2526
2526
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2527
2527
|
|
|
2528
2528
|
/**
|
|
@@ -2664,17 +2664,17 @@ 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
|
-
// TODO: !!!!!
|
|
2677
|
-
console.warn(spaceTrim$1("\n Pipeline ".concat(
|
|
2675
|
+
else if (isNotPreparedWarningSupressed !== true) {
|
|
2676
|
+
// TODO: !!!!! Test that this work as intended together with prepared pipeline
|
|
2677
|
+
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
2678
|
}
|
|
2679
2679
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2680
2680
|
// TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
|
|
@@ -2691,9 +2691,9 @@ function createPipelineExecutor(options) {
|
|
|
2691
2691
|
template) {
|
|
2692
2692
|
return __awaiter(this, void 0, void 0, function () {
|
|
2693
2693
|
return __generator(this, function (_a) {
|
|
2694
|
-
// TODO: [♨] Implement Better - use real index and keyword search
|
|
2694
|
+
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {samples}
|
|
2695
2695
|
TODO_USE(template);
|
|
2696
|
-
return [2 /*return*/,
|
|
2696
|
+
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
2697
2697
|
var content = _a.content;
|
|
2698
2698
|
return "- ".concat(content);
|
|
2699
2699
|
}).join('\n')];
|
|
@@ -2766,7 +2766,7 @@ function createPipelineExecutor(options) {
|
|
|
2766
2766
|
case 0:
|
|
2767
2767
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
2768
2768
|
title = currentTemplate.title;
|
|
2769
|
-
priority =
|
|
2769
|
+
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
2770
2770
|
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
2771
2771
|
return [4 /*yield*/, onProgress({
|
|
2772
2772
|
name: name,
|
|
@@ -2870,13 +2870,13 @@ function createPipelineExecutor(options) {
|
|
|
2870
2870
|
case 7:
|
|
2871
2871
|
prompt = {
|
|
2872
2872
|
title: currentTemplate.title,
|
|
2873
|
-
pipelineUrl: "".concat(
|
|
2874
|
-
?
|
|
2873
|
+
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
2874
|
+
? preparedPipeline.pipelineUrl
|
|
2875
2875
|
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
|
|
2876
2876
|
parameters: parameters,
|
|
2877
2877
|
content: preparedContent,
|
|
2878
2878
|
modelRequirements: currentTemplate.modelRequirements,
|
|
2879
|
-
expectations: __assign(__assign({}, (
|
|
2879
|
+
expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
|
|
2880
2880
|
var name = _a.name;
|
|
2881
2881
|
return name === currentTemplate.personaName;
|
|
2882
2882
|
}) || {})), currentTemplate.expectations),
|
|
@@ -3168,7 +3168,7 @@ function createPipelineExecutor(options) {
|
|
|
3168
3168
|
) {
|
|
3169
3169
|
// TODO: [🧠] Maybe put other blockTypes into report
|
|
3170
3170
|
executionReport.promptExecutions.push({
|
|
3171
|
-
prompt: __assign(
|
|
3171
|
+
prompt: __assign({}, prompt),
|
|
3172
3172
|
result: result || undefined,
|
|
3173
3173
|
error: expectError || undefined,
|
|
3174
3174
|
});
|
|
@@ -3209,7 +3209,7 @@ function createPipelineExecutor(options) {
|
|
|
3209
3209
|
var outputParameters = {};
|
|
3210
3210
|
try {
|
|
3211
3211
|
// Note: Filter ONLY output parameters
|
|
3212
|
-
for (var _b = __values(
|
|
3212
|
+
for (var _b = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
3213
3213
|
var isOutput = _a.isOutput;
|
|
3214
3214
|
return isOutput;
|
|
3215
3215
|
})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -3236,29 +3236,29 @@ function createPipelineExecutor(options) {
|
|
|
3236
3236
|
return __generator(this, function (_g) {
|
|
3237
3237
|
switch (_g.label) {
|
|
3238
3238
|
case 0:
|
|
3239
|
-
if (!(
|
|
3240
|
-
return [4 /*yield*/, preparePipeline(
|
|
3239
|
+
if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
|
|
3240
|
+
return [4 /*yield*/, preparePipeline(pipeline, {
|
|
3241
3241
|
llmTools: llmTools,
|
|
3242
3242
|
isVerbose: isVerbose,
|
|
3243
3243
|
maxParallelCount: maxParallelCount,
|
|
3244
3244
|
})];
|
|
3245
3245
|
case 1:
|
|
3246
|
-
|
|
3246
|
+
preparedPipeline = _g.sent();
|
|
3247
3247
|
_g.label = 2;
|
|
3248
3248
|
case 2:
|
|
3249
3249
|
errors = [];
|
|
3250
3250
|
warnings = [];
|
|
3251
3251
|
executionReport = {
|
|
3252
|
-
pipelineUrl:
|
|
3253
|
-
title:
|
|
3252
|
+
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
3253
|
+
title: preparedPipeline.title,
|
|
3254
3254
|
promptbookUsedVersion: PROMPTBOOK_VERSION,
|
|
3255
|
-
promptbookRequestedVersion:
|
|
3256
|
-
description:
|
|
3255
|
+
promptbookRequestedVersion: preparedPipeline.promptbookVersion,
|
|
3256
|
+
description: preparedPipeline.description,
|
|
3257
3257
|
promptExecutions: [],
|
|
3258
3258
|
};
|
|
3259
3259
|
try {
|
|
3260
3260
|
// Note: Check that all input input parameters are defined
|
|
3261
|
-
for (_a = __values(
|
|
3261
|
+
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
3262
3262
|
var isInput = _a.isInput;
|
|
3263
3263
|
return isInput;
|
|
3264
3264
|
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
@@ -3273,6 +3273,7 @@ function createPipelineExecutor(options) {
|
|
|
3273
3273
|
executionReport: executionReport,
|
|
3274
3274
|
outputParameters: {},
|
|
3275
3275
|
usage: ZERO_USAGE,
|
|
3276
|
+
preparedPipeline: preparedPipeline,
|
|
3276
3277
|
})];
|
|
3277
3278
|
}
|
|
3278
3279
|
}
|
|
@@ -3285,7 +3286,7 @@ function createPipelineExecutor(options) {
|
|
|
3285
3286
|
finally { if (e_1) throw e_1.error; }
|
|
3286
3287
|
}
|
|
3287
3288
|
_loop_1 = function (parameterName) {
|
|
3288
|
-
var parameter =
|
|
3289
|
+
var parameter = preparedPipeline.parameters.find(function (_a) {
|
|
3289
3290
|
var name = _a.name;
|
|
3290
3291
|
return name === parameterName;
|
|
3291
3292
|
});
|
|
@@ -3302,6 +3303,7 @@ function createPipelineExecutor(options) {
|
|
|
3302
3303
|
executionReport: executionReport,
|
|
3303
3304
|
outputParameters: {},
|
|
3304
3305
|
usage: ZERO_USAGE,
|
|
3306
|
+
preparedPipeline: preparedPipeline,
|
|
3305
3307
|
}) };
|
|
3306
3308
|
}
|
|
3307
3309
|
};
|
|
@@ -3325,7 +3327,7 @@ function createPipelineExecutor(options) {
|
|
|
3325
3327
|
_g.label = 3;
|
|
3326
3328
|
case 3:
|
|
3327
3329
|
_g.trys.push([3, 8, , 9]);
|
|
3328
|
-
resovedParameterNames_1 =
|
|
3330
|
+
resovedParameterNames_1 = preparedPipeline.parameters
|
|
3329
3331
|
.filter(function (_a) {
|
|
3330
3332
|
var isInput = _a.isInput;
|
|
3331
3333
|
return isInput;
|
|
@@ -3334,7 +3336,7 @@ function createPipelineExecutor(options) {
|
|
|
3334
3336
|
var name = _a.name;
|
|
3335
3337
|
return name;
|
|
3336
3338
|
});
|
|
3337
|
-
unresovedTemplates_1 = __spreadArray([], __read(
|
|
3339
|
+
unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.promptTemplates), false);
|
|
3338
3340
|
resolving_1 = [];
|
|
3339
3341
|
loopLimit = LOOP_LIMIT;
|
|
3340
3342
|
_loop_2 = function () {
|
|
@@ -3411,6 +3413,7 @@ function createPipelineExecutor(options) {
|
|
|
3411
3413
|
usage: usage_1,
|
|
3412
3414
|
executionReport: executionReport,
|
|
3413
3415
|
outputParameters: outputParameters_1,
|
|
3416
|
+
preparedPipeline: preparedPipeline,
|
|
3414
3417
|
})];
|
|
3415
3418
|
case 9:
|
|
3416
3419
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
@@ -3425,6 +3428,7 @@ function createPipelineExecutor(options) {
|
|
|
3425
3428
|
usage: usage,
|
|
3426
3429
|
executionReport: executionReport,
|
|
3427
3430
|
outputParameters: outputParameters,
|
|
3431
|
+
preparedPipeline: preparedPipeline,
|
|
3428
3432
|
})];
|
|
3429
3433
|
}
|
|
3430
3434
|
});
|
|
@@ -3432,8 +3436,6 @@ function createPipelineExecutor(options) {
|
|
|
3432
3436
|
return pipelineExecutor;
|
|
3433
3437
|
}
|
|
3434
3438
|
/**
|
|
3435
|
-
* TODO: !!!!! return `preparedPipeline` from execution
|
|
3436
|
-
* TODO: !!!!! `isNotPreparedWarningSupressed`
|
|
3437
3439
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
3438
3440
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
3439
3441
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
@@ -3493,6 +3495,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
|
|
|
3493
3495
|
outputParameters = result.outputParameters;
|
|
3494
3496
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
3495
3497
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
3498
|
+
// <- TODO: !!!!! Smarter split and filter out empty pieces
|
|
3496
3499
|
if (isVerbose) {
|
|
3497
3500
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
3498
3501
|
}
|