@promptbook/core 0.67.5 → 0.67.6
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 +165 -146
- package/esm/index.es.js.map +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +165 -146
- package/umd/index.umd.js.map +1 -1
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.67.5';
|
|
20
20
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
/*! *****************************************************************************
|
|
@@ -1786,7 +1786,7 @@
|
|
|
1786
1786
|
});
|
|
1787
1787
|
}
|
|
1788
1788
|
|
|
1789
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
1789
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.5",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.5",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.5",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.5",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"}];
|
|
1790
1790
|
|
|
1791
1791
|
var defaultDiacriticsRemovalMap = [
|
|
1792
1792
|
{
|
|
@@ -6068,6 +6068,17 @@
|
|
|
6068
6068
|
personas: [],
|
|
6069
6069
|
preparations: [],
|
|
6070
6070
|
};
|
|
6071
|
+
var pipelineIdentification = (function () {
|
|
6072
|
+
// Note: This is a 😐 implementation of [🚞]
|
|
6073
|
+
var _ = [];
|
|
6074
|
+
if (pipelineJson.sourceFile !== undefined) {
|
|
6075
|
+
_.push("File: ".concat(pipelineJson.sourceFile));
|
|
6076
|
+
}
|
|
6077
|
+
if (pipelineJson.pipelineUrl !== undefined) {
|
|
6078
|
+
_.push("Url: ".concat(pipelineJson.pipelineUrl));
|
|
6079
|
+
}
|
|
6080
|
+
return _.join('\n');
|
|
6081
|
+
})();
|
|
6071
6082
|
// =============================================================
|
|
6072
6083
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
6073
6084
|
pipelineString = removeContentComments(pipelineString);
|
|
@@ -6076,27 +6087,27 @@
|
|
|
6076
6087
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
6077
6088
|
var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
|
|
6078
6089
|
if (pipelineHead === undefined) {
|
|
6079
|
-
throw new UnexpectedError(spaceTrim.spaceTrim("\n
|
|
6090
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(pipelineIdentification), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
6080
6091
|
}
|
|
6081
6092
|
if (pipelineHead.level !== 1) {
|
|
6082
|
-
throw new UnexpectedError(spaceTrim.spaceTrim("\n
|
|
6093
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(pipelineIdentification), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
6083
6094
|
}
|
|
6084
6095
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
6085
|
-
throw new UnexpectedError(spaceTrim.spaceTrim("\n
|
|
6096
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(pipelineIdentification), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
6086
6097
|
}
|
|
6087
6098
|
// =============================================================
|
|
6088
6099
|
///Note: 2️⃣ Function for defining parameters
|
|
6089
6100
|
var defineParam = function (parameterCommand) {
|
|
6090
6101
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
6091
6102
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
6092
|
-
throw new ParsingError("Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name") /* <- TODO: [🚞] */);
|
|
6103
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(pipelineIdentification), "\n "); }) /* <- TODO: [🚞] */);
|
|
6093
6104
|
}
|
|
6094
6105
|
var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
6095
6106
|
if (existingParameter &&
|
|
6096
6107
|
existingParameter.description &&
|
|
6097
6108
|
existingParameter.description !== parameterDescription &&
|
|
6098
6109
|
parameterDescription) {
|
|
6099
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
6110
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(pipelineIdentification), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
6100
6111
|
}
|
|
6101
6112
|
if (existingParameter) {
|
|
6102
6113
|
if (parameterDescription) {
|
|
@@ -6129,44 +6140,46 @@
|
|
|
6129
6140
|
pipelineJson.description = description;
|
|
6130
6141
|
var defaultModelRequirements = {};
|
|
6131
6142
|
var listItems = extractAllListItemsFromMarkdown(pipelineHead.content);
|
|
6143
|
+
var _loop_1 = function (listItem) {
|
|
6144
|
+
var command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
6145
|
+
switch (command.type) {
|
|
6146
|
+
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6147
|
+
case 'MODEL':
|
|
6148
|
+
defaultModelRequirements[command.key] = command.value;
|
|
6149
|
+
break;
|
|
6150
|
+
case 'PARAMETER':
|
|
6151
|
+
defineParam(command);
|
|
6152
|
+
break;
|
|
6153
|
+
case 'PROMPTBOOK_VERSION':
|
|
6154
|
+
pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
6155
|
+
break;
|
|
6156
|
+
case 'URL':
|
|
6157
|
+
pipelineJson.pipelineUrl = command.pipelineUrl.href;
|
|
6158
|
+
break;
|
|
6159
|
+
case 'KNOWLEDGE':
|
|
6160
|
+
knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
|
|
6161
|
+
break;
|
|
6162
|
+
case 'ACTION':
|
|
6163
|
+
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6164
|
+
break;
|
|
6165
|
+
case 'INSTRUMENT':
|
|
6166
|
+
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6167
|
+
break;
|
|
6168
|
+
case 'PERSONA':
|
|
6169
|
+
personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
|
|
6170
|
+
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6171
|
+
break;
|
|
6172
|
+
case 'BOILERPLATE':
|
|
6173
|
+
throw new ParsingError(spaceTrim.spaceTrim(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(pipelineIdentification), "\n "); })); // <- TODO: [🚞]
|
|
6174
|
+
// <- [💐]
|
|
6175
|
+
default:
|
|
6176
|
+
throw new ParsingError(spaceTrim.spaceTrim(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(pipelineIdentification), "\n "); })); // <- TODO: [🚞]
|
|
6177
|
+
}
|
|
6178
|
+
};
|
|
6132
6179
|
try {
|
|
6133
6180
|
for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
6134
6181
|
var listItem = listItems_1_1.value;
|
|
6135
|
-
|
|
6136
|
-
switch (command.type) {
|
|
6137
|
-
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6138
|
-
case 'MODEL':
|
|
6139
|
-
defaultModelRequirements[command.key] = command.value;
|
|
6140
|
-
break;
|
|
6141
|
-
case 'PARAMETER':
|
|
6142
|
-
defineParam(command);
|
|
6143
|
-
break;
|
|
6144
|
-
case 'PROMPTBOOK_VERSION':
|
|
6145
|
-
pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
6146
|
-
break;
|
|
6147
|
-
case 'URL':
|
|
6148
|
-
pipelineJson.pipelineUrl = command.pipelineUrl.href;
|
|
6149
|
-
break;
|
|
6150
|
-
case 'KNOWLEDGE':
|
|
6151
|
-
knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
|
|
6152
|
-
break;
|
|
6153
|
-
case 'ACTION':
|
|
6154
|
-
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6155
|
-
break;
|
|
6156
|
-
case 'INSTRUMENT':
|
|
6157
|
-
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6158
|
-
break;
|
|
6159
|
-
case 'PERSONA':
|
|
6160
|
-
personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
|
|
6161
|
-
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6162
|
-
break;
|
|
6163
|
-
case 'BOILERPLATE':
|
|
6164
|
-
throw new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'); // <- TODO: [🚞]
|
|
6165
|
-
break;
|
|
6166
|
-
// <- [💐]
|
|
6167
|
-
default:
|
|
6168
|
-
throw new ParsingError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template")); // <- TODO: [🚞]
|
|
6169
|
-
}
|
|
6182
|
+
_loop_1(listItem);
|
|
6170
6183
|
}
|
|
6171
6184
|
}
|
|
6172
6185
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -6176,7 +6189,7 @@
|
|
|
6176
6189
|
}
|
|
6177
6190
|
finally { if (e_1) throw e_1.error; }
|
|
6178
6191
|
}
|
|
6179
|
-
var
|
|
6192
|
+
var _loop_2 = function (section) {
|
|
6180
6193
|
var e_3, _d;
|
|
6181
6194
|
// TODO: Parse prompt template description (the content out of the codeblock and lists)
|
|
6182
6195
|
var templateModelRequirements = __assign({}, defaultModelRequirements);
|
|
@@ -6193,7 +6206,7 @@
|
|
|
6193
6206
|
if (resultingParameterName !== null) {
|
|
6194
6207
|
return resultingParameterName;
|
|
6195
6208
|
}
|
|
6196
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n Invalid section:\n ".concat(block(
|
|
6209
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(pipelineIdentification), "\n\n Invalid section:\n ").concat(block(
|
|
6197
6210
|
// TODO: Show code of invalid sections each time + DRY
|
|
6198
6211
|
section.content
|
|
6199
6212
|
.split('\n')
|
|
@@ -6229,110 +6242,116 @@
|
|
|
6229
6242
|
* Note: [2]
|
|
6230
6243
|
*/
|
|
6231
6244
|
var isBlockTypeSet = false;
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
// TODO [🍧]
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
}
|
|
6243
|
-
if (command.blockType === 'SAMPLE') {
|
|
6244
|
-
expectResultingParameterName();
|
|
6245
|
-
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
6246
|
-
if (parameter === undefined) {
|
|
6247
|
-
throw new UnexpectedError("Can not find parameter {".concat(resultingParameterName, "} to assign sample value"));
|
|
6248
|
-
}
|
|
6249
|
-
parameter.sampleValues = parameter.sampleValues || [];
|
|
6250
|
-
parameter.sampleValues.push(content);
|
|
6251
|
-
return "continue-templates";
|
|
6252
|
-
}
|
|
6253
|
-
if (command.blockType === 'KNOWLEDGE') {
|
|
6254
|
-
knowledgeCommandParser.applyToPipelineJson({
|
|
6255
|
-
type: 'KNOWLEDGE',
|
|
6256
|
-
sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
6257
|
-
}, {
|
|
6258
|
-
pipelineJson: pipelineJson,
|
|
6259
|
-
templateJson: templateJson,
|
|
6260
|
-
});
|
|
6261
|
-
return "continue-templates";
|
|
6262
|
-
}
|
|
6263
|
-
if (command.blockType === 'ACTION') {
|
|
6264
|
-
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6265
|
-
return "continue-templates";
|
|
6266
|
-
}
|
|
6267
|
-
if (command.blockType === 'INSTRUMENT') {
|
|
6268
|
-
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6269
|
-
return "continue-templates";
|
|
6270
|
-
}
|
|
6245
|
+
var _loop_3 = function (listItem) {
|
|
6246
|
+
var command = parseCommand(listItem, 'PIPELINE_TEMPLATE');
|
|
6247
|
+
// TODO [🍧][♓️] List commands and before apply order them
|
|
6248
|
+
switch (command.type) {
|
|
6249
|
+
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6250
|
+
case 'BLOCK':
|
|
6251
|
+
if (isBlockTypeSet) {
|
|
6252
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
6253
|
+
}
|
|
6254
|
+
if (command.blockType === 'SAMPLE') {
|
|
6271
6255
|
expectResultingParameterName();
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
case 'EXPECT_AMOUNT':
|
|
6276
|
-
// eslint-disable-next-line no-case-declarations
|
|
6277
|
-
var unit = command.unit.toLowerCase();
|
|
6278
|
-
templateJson.expectations = templateJson.expectations || {};
|
|
6279
|
-
templateJson.expectations[unit] = templateJson.expectations[unit] || {};
|
|
6280
|
-
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6281
|
-
if (templateJson.expectations[unit].min !== undefined) {
|
|
6282
|
-
throw new ParsingError("Already defined minumum ".concat(templateJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
6283
|
-
}
|
|
6284
|
-
templateJson.expectations[unit].min = command.amount;
|
|
6285
|
-
} /* not else */
|
|
6286
|
-
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6287
|
-
if (templateJson.expectations[unit].max !== undefined) {
|
|
6288
|
-
throw new ParsingError("Already defined maximum ".concat(templateJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
6289
|
-
}
|
|
6290
|
-
templateJson.expectations[unit].max = command.amount;
|
|
6291
|
-
}
|
|
6292
|
-
break;
|
|
6293
|
-
case 'EXPECT_FORMAT':
|
|
6294
|
-
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6295
|
-
throw new ParsingError(spaceTrim.spaceTrim("\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n ")));
|
|
6256
|
+
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
6257
|
+
if (parameter === undefined) {
|
|
6258
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
6296
6259
|
}
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
templateJson.postprocessingFunctionNames.push(command.functionName);
|
|
6313
|
-
break;
|
|
6314
|
-
case 'KNOWLEDGE':
|
|
6315
|
-
// TODO: [👙] The knowledge is maybe relevant for just this template
|
|
6316
|
-
knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
|
|
6317
|
-
break;
|
|
6318
|
-
case 'ACTION':
|
|
6319
|
-
// TODO: [👙] The action is maybe relevant for just this template
|
|
6260
|
+
parameter.sampleValues = parameter.sampleValues || [];
|
|
6261
|
+
parameter.sampleValues.push(content);
|
|
6262
|
+
return "continue-templates";
|
|
6263
|
+
}
|
|
6264
|
+
if (command.blockType === 'KNOWLEDGE') {
|
|
6265
|
+
knowledgeCommandParser.applyToPipelineJson({
|
|
6266
|
+
type: 'KNOWLEDGE',
|
|
6267
|
+
sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
6268
|
+
}, {
|
|
6269
|
+
pipelineJson: pipelineJson,
|
|
6270
|
+
templateJson: templateJson,
|
|
6271
|
+
});
|
|
6272
|
+
return "continue-templates";
|
|
6273
|
+
}
|
|
6274
|
+
if (command.blockType === 'ACTION') {
|
|
6320
6275
|
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6276
|
+
return "continue-templates";
|
|
6277
|
+
}
|
|
6278
|
+
if (command.blockType === 'INSTRUMENT') {
|
|
6324
6279
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6280
|
+
return "continue-templates";
|
|
6281
|
+
}
|
|
6282
|
+
expectResultingParameterName();
|
|
6283
|
+
templateJson.blockType = command.blockType;
|
|
6284
|
+
isBlockTypeSet = true; //<- Note: [2]
|
|
6285
|
+
break;
|
|
6286
|
+
case 'EXPECT_AMOUNT':
|
|
6287
|
+
// eslint-disable-next-line no-case-declarations
|
|
6288
|
+
var unit_1 = command.unit.toLowerCase();
|
|
6289
|
+
templateJson.expectations = templateJson.expectations || {};
|
|
6290
|
+
templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
|
|
6291
|
+
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6292
|
+
if (templateJson.expectations[unit_1].min !== undefined) {
|
|
6293
|
+
throw new ParsingError(spaceTrim.spaceTrim(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(pipelineIdentification), "\n "); }));
|
|
6294
|
+
}
|
|
6295
|
+
templateJson.expectations[unit_1].min = command.amount;
|
|
6296
|
+
} /* not else */
|
|
6297
|
+
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6298
|
+
if (templateJson.expectations[unit_1].max !== undefined) {
|
|
6299
|
+
throw new ParsingError(spaceTrim.spaceTrim(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(pipelineIdentification), "\n "); }));
|
|
6300
|
+
}
|
|
6301
|
+
templateJson.expectations[unit_1].max = command.amount;
|
|
6302
|
+
}
|
|
6303
|
+
break;
|
|
6304
|
+
case 'EXPECT_FORMAT':
|
|
6305
|
+
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6306
|
+
throw new ParsingError(spaceTrim.spaceTrim(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(pipelineIdentification), "\n "); }));
|
|
6307
|
+
}
|
|
6308
|
+
templateJson.expectFormat = command.format;
|
|
6309
|
+
break;
|
|
6310
|
+
case 'JOKER':
|
|
6311
|
+
templateJson.jokerParameterNames = templateJson.jokerParameterNames || [];
|
|
6312
|
+
templateJson.jokerParameterNames.push(command.parameterName);
|
|
6313
|
+
break;
|
|
6314
|
+
case 'MODEL':
|
|
6315
|
+
templateModelRequirements[command.key] = command.value;
|
|
6316
|
+
break;
|
|
6317
|
+
case 'PARAMETER':
|
|
6318
|
+
// Note: This is just for detecting resulitng parameter name
|
|
6319
|
+
defineParam(command);
|
|
6320
|
+
break;
|
|
6321
|
+
case 'POSTPROCESS':
|
|
6322
|
+
templateJson.postprocessingFunctionNames = templateJson.postprocessingFunctionNames || [];
|
|
6323
|
+
templateJson.postprocessingFunctionNames.push(command.functionName);
|
|
6324
|
+
break;
|
|
6325
|
+
case 'KNOWLEDGE':
|
|
6326
|
+
// TODO: [👙] The knowledge is maybe relevant for just this template
|
|
6327
|
+
knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
|
|
6328
|
+
break;
|
|
6329
|
+
case 'ACTION':
|
|
6330
|
+
// TODO: [👙] The action is maybe relevant for just this template
|
|
6331
|
+
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6332
|
+
break;
|
|
6333
|
+
case 'INSTRUMENT':
|
|
6334
|
+
// TODO: [👙] The instrument is maybe relevant for just this template
|
|
6335
|
+
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6336
|
+
break;
|
|
6337
|
+
case 'PERSONA':
|
|
6338
|
+
personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
|
|
6339
|
+
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6340
|
+
break;
|
|
6341
|
+
case 'BOILERPLATE':
|
|
6342
|
+
console.error(new ParsingError(spaceTrim.spaceTrim(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(pipelineIdentification), "\n "); })));
|
|
6343
|
+
break;
|
|
6344
|
+
// <- [💐]
|
|
6345
|
+
default:
|
|
6346
|
+
throw new ParsingError(spaceTrim.spaceTrim(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(pipelineIdentification), "\n\n "); }));
|
|
6347
|
+
}
|
|
6348
|
+
};
|
|
6349
|
+
try {
|
|
6350
|
+
for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
|
|
6351
|
+
var listItem = listItems_2_1.value;
|
|
6352
|
+
var state_2 = _loop_3(listItem);
|
|
6353
|
+
switch (state_2) {
|
|
6354
|
+
case "continue-templates": return state_2;
|
|
6336
6355
|
}
|
|
6337
6356
|
}
|
|
6338
6357
|
}
|
|
@@ -6346,7 +6365,7 @@
|
|
|
6346
6365
|
// TODO: [🍧] Should be done in BLOCK command
|
|
6347
6366
|
if (templateJson.blockType === 'SCRIPT') {
|
|
6348
6367
|
if (!language) {
|
|
6349
|
-
throw new ParsingError(
|
|
6368
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
6350
6369
|
}
|
|
6351
6370
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6352
6371
|
throw new ParsingError(spaceTrim.spaceTrim(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 "); }));
|
|
@@ -6372,7 +6391,7 @@
|
|
|
6372
6391
|
// Note: 4️⃣ Process each template of the pipeline
|
|
6373
6392
|
templates: for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
|
|
6374
6393
|
var section = pipelineSections_1_1.value;
|
|
6375
|
-
var state_1 =
|
|
6394
|
+
var state_1 = _loop_2(section);
|
|
6376
6395
|
switch (state_1) {
|
|
6377
6396
|
case "continue-templates": continue templates;
|
|
6378
6397
|
}
|