@promptbook/node 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
|
@@ -654,7 +654,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
654
654
|
});
|
|
655
655
|
}
|
|
656
656
|
|
|
657
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
657
|
+
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"}];
|
|
658
658
|
|
|
659
659
|
/**
|
|
660
660
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -2268,7 +2268,7 @@ function union() {
|
|
|
2268
2268
|
/**
|
|
2269
2269
|
* The version of the Promptbook library
|
|
2270
2270
|
*/
|
|
2271
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2271
|
+
var PROMPTBOOK_VERSION = '0.61.0-29';
|
|
2272
2272
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2273
2273
|
|
|
2274
2274
|
/**
|
|
@@ -2389,17 +2389,16 @@ function checkExpectations(expectations, value) {
|
|
|
2389
2389
|
*/
|
|
2390
2390
|
function createPipelineExecutor(options) {
|
|
2391
2391
|
var _this = this;
|
|
2392
|
-
var
|
|
2393
|
-
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;
|
|
2394
|
-
validatePipeline(
|
|
2392
|
+
var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
2393
|
+
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;
|
|
2394
|
+
validatePipeline(pipeline);
|
|
2395
2395
|
var llmTools = joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(arrayableToArray(tools.llm)), false));
|
|
2396
|
-
var
|
|
2397
|
-
if (isPipelinePrepared(
|
|
2398
|
-
|
|
2396
|
+
var preparedPipeline;
|
|
2397
|
+
if (isPipelinePrepared(pipeline)) {
|
|
2398
|
+
preparedPipeline = pipeline;
|
|
2399
2399
|
}
|
|
2400
|
-
else {
|
|
2401
|
-
|
|
2402
|
-
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 ")));
|
|
2400
|
+
else if (isNotPreparedWarningSupressed !== true) {
|
|
2401
|
+
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 ")));
|
|
2403
2402
|
}
|
|
2404
2403
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2405
2404
|
// TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
|
|
@@ -2416,9 +2415,9 @@ function createPipelineExecutor(options) {
|
|
|
2416
2415
|
template) {
|
|
2417
2416
|
return __awaiter(this, void 0, void 0, function () {
|
|
2418
2417
|
return __generator(this, function (_a) {
|
|
2419
|
-
// TODO: [♨] Implement Better - use real index and keyword search
|
|
2418
|
+
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {samples}
|
|
2420
2419
|
TODO_USE(template);
|
|
2421
|
-
return [2 /*return*/,
|
|
2420
|
+
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
2422
2421
|
var content = _a.content;
|
|
2423
2422
|
return "- ".concat(content);
|
|
2424
2423
|
}).join('\n')];
|
|
@@ -2491,7 +2490,7 @@ function createPipelineExecutor(options) {
|
|
|
2491
2490
|
case 0:
|
|
2492
2491
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
2493
2492
|
title = currentTemplate.title;
|
|
2494
|
-
priority =
|
|
2493
|
+
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
2495
2494
|
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
2496
2495
|
return [4 /*yield*/, onProgress({
|
|
2497
2496
|
name: name,
|
|
@@ -2595,13 +2594,13 @@ function createPipelineExecutor(options) {
|
|
|
2595
2594
|
case 7:
|
|
2596
2595
|
prompt = {
|
|
2597
2596
|
title: currentTemplate.title,
|
|
2598
|
-
pipelineUrl: "".concat(
|
|
2599
|
-
?
|
|
2597
|
+
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
2598
|
+
? preparedPipeline.pipelineUrl
|
|
2600
2599
|
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
|
|
2601
2600
|
parameters: parameters,
|
|
2602
2601
|
content: preparedContent,
|
|
2603
2602
|
modelRequirements: currentTemplate.modelRequirements,
|
|
2604
|
-
expectations: __assign(__assign({}, (
|
|
2603
|
+
expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
|
|
2605
2604
|
var name = _a.name;
|
|
2606
2605
|
return name === currentTemplate.personaName;
|
|
2607
2606
|
}) || {})), currentTemplate.expectations),
|
|
@@ -2893,7 +2892,7 @@ function createPipelineExecutor(options) {
|
|
|
2893
2892
|
) {
|
|
2894
2893
|
// TODO: [🧠] Maybe put other blockTypes into report
|
|
2895
2894
|
executionReport.promptExecutions.push({
|
|
2896
|
-
prompt: __assign(
|
|
2895
|
+
prompt: __assign({}, prompt),
|
|
2897
2896
|
result: result || undefined,
|
|
2898
2897
|
error: expectError || undefined,
|
|
2899
2898
|
});
|
|
@@ -2934,7 +2933,7 @@ function createPipelineExecutor(options) {
|
|
|
2934
2933
|
var outputParameters = {};
|
|
2935
2934
|
try {
|
|
2936
2935
|
// Note: Filter ONLY output parameters
|
|
2937
|
-
for (var _b = __values(
|
|
2936
|
+
for (var _b = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
2938
2937
|
var isOutput = _a.isOutput;
|
|
2939
2938
|
return isOutput;
|
|
2940
2939
|
})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -2961,29 +2960,29 @@ function createPipelineExecutor(options) {
|
|
|
2961
2960
|
return __generator(this, function (_g) {
|
|
2962
2961
|
switch (_g.label) {
|
|
2963
2962
|
case 0:
|
|
2964
|
-
if (!(
|
|
2965
|
-
return [4 /*yield*/, preparePipeline(
|
|
2963
|
+
if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
|
|
2964
|
+
return [4 /*yield*/, preparePipeline(pipeline, {
|
|
2966
2965
|
llmTools: llmTools,
|
|
2967
2966
|
isVerbose: isVerbose,
|
|
2968
2967
|
maxParallelCount: maxParallelCount,
|
|
2969
2968
|
})];
|
|
2970
2969
|
case 1:
|
|
2971
|
-
|
|
2970
|
+
preparedPipeline = _g.sent();
|
|
2972
2971
|
_g.label = 2;
|
|
2973
2972
|
case 2:
|
|
2974
2973
|
errors = [];
|
|
2975
2974
|
warnings = [];
|
|
2976
2975
|
executionReport = {
|
|
2977
|
-
pipelineUrl:
|
|
2978
|
-
title:
|
|
2976
|
+
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
2977
|
+
title: preparedPipeline.title,
|
|
2979
2978
|
promptbookUsedVersion: PROMPTBOOK_VERSION,
|
|
2980
|
-
promptbookRequestedVersion:
|
|
2981
|
-
description:
|
|
2979
|
+
promptbookRequestedVersion: preparedPipeline.promptbookVersion,
|
|
2980
|
+
description: preparedPipeline.description,
|
|
2982
2981
|
promptExecutions: [],
|
|
2983
2982
|
};
|
|
2984
2983
|
try {
|
|
2985
2984
|
// Note: Check that all input input parameters are defined
|
|
2986
|
-
for (_a = __values(
|
|
2985
|
+
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
2987
2986
|
var isInput = _a.isInput;
|
|
2988
2987
|
return isInput;
|
|
2989
2988
|
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
@@ -2998,6 +2997,7 @@ function createPipelineExecutor(options) {
|
|
|
2998
2997
|
executionReport: executionReport,
|
|
2999
2998
|
outputParameters: {},
|
|
3000
2999
|
usage: ZERO_USAGE,
|
|
3000
|
+
preparedPipeline: preparedPipeline,
|
|
3001
3001
|
})];
|
|
3002
3002
|
}
|
|
3003
3003
|
}
|
|
@@ -3010,7 +3010,7 @@ function createPipelineExecutor(options) {
|
|
|
3010
3010
|
finally { if (e_1) throw e_1.error; }
|
|
3011
3011
|
}
|
|
3012
3012
|
_loop_1 = function (parameterName) {
|
|
3013
|
-
var parameter =
|
|
3013
|
+
var parameter = preparedPipeline.parameters.find(function (_a) {
|
|
3014
3014
|
var name = _a.name;
|
|
3015
3015
|
return name === parameterName;
|
|
3016
3016
|
});
|
|
@@ -3027,6 +3027,7 @@ function createPipelineExecutor(options) {
|
|
|
3027
3027
|
executionReport: executionReport,
|
|
3028
3028
|
outputParameters: {},
|
|
3029
3029
|
usage: ZERO_USAGE,
|
|
3030
|
+
preparedPipeline: preparedPipeline,
|
|
3030
3031
|
}) };
|
|
3031
3032
|
}
|
|
3032
3033
|
};
|
|
@@ -3050,7 +3051,7 @@ function createPipelineExecutor(options) {
|
|
|
3050
3051
|
_g.label = 3;
|
|
3051
3052
|
case 3:
|
|
3052
3053
|
_g.trys.push([3, 8, , 9]);
|
|
3053
|
-
resovedParameterNames_1 =
|
|
3054
|
+
resovedParameterNames_1 = preparedPipeline.parameters
|
|
3054
3055
|
.filter(function (_a) {
|
|
3055
3056
|
var isInput = _a.isInput;
|
|
3056
3057
|
return isInput;
|
|
@@ -3059,7 +3060,7 @@ function createPipelineExecutor(options) {
|
|
|
3059
3060
|
var name = _a.name;
|
|
3060
3061
|
return name;
|
|
3061
3062
|
});
|
|
3062
|
-
unresovedTemplates_1 = __spreadArray([], __read(
|
|
3063
|
+
unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.promptTemplates), false);
|
|
3063
3064
|
resolving_1 = [];
|
|
3064
3065
|
loopLimit = LOOP_LIMIT;
|
|
3065
3066
|
_loop_2 = function () {
|
|
@@ -3136,6 +3137,7 @@ function createPipelineExecutor(options) {
|
|
|
3136
3137
|
usage: usage_1,
|
|
3137
3138
|
executionReport: executionReport,
|
|
3138
3139
|
outputParameters: outputParameters_1,
|
|
3140
|
+
preparedPipeline: preparedPipeline,
|
|
3139
3141
|
})];
|
|
3140
3142
|
case 9:
|
|
3141
3143
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
@@ -3150,6 +3152,7 @@ function createPipelineExecutor(options) {
|
|
|
3150
3152
|
usage: usage,
|
|
3151
3153
|
executionReport: executionReport,
|
|
3152
3154
|
outputParameters: outputParameters,
|
|
3155
|
+
preparedPipeline: preparedPipeline,
|
|
3153
3156
|
})];
|
|
3154
3157
|
}
|
|
3155
3158
|
});
|
|
@@ -3157,8 +3160,6 @@ function createPipelineExecutor(options) {
|
|
|
3157
3160
|
return pipelineExecutor;
|
|
3158
3161
|
}
|
|
3159
3162
|
/**
|
|
3160
|
-
* TODO: !!!!! return `preparedPipeline` from execution
|
|
3161
|
-
* TODO: !!!!! `isNotPreparedWarningSupressed`
|
|
3162
3163
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
3163
3164
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
3164
3165
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
@@ -3218,6 +3219,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
|
|
|
3218
3219
|
outputParameters = result.outputParameters;
|
|
3219
3220
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
3220
3221
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
3222
|
+
// <- TODO: !!!!! Smarter split and filter out empty pieces
|
|
3221
3223
|
if (isVerbose) {
|
|
3222
3224
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
3223
3225
|
}
|