@promptbook/cli 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 +2 -2
- 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
|
@@ -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-29';
|
|
154
154
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
155
155
|
|
|
156
156
|
/**
|
|
@@ -747,7 +747,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
747
747
|
});
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
750
|
+
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"}];
|
|
751
751
|
|
|
752
752
|
/**
|
|
753
753
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -2476,17 +2476,16 @@ function checkExpectations(expectations, value) {
|
|
|
2476
2476
|
*/
|
|
2477
2477
|
function createPipelineExecutor(options) {
|
|
2478
2478
|
var _this = this;
|
|
2479
|
-
var
|
|
2480
|
-
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;
|
|
2481
|
-
validatePipeline(
|
|
2479
|
+
var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
2480
|
+
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;
|
|
2481
|
+
validatePipeline(pipeline);
|
|
2482
2482
|
var llmTools = joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(arrayableToArray(tools.llm)), false));
|
|
2483
|
-
var
|
|
2484
|
-
if (isPipelinePrepared(
|
|
2485
|
-
|
|
2483
|
+
var preparedPipeline;
|
|
2484
|
+
if (isPipelinePrepared(pipeline)) {
|
|
2485
|
+
preparedPipeline = pipeline;
|
|
2486
2486
|
}
|
|
2487
|
-
else {
|
|
2488
|
-
|
|
2489
|
-
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 ")));
|
|
2487
|
+
else if (isNotPreparedWarningSupressed !== true) {
|
|
2488
|
+
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 ")));
|
|
2490
2489
|
}
|
|
2491
2490
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2492
2491
|
// TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
|
|
@@ -2503,9 +2502,9 @@ function createPipelineExecutor(options) {
|
|
|
2503
2502
|
template) {
|
|
2504
2503
|
return __awaiter(this, void 0, void 0, function () {
|
|
2505
2504
|
return __generator(this, function (_a) {
|
|
2506
|
-
// TODO: [♨] Implement Better - use real index and keyword search
|
|
2505
|
+
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {samples}
|
|
2507
2506
|
TODO_USE(template);
|
|
2508
|
-
return [2 /*return*/,
|
|
2507
|
+
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
2509
2508
|
var content = _a.content;
|
|
2510
2509
|
return "- ".concat(content);
|
|
2511
2510
|
}).join('\n')];
|
|
@@ -2578,7 +2577,7 @@ function createPipelineExecutor(options) {
|
|
|
2578
2577
|
case 0:
|
|
2579
2578
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
2580
2579
|
title = currentTemplate.title;
|
|
2581
|
-
priority =
|
|
2580
|
+
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
2582
2581
|
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
2583
2582
|
return [4 /*yield*/, onProgress({
|
|
2584
2583
|
name: name,
|
|
@@ -2682,13 +2681,13 @@ function createPipelineExecutor(options) {
|
|
|
2682
2681
|
case 7:
|
|
2683
2682
|
prompt = {
|
|
2684
2683
|
title: currentTemplate.title,
|
|
2685
|
-
pipelineUrl: "".concat(
|
|
2686
|
-
?
|
|
2684
|
+
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
2685
|
+
? preparedPipeline.pipelineUrl
|
|
2687
2686
|
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
|
|
2688
2687
|
parameters: parameters,
|
|
2689
2688
|
content: preparedContent,
|
|
2690
2689
|
modelRequirements: currentTemplate.modelRequirements,
|
|
2691
|
-
expectations: __assign(__assign({}, (
|
|
2690
|
+
expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
|
|
2692
2691
|
var name = _a.name;
|
|
2693
2692
|
return name === currentTemplate.personaName;
|
|
2694
2693
|
}) || {})), currentTemplate.expectations),
|
|
@@ -2980,7 +2979,7 @@ function createPipelineExecutor(options) {
|
|
|
2980
2979
|
) {
|
|
2981
2980
|
// TODO: [🧠] Maybe put other blockTypes into report
|
|
2982
2981
|
executionReport.promptExecutions.push({
|
|
2983
|
-
prompt: __assign(
|
|
2982
|
+
prompt: __assign({}, prompt),
|
|
2984
2983
|
result: result || undefined,
|
|
2985
2984
|
error: expectError || undefined,
|
|
2986
2985
|
});
|
|
@@ -3021,7 +3020,7 @@ function createPipelineExecutor(options) {
|
|
|
3021
3020
|
var outputParameters = {};
|
|
3022
3021
|
try {
|
|
3023
3022
|
// Note: Filter ONLY output parameters
|
|
3024
|
-
for (var _b = __values(
|
|
3023
|
+
for (var _b = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
3025
3024
|
var isOutput = _a.isOutput;
|
|
3026
3025
|
return isOutput;
|
|
3027
3026
|
})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -3048,29 +3047,29 @@ function createPipelineExecutor(options) {
|
|
|
3048
3047
|
return __generator(this, function (_g) {
|
|
3049
3048
|
switch (_g.label) {
|
|
3050
3049
|
case 0:
|
|
3051
|
-
if (!(
|
|
3052
|
-
return [4 /*yield*/, preparePipeline(
|
|
3050
|
+
if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
|
|
3051
|
+
return [4 /*yield*/, preparePipeline(pipeline, {
|
|
3053
3052
|
llmTools: llmTools,
|
|
3054
3053
|
isVerbose: isVerbose,
|
|
3055
3054
|
maxParallelCount: maxParallelCount,
|
|
3056
3055
|
})];
|
|
3057
3056
|
case 1:
|
|
3058
|
-
|
|
3057
|
+
preparedPipeline = _g.sent();
|
|
3059
3058
|
_g.label = 2;
|
|
3060
3059
|
case 2:
|
|
3061
3060
|
errors = [];
|
|
3062
3061
|
warnings = [];
|
|
3063
3062
|
executionReport = {
|
|
3064
|
-
pipelineUrl:
|
|
3065
|
-
title:
|
|
3063
|
+
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
3064
|
+
title: preparedPipeline.title,
|
|
3066
3065
|
promptbookUsedVersion: PROMPTBOOK_VERSION,
|
|
3067
|
-
promptbookRequestedVersion:
|
|
3068
|
-
description:
|
|
3066
|
+
promptbookRequestedVersion: preparedPipeline.promptbookVersion,
|
|
3067
|
+
description: preparedPipeline.description,
|
|
3069
3068
|
promptExecutions: [],
|
|
3070
3069
|
};
|
|
3071
3070
|
try {
|
|
3072
3071
|
// Note: Check that all input input parameters are defined
|
|
3073
|
-
for (_a = __values(
|
|
3072
|
+
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
3074
3073
|
var isInput = _a.isInput;
|
|
3075
3074
|
return isInput;
|
|
3076
3075
|
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
@@ -3085,6 +3084,7 @@ function createPipelineExecutor(options) {
|
|
|
3085
3084
|
executionReport: executionReport,
|
|
3086
3085
|
outputParameters: {},
|
|
3087
3086
|
usage: ZERO_USAGE,
|
|
3087
|
+
preparedPipeline: preparedPipeline,
|
|
3088
3088
|
})];
|
|
3089
3089
|
}
|
|
3090
3090
|
}
|
|
@@ -3097,7 +3097,7 @@ function createPipelineExecutor(options) {
|
|
|
3097
3097
|
finally { if (e_1) throw e_1.error; }
|
|
3098
3098
|
}
|
|
3099
3099
|
_loop_1 = function (parameterName) {
|
|
3100
|
-
var parameter =
|
|
3100
|
+
var parameter = preparedPipeline.parameters.find(function (_a) {
|
|
3101
3101
|
var name = _a.name;
|
|
3102
3102
|
return name === parameterName;
|
|
3103
3103
|
});
|
|
@@ -3114,6 +3114,7 @@ function createPipelineExecutor(options) {
|
|
|
3114
3114
|
executionReport: executionReport,
|
|
3115
3115
|
outputParameters: {},
|
|
3116
3116
|
usage: ZERO_USAGE,
|
|
3117
|
+
preparedPipeline: preparedPipeline,
|
|
3117
3118
|
}) };
|
|
3118
3119
|
}
|
|
3119
3120
|
};
|
|
@@ -3137,7 +3138,7 @@ function createPipelineExecutor(options) {
|
|
|
3137
3138
|
_g.label = 3;
|
|
3138
3139
|
case 3:
|
|
3139
3140
|
_g.trys.push([3, 8, , 9]);
|
|
3140
|
-
resovedParameterNames_1 =
|
|
3141
|
+
resovedParameterNames_1 = preparedPipeline.parameters
|
|
3141
3142
|
.filter(function (_a) {
|
|
3142
3143
|
var isInput = _a.isInput;
|
|
3143
3144
|
return isInput;
|
|
@@ -3146,7 +3147,7 @@ function createPipelineExecutor(options) {
|
|
|
3146
3147
|
var name = _a.name;
|
|
3147
3148
|
return name;
|
|
3148
3149
|
});
|
|
3149
|
-
unresovedTemplates_1 = __spreadArray([], __read(
|
|
3150
|
+
unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.promptTemplates), false);
|
|
3150
3151
|
resolving_1 = [];
|
|
3151
3152
|
loopLimit = LOOP_LIMIT;
|
|
3152
3153
|
_loop_2 = function () {
|
|
@@ -3223,6 +3224,7 @@ function createPipelineExecutor(options) {
|
|
|
3223
3224
|
usage: usage_1,
|
|
3224
3225
|
executionReport: executionReport,
|
|
3225
3226
|
outputParameters: outputParameters_1,
|
|
3227
|
+
preparedPipeline: preparedPipeline,
|
|
3226
3228
|
})];
|
|
3227
3229
|
case 9:
|
|
3228
3230
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
@@ -3237,6 +3239,7 @@ function createPipelineExecutor(options) {
|
|
|
3237
3239
|
usage: usage,
|
|
3238
3240
|
executionReport: executionReport,
|
|
3239
3241
|
outputParameters: outputParameters,
|
|
3242
|
+
preparedPipeline: preparedPipeline,
|
|
3240
3243
|
})];
|
|
3241
3244
|
}
|
|
3242
3245
|
});
|
|
@@ -3244,8 +3247,6 @@ function createPipelineExecutor(options) {
|
|
|
3244
3247
|
return pipelineExecutor;
|
|
3245
3248
|
}
|
|
3246
3249
|
/**
|
|
3247
|
-
* TODO: !!!!! return `preparedPipeline` from execution
|
|
3248
|
-
* TODO: !!!!! `isNotPreparedWarningSupressed`
|
|
3249
3250
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
3250
3251
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
3251
3252
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
@@ -3305,6 +3306,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
|
|
|
3305
3306
|
outputParameters = result.outputParameters;
|
|
3306
3307
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
3307
3308
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
3309
|
+
// <- TODO: !!!!! Smarter split and filter out empty pieces
|
|
3308
3310
|
if (isVerbose) {
|
|
3309
3311
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
3310
3312
|
}
|