@promptbook/core 0.67.6 → 0.67.8
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
CHANGED
|
@@ -9,7 +9,7 @@ import moment from 'moment';
|
|
|
9
9
|
/**
|
|
10
10
|
* The version of the Promptbook library
|
|
11
11
|
*/
|
|
12
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
12
|
+
var PROMPTBOOK_VERSION = '0.67.7';
|
|
13
13
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
14
14
|
|
|
15
15
|
/*! *****************************************************************************
|
|
@@ -1779,7 +1779,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1779
1779
|
});
|
|
1780
1780
|
}
|
|
1781
1781
|
|
|
1782
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
1782
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.7",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.67.7",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.67.7",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"},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:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.67.7",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"},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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1783
1783
|
|
|
1784
1784
|
var defaultDiacriticsRemovalMap = [
|
|
1785
1785
|
{
|
|
@@ -3372,7 +3372,7 @@ function createPipelineExecutor(options) {
|
|
|
3372
3372
|
}
|
|
3373
3373
|
function executeSingleTemplate(currentTemplate) {
|
|
3374
3374
|
return __awaiter(this, void 0, void 0, function () {
|
|
3375
|
-
var name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2;
|
|
3375
|
+
var name, title, priority, progress_1, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2, progress_2;
|
|
3376
3376
|
var e_4, _f, _g;
|
|
3377
3377
|
return __generator(this, function (_h) {
|
|
3378
3378
|
switch (_h.label) {
|
|
@@ -3381,16 +3381,23 @@ function createPipelineExecutor(options) {
|
|
|
3381
3381
|
title = currentTemplate.title;
|
|
3382
3382
|
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
3383
3383
|
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3384
|
+
progress_1 = {
|
|
3385
|
+
name: name,
|
|
3386
|
+
title: title,
|
|
3387
|
+
isStarted: false,
|
|
3388
|
+
isDone: false,
|
|
3389
|
+
blockType: currentTemplate.blockType,
|
|
3390
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3391
|
+
parameterValue: null,
|
|
3392
|
+
// <- [3]
|
|
3393
|
+
};
|
|
3394
|
+
if (isReturned) {
|
|
3395
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4F\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_1, null, 4)
|
|
3396
|
+
.split('\n')
|
|
3397
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3398
|
+
.join('\n')), "\n "); }));
|
|
3399
|
+
}
|
|
3400
|
+
return [4 /*yield*/, onProgress(progress_1)];
|
|
3394
3401
|
case 1:
|
|
3395
3402
|
_h.sent();
|
|
3396
3403
|
_h.label = 2;
|
|
@@ -3776,18 +3783,28 @@ function createPipelineExecutor(options) {
|
|
|
3776
3783
|
if (resultString === null) {
|
|
3777
3784
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3778
3785
|
}
|
|
3779
|
-
if (onProgress /* <- [3] */)
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3786
|
+
if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
|
|
3787
|
+
progress_2 = {
|
|
3788
|
+
name: name,
|
|
3789
|
+
title: title,
|
|
3790
|
+
isStarted: true,
|
|
3791
|
+
isDone: true,
|
|
3792
|
+
blockType: currentTemplate.blockType,
|
|
3793
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3794
|
+
parameterValue: resultString,
|
|
3795
|
+
// <- [3]
|
|
3796
|
+
};
|
|
3797
|
+
if (isReturned) {
|
|
3798
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4E\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_2, null, 4)
|
|
3799
|
+
.split('\n')
|
|
3800
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3801
|
+
.join('\n')), "\n\n "); }));
|
|
3790
3802
|
}
|
|
3803
|
+
return [4 /*yield*/, onProgress(progress_2)];
|
|
3804
|
+
case 8:
|
|
3805
|
+
_h.sent();
|
|
3806
|
+
_h.label = 9;
|
|
3807
|
+
case 9:
|
|
3791
3808
|
parametersToPass = Object.freeze(__assign(__assign({}, parametersToPass), (_g = {}, _g[currentTemplate.resultingParameterName] = resultString /* <- Note: Not need to detect parameter collision here because pipeline checks logic consistency during construction */, _g)));
|
|
3792
3809
|
return [2 /*return*/];
|
|
3793
3810
|
}
|
|
@@ -3824,7 +3841,7 @@ function createPipelineExecutor(options) {
|
|
|
3824
3841
|
}
|
|
3825
3842
|
return outputParameters;
|
|
3826
3843
|
}
|
|
3827
|
-
var errors, warnings, executionReport, _a, _b, parameter, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
3844
|
+
var errors, warnings, executionReport, isReturned, _a, _b, parameter, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
3828
3845
|
var e_1, _e, e_2, _f;
|
|
3829
3846
|
return __generator(this, function (_g) {
|
|
3830
3847
|
switch (_g.label) {
|
|
@@ -3849,6 +3866,7 @@ function createPipelineExecutor(options) {
|
|
|
3849
3866
|
description: preparedPipeline.description,
|
|
3850
3867
|
promptExecutions: [],
|
|
3851
3868
|
};
|
|
3869
|
+
isReturned = false;
|
|
3852
3870
|
try {
|
|
3853
3871
|
// Note: Check that all input input parameters are defined
|
|
3854
3872
|
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
@@ -3857,6 +3875,7 @@ function createPipelineExecutor(options) {
|
|
|
3857
3875
|
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
3858
3876
|
parameter = _b.value;
|
|
3859
3877
|
if (inputParameters[parameter.name] === undefined) {
|
|
3878
|
+
isReturned = true;
|
|
3860
3879
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
3861
3880
|
isSuccessful: false,
|
|
3862
3881
|
errors: __spreadArray([
|
|
@@ -3887,6 +3906,7 @@ function createPipelineExecutor(options) {
|
|
|
3887
3906
|
warnings.push(new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
|
|
3888
3907
|
}
|
|
3889
3908
|
else if (parameter.isInput === false) {
|
|
3909
|
+
isReturned = true;
|
|
3890
3910
|
return { value: $asDeeplyFrozenSerializableJson(spaceTrim$1(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
3891
3911
|
isSuccessful: false,
|
|
3892
3912
|
errors: __spreadArray([
|
|
@@ -3999,6 +4019,7 @@ function createPipelineExecutor(options) {
|
|
|
3999
4019
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
4000
4020
|
})), false));
|
|
4001
4021
|
outputParameters_1 = filterJustOutputParameters();
|
|
4022
|
+
isReturned = true;
|
|
4002
4023
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
|
|
4003
4024
|
isSuccessful: false,
|
|
4004
4025
|
errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
|
|
@@ -4014,6 +4035,7 @@ function createPipelineExecutor(options) {
|
|
|
4014
4035
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
4015
4036
|
})), false));
|
|
4016
4037
|
outputParameters = filterJustOutputParameters();
|
|
4038
|
+
isReturned = true;
|
|
4017
4039
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
|
|
4018
4040
|
isSuccessful: true,
|
|
4019
4041
|
errors: errors.map(serializeError),
|
|
@@ -6061,7 +6083,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6061
6083
|
personas: [],
|
|
6062
6084
|
preparations: [],
|
|
6063
6085
|
};
|
|
6064
|
-
|
|
6086
|
+
function getPipelineIdentification() {
|
|
6065
6087
|
// Note: This is a 😐 implementation of [🚞]
|
|
6066
6088
|
var _ = [];
|
|
6067
6089
|
if (pipelineJson.sourceFile !== undefined) {
|
|
@@ -6071,7 +6093,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6071
6093
|
_.push("Url: ".concat(pipelineJson.pipelineUrl));
|
|
6072
6094
|
}
|
|
6073
6095
|
return _.join('\n');
|
|
6074
|
-
}
|
|
6096
|
+
}
|
|
6075
6097
|
// =============================================================
|
|
6076
6098
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
6077
6099
|
pipelineString = removeContentComments(pipelineString);
|
|
@@ -6080,27 +6102,27 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6080
6102
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
6081
6103
|
var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
|
|
6082
6104
|
if (pipelineHead === undefined) {
|
|
6083
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(
|
|
6105
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
6084
6106
|
}
|
|
6085
6107
|
if (pipelineHead.level !== 1) {
|
|
6086
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(
|
|
6108
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
6087
6109
|
}
|
|
6088
6110
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
6089
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(
|
|
6111
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
6090
6112
|
}
|
|
6091
6113
|
// =============================================================
|
|
6092
6114
|
///Note: 2️⃣ Function for defining parameters
|
|
6093
6115
|
var defineParam = function (parameterCommand) {
|
|
6094
6116
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
6095
6117
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
6096
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(
|
|
6118
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(getPipelineIdentification()), "\n "); }) /* <- TODO: [🚞] */);
|
|
6097
6119
|
}
|
|
6098
6120
|
var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
6099
6121
|
if (existingParameter &&
|
|
6100
6122
|
existingParameter.description &&
|
|
6101
6123
|
existingParameter.description !== parameterDescription &&
|
|
6102
6124
|
parameterDescription) {
|
|
6103
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(
|
|
6125
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
6104
6126
|
}
|
|
6105
6127
|
if (existingParameter) {
|
|
6106
6128
|
if (parameterDescription) {
|
|
@@ -6163,10 +6185,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6163
6185
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6164
6186
|
break;
|
|
6165
6187
|
case 'BOILERPLATE':
|
|
6166
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(
|
|
6188
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
6167
6189
|
// <- [💐]
|
|
6168
6190
|
default:
|
|
6169
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(
|
|
6191
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
6170
6192
|
}
|
|
6171
6193
|
};
|
|
6172
6194
|
try {
|
|
@@ -6199,7 +6221,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6199
6221
|
if (resultingParameterName !== null) {
|
|
6200
6222
|
return resultingParameterName;
|
|
6201
6223
|
}
|
|
6202
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(
|
|
6224
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
|
|
6203
6225
|
// TODO: Show code of invalid sections each time + DRY
|
|
6204
6226
|
section.content
|
|
6205
6227
|
.split('\n')
|
|
@@ -6242,13 +6264,13 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6242
6264
|
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6243
6265
|
case 'BLOCK':
|
|
6244
6266
|
if (isBlockTypeSet) {
|
|
6245
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(
|
|
6267
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
6246
6268
|
}
|
|
6247
6269
|
if (command.blockType === 'SAMPLE') {
|
|
6248
6270
|
expectResultingParameterName();
|
|
6249
6271
|
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
6250
6272
|
if (parameter === undefined) {
|
|
6251
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(
|
|
6273
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6252
6274
|
}
|
|
6253
6275
|
parameter.sampleValues = parameter.sampleValues || [];
|
|
6254
6276
|
parameter.sampleValues.push(content);
|
|
@@ -6283,20 +6305,20 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6283
6305
|
templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
|
|
6284
6306
|
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6285
6307
|
if (templateJson.expectations[unit_1].min !== undefined) {
|
|
6286
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(
|
|
6308
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6287
6309
|
}
|
|
6288
6310
|
templateJson.expectations[unit_1].min = command.amount;
|
|
6289
6311
|
} /* not else */
|
|
6290
6312
|
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6291
6313
|
if (templateJson.expectations[unit_1].max !== undefined) {
|
|
6292
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(
|
|
6314
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6293
6315
|
}
|
|
6294
6316
|
templateJson.expectations[unit_1].max = command.amount;
|
|
6295
6317
|
}
|
|
6296
6318
|
break;
|
|
6297
6319
|
case 'EXPECT_FORMAT':
|
|
6298
6320
|
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6299
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(
|
|
6321
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6300
6322
|
}
|
|
6301
6323
|
templateJson.expectFormat = command.format;
|
|
6302
6324
|
break;
|
|
@@ -6332,11 +6354,11 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6332
6354
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6333
6355
|
break;
|
|
6334
6356
|
case 'BOILERPLATE':
|
|
6335
|
-
console.error(new ParsingError(spaceTrim$1(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(
|
|
6357
|
+
console.error(new ParsingError(spaceTrim$1(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })));
|
|
6336
6358
|
break;
|
|
6337
6359
|
// <- [💐]
|
|
6338
6360
|
default:
|
|
6339
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(
|
|
6361
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(getPipelineIdentification()), "\n\n "); }));
|
|
6340
6362
|
}
|
|
6341
6363
|
};
|
|
6342
6364
|
try {
|
|
@@ -6358,7 +6380,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6358
6380
|
// TODO: [🍧] Should be done in BLOCK command
|
|
6359
6381
|
if (templateJson.blockType === 'SCRIPT') {
|
|
6360
6382
|
if (!language) {
|
|
6361
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(
|
|
6383
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
6362
6384
|
}
|
|
6363
6385
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6364
6386
|
throw new ParsingError(spaceTrim$1(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|