@promptbook/cli 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
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/**
|
|
40
40
|
* The version of the Promptbook library
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.67.5';
|
|
43
43
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -1053,7 +1053,7 @@
|
|
|
1053
1053
|
});
|
|
1054
1054
|
}
|
|
1055
1055
|
|
|
1056
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
1056
|
+
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"}];
|
|
1057
1057
|
|
|
1058
1058
|
/**
|
|
1059
1059
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -5929,6 +5929,17 @@
|
|
|
5929
5929
|
personas: [],
|
|
5930
5930
|
preparations: [],
|
|
5931
5931
|
};
|
|
5932
|
+
var pipelineIdentification = (function () {
|
|
5933
|
+
// Note: This is a 😐 implementation of [🚞]
|
|
5934
|
+
var _ = [];
|
|
5935
|
+
if (pipelineJson.sourceFile !== undefined) {
|
|
5936
|
+
_.push("File: ".concat(pipelineJson.sourceFile));
|
|
5937
|
+
}
|
|
5938
|
+
if (pipelineJson.pipelineUrl !== undefined) {
|
|
5939
|
+
_.push("Url: ".concat(pipelineJson.pipelineUrl));
|
|
5940
|
+
}
|
|
5941
|
+
return _.join('\n');
|
|
5942
|
+
})();
|
|
5932
5943
|
// =============================================================
|
|
5933
5944
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
5934
5945
|
pipelineString = removeContentComments(pipelineString);
|
|
@@ -5937,27 +5948,27 @@
|
|
|
5937
5948
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
5938
5949
|
var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
|
|
5939
5950
|
if (pipelineHead === undefined) {
|
|
5940
|
-
throw new UnexpectedError(spaceTrim.spaceTrim("\n
|
|
5951
|
+
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 "); }));
|
|
5941
5952
|
}
|
|
5942
5953
|
if (pipelineHead.level !== 1) {
|
|
5943
|
-
throw new UnexpectedError(spaceTrim.spaceTrim("\n
|
|
5954
|
+
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 "); }));
|
|
5944
5955
|
}
|
|
5945
5956
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
5946
|
-
throw new UnexpectedError(spaceTrim.spaceTrim("\n
|
|
5957
|
+
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 "); }));
|
|
5947
5958
|
}
|
|
5948
5959
|
// =============================================================
|
|
5949
5960
|
///Note: 2️⃣ Function for defining parameters
|
|
5950
5961
|
var defineParam = function (parameterCommand) {
|
|
5951
5962
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
5952
5963
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
5953
|
-
throw new ParsingError("Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name") /* <- TODO: [🚞] */);
|
|
5964
|
+
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: [🚞] */);
|
|
5954
5965
|
}
|
|
5955
5966
|
var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
5956
5967
|
if (existingParameter &&
|
|
5957
5968
|
existingParameter.description &&
|
|
5958
5969
|
existingParameter.description !== parameterDescription &&
|
|
5959
5970
|
parameterDescription) {
|
|
5960
|
-
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 "); }));
|
|
5971
|
+
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 "); }));
|
|
5961
5972
|
}
|
|
5962
5973
|
if (existingParameter) {
|
|
5963
5974
|
if (parameterDescription) {
|
|
@@ -5990,44 +6001,46 @@
|
|
|
5990
6001
|
pipelineJson.description = description;
|
|
5991
6002
|
var defaultModelRequirements = {};
|
|
5992
6003
|
var listItems = extractAllListItemsFromMarkdown(pipelineHead.content);
|
|
6004
|
+
var _loop_1 = function (listItem) {
|
|
6005
|
+
var command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
6006
|
+
switch (command.type) {
|
|
6007
|
+
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6008
|
+
case 'MODEL':
|
|
6009
|
+
defaultModelRequirements[command.key] = command.value;
|
|
6010
|
+
break;
|
|
6011
|
+
case 'PARAMETER':
|
|
6012
|
+
defineParam(command);
|
|
6013
|
+
break;
|
|
6014
|
+
case 'PROMPTBOOK_VERSION':
|
|
6015
|
+
pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
6016
|
+
break;
|
|
6017
|
+
case 'URL':
|
|
6018
|
+
pipelineJson.pipelineUrl = command.pipelineUrl.href;
|
|
6019
|
+
break;
|
|
6020
|
+
case 'KNOWLEDGE':
|
|
6021
|
+
knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
|
|
6022
|
+
break;
|
|
6023
|
+
case 'ACTION':
|
|
6024
|
+
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6025
|
+
break;
|
|
6026
|
+
case 'INSTRUMENT':
|
|
6027
|
+
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6028
|
+
break;
|
|
6029
|
+
case 'PERSONA':
|
|
6030
|
+
personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
|
|
6031
|
+
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6032
|
+
break;
|
|
6033
|
+
case 'BOILERPLATE':
|
|
6034
|
+
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: [🚞]
|
|
6035
|
+
// <- [💐]
|
|
6036
|
+
default:
|
|
6037
|
+
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: [🚞]
|
|
6038
|
+
}
|
|
6039
|
+
};
|
|
5993
6040
|
try {
|
|
5994
6041
|
for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
5995
6042
|
var listItem = listItems_1_1.value;
|
|
5996
|
-
|
|
5997
|
-
switch (command.type) {
|
|
5998
|
-
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
5999
|
-
case 'MODEL':
|
|
6000
|
-
defaultModelRequirements[command.key] = command.value;
|
|
6001
|
-
break;
|
|
6002
|
-
case 'PARAMETER':
|
|
6003
|
-
defineParam(command);
|
|
6004
|
-
break;
|
|
6005
|
-
case 'PROMPTBOOK_VERSION':
|
|
6006
|
-
pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
6007
|
-
break;
|
|
6008
|
-
case 'URL':
|
|
6009
|
-
pipelineJson.pipelineUrl = command.pipelineUrl.href;
|
|
6010
|
-
break;
|
|
6011
|
-
case 'KNOWLEDGE':
|
|
6012
|
-
knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
|
|
6013
|
-
break;
|
|
6014
|
-
case 'ACTION':
|
|
6015
|
-
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6016
|
-
break;
|
|
6017
|
-
case 'INSTRUMENT':
|
|
6018
|
-
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6019
|
-
break;
|
|
6020
|
-
case 'PERSONA':
|
|
6021
|
-
personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: null });
|
|
6022
|
-
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6023
|
-
break;
|
|
6024
|
-
case 'BOILERPLATE':
|
|
6025
|
-
throw new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'); // <- TODO: [🚞]
|
|
6026
|
-
break;
|
|
6027
|
-
// <- [💐]
|
|
6028
|
-
default:
|
|
6029
|
-
throw new ParsingError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template")); // <- TODO: [🚞]
|
|
6030
|
-
}
|
|
6043
|
+
_loop_1(listItem);
|
|
6031
6044
|
}
|
|
6032
6045
|
}
|
|
6033
6046
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -6037,7 +6050,7 @@
|
|
|
6037
6050
|
}
|
|
6038
6051
|
finally { if (e_1) throw e_1.error; }
|
|
6039
6052
|
}
|
|
6040
|
-
var
|
|
6053
|
+
var _loop_2 = function (section) {
|
|
6041
6054
|
var e_3, _d;
|
|
6042
6055
|
// TODO: Parse prompt template description (the content out of the codeblock and lists)
|
|
6043
6056
|
var templateModelRequirements = __assign({}, defaultModelRequirements);
|
|
@@ -6054,7 +6067,7 @@
|
|
|
6054
6067
|
if (resultingParameterName !== null) {
|
|
6055
6068
|
return resultingParameterName;
|
|
6056
6069
|
}
|
|
6057
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n Invalid section:\n ".concat(block(
|
|
6070
|
+
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(
|
|
6058
6071
|
// TODO: Show code of invalid sections each time + DRY
|
|
6059
6072
|
section.content
|
|
6060
6073
|
.split('\n')
|
|
@@ -6090,110 +6103,116 @@
|
|
|
6090
6103
|
* Note: [2]
|
|
6091
6104
|
*/
|
|
6092
6105
|
var isBlockTypeSet = false;
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
// TODO [🍧]
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
}
|
|
6104
|
-
if (command.blockType === 'SAMPLE') {
|
|
6105
|
-
expectResultingParameterName();
|
|
6106
|
-
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
6107
|
-
if (parameter === undefined) {
|
|
6108
|
-
throw new UnexpectedError("Can not find parameter {".concat(resultingParameterName, "} to assign sample value"));
|
|
6109
|
-
}
|
|
6110
|
-
parameter.sampleValues = parameter.sampleValues || [];
|
|
6111
|
-
parameter.sampleValues.push(content);
|
|
6112
|
-
return "continue-templates";
|
|
6113
|
-
}
|
|
6114
|
-
if (command.blockType === 'KNOWLEDGE') {
|
|
6115
|
-
knowledgeCommandParser.applyToPipelineJson({
|
|
6116
|
-
type: 'KNOWLEDGE',
|
|
6117
|
-
sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
6118
|
-
}, {
|
|
6119
|
-
pipelineJson: pipelineJson,
|
|
6120
|
-
templateJson: templateJson,
|
|
6121
|
-
});
|
|
6122
|
-
return "continue-templates";
|
|
6123
|
-
}
|
|
6124
|
-
if (command.blockType === 'ACTION') {
|
|
6125
|
-
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6126
|
-
return "continue-templates";
|
|
6127
|
-
}
|
|
6128
|
-
if (command.blockType === 'INSTRUMENT') {
|
|
6129
|
-
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6130
|
-
return "continue-templates";
|
|
6131
|
-
}
|
|
6106
|
+
var _loop_3 = function (listItem) {
|
|
6107
|
+
var command = parseCommand(listItem, 'PIPELINE_TEMPLATE');
|
|
6108
|
+
// TODO [🍧][♓️] List commands and before apply order them
|
|
6109
|
+
switch (command.type) {
|
|
6110
|
+
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6111
|
+
case 'BLOCK':
|
|
6112
|
+
if (isBlockTypeSet) {
|
|
6113
|
+
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 "); }));
|
|
6114
|
+
}
|
|
6115
|
+
if (command.blockType === 'SAMPLE') {
|
|
6132
6116
|
expectResultingParameterName();
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
case 'EXPECT_AMOUNT':
|
|
6137
|
-
// eslint-disable-next-line no-case-declarations
|
|
6138
|
-
var unit = command.unit.toLowerCase();
|
|
6139
|
-
templateJson.expectations = templateJson.expectations || {};
|
|
6140
|
-
templateJson.expectations[unit] = templateJson.expectations[unit] || {};
|
|
6141
|
-
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6142
|
-
if (templateJson.expectations[unit].min !== undefined) {
|
|
6143
|
-
throw new ParsingError("Already defined minumum ".concat(templateJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
6144
|
-
}
|
|
6145
|
-
templateJson.expectations[unit].min = command.amount;
|
|
6146
|
-
} /* not else */
|
|
6147
|
-
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6148
|
-
if (templateJson.expectations[unit].max !== undefined) {
|
|
6149
|
-
throw new ParsingError("Already defined maximum ".concat(templateJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
6150
|
-
}
|
|
6151
|
-
templateJson.expectations[unit].max = command.amount;
|
|
6152
|
-
}
|
|
6153
|
-
break;
|
|
6154
|
-
case 'EXPECT_FORMAT':
|
|
6155
|
-
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6156
|
-
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 ")));
|
|
6117
|
+
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
6118
|
+
if (parameter === undefined) {
|
|
6119
|
+
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 "); }));
|
|
6157
6120
|
}
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
templateJson.postprocessingFunctionNames.push(command.functionName);
|
|
6174
|
-
break;
|
|
6175
|
-
case 'KNOWLEDGE':
|
|
6176
|
-
// TODO: [👙] The knowledge is maybe relevant for just this template
|
|
6177
|
-
knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
|
|
6178
|
-
break;
|
|
6179
|
-
case 'ACTION':
|
|
6180
|
-
// TODO: [👙] The action is maybe relevant for just this template
|
|
6121
|
+
parameter.sampleValues = parameter.sampleValues || [];
|
|
6122
|
+
parameter.sampleValues.push(content);
|
|
6123
|
+
return "continue-templates";
|
|
6124
|
+
}
|
|
6125
|
+
if (command.blockType === 'KNOWLEDGE') {
|
|
6126
|
+
knowledgeCommandParser.applyToPipelineJson({
|
|
6127
|
+
type: 'KNOWLEDGE',
|
|
6128
|
+
sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
6129
|
+
}, {
|
|
6130
|
+
pipelineJson: pipelineJson,
|
|
6131
|
+
templateJson: templateJson,
|
|
6132
|
+
});
|
|
6133
|
+
return "continue-templates";
|
|
6134
|
+
}
|
|
6135
|
+
if (command.blockType === 'ACTION') {
|
|
6181
6136
|
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6137
|
+
return "continue-templates";
|
|
6138
|
+
}
|
|
6139
|
+
if (command.blockType === 'INSTRUMENT') {
|
|
6185
6140
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6141
|
+
return "continue-templates";
|
|
6142
|
+
}
|
|
6143
|
+
expectResultingParameterName();
|
|
6144
|
+
templateJson.blockType = command.blockType;
|
|
6145
|
+
isBlockTypeSet = true; //<- Note: [2]
|
|
6146
|
+
break;
|
|
6147
|
+
case 'EXPECT_AMOUNT':
|
|
6148
|
+
// eslint-disable-next-line no-case-declarations
|
|
6149
|
+
var unit_1 = command.unit.toLowerCase();
|
|
6150
|
+
templateJson.expectations = templateJson.expectations || {};
|
|
6151
|
+
templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
|
|
6152
|
+
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6153
|
+
if (templateJson.expectations[unit_1].min !== undefined) {
|
|
6154
|
+
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 "); }));
|
|
6155
|
+
}
|
|
6156
|
+
templateJson.expectations[unit_1].min = command.amount;
|
|
6157
|
+
} /* not else */
|
|
6158
|
+
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6159
|
+
if (templateJson.expectations[unit_1].max !== undefined) {
|
|
6160
|
+
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 "); }));
|
|
6161
|
+
}
|
|
6162
|
+
templateJson.expectations[unit_1].max = command.amount;
|
|
6163
|
+
}
|
|
6164
|
+
break;
|
|
6165
|
+
case 'EXPECT_FORMAT':
|
|
6166
|
+
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6167
|
+
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 "); }));
|
|
6168
|
+
}
|
|
6169
|
+
templateJson.expectFormat = command.format;
|
|
6170
|
+
break;
|
|
6171
|
+
case 'JOKER':
|
|
6172
|
+
templateJson.jokerParameterNames = templateJson.jokerParameterNames || [];
|
|
6173
|
+
templateJson.jokerParameterNames.push(command.parameterName);
|
|
6174
|
+
break;
|
|
6175
|
+
case 'MODEL':
|
|
6176
|
+
templateModelRequirements[command.key] = command.value;
|
|
6177
|
+
break;
|
|
6178
|
+
case 'PARAMETER':
|
|
6179
|
+
// Note: This is just for detecting resulitng parameter name
|
|
6180
|
+
defineParam(command);
|
|
6181
|
+
break;
|
|
6182
|
+
case 'POSTPROCESS':
|
|
6183
|
+
templateJson.postprocessingFunctionNames = templateJson.postprocessingFunctionNames || [];
|
|
6184
|
+
templateJson.postprocessingFunctionNames.push(command.functionName);
|
|
6185
|
+
break;
|
|
6186
|
+
case 'KNOWLEDGE':
|
|
6187
|
+
// TODO: [👙] The knowledge is maybe relevant for just this template
|
|
6188
|
+
knowledgeCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
|
|
6189
|
+
break;
|
|
6190
|
+
case 'ACTION':
|
|
6191
|
+
// TODO: [👙] The action is maybe relevant for just this template
|
|
6192
|
+
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6193
|
+
break;
|
|
6194
|
+
case 'INSTRUMENT':
|
|
6195
|
+
// TODO: [👙] The instrument is maybe relevant for just this template
|
|
6196
|
+
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6197
|
+
break;
|
|
6198
|
+
case 'PERSONA':
|
|
6199
|
+
personaCommandParser.applyToPipelineJson(command, { pipelineJson: pipelineJson, templateJson: templateJson });
|
|
6200
|
+
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6201
|
+
break;
|
|
6202
|
+
case 'BOILERPLATE':
|
|
6203
|
+
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 "); })));
|
|
6204
|
+
break;
|
|
6205
|
+
// <- [💐]
|
|
6206
|
+
default:
|
|
6207
|
+
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 "); }));
|
|
6208
|
+
}
|
|
6209
|
+
};
|
|
6210
|
+
try {
|
|
6211
|
+
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()) {
|
|
6212
|
+
var listItem = listItems_2_1.value;
|
|
6213
|
+
var state_2 = _loop_3(listItem);
|
|
6214
|
+
switch (state_2) {
|
|
6215
|
+
case "continue-templates": return state_2;
|
|
6197
6216
|
}
|
|
6198
6217
|
}
|
|
6199
6218
|
}
|
|
@@ -6207,7 +6226,7 @@
|
|
|
6207
6226
|
// TODO: [🍧] Should be done in BLOCK command
|
|
6208
6227
|
if (templateJson.blockType === 'SCRIPT') {
|
|
6209
6228
|
if (!language) {
|
|
6210
|
-
throw new ParsingError(
|
|
6229
|
+
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 "); }));
|
|
6211
6230
|
}
|
|
6212
6231
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6213
6232
|
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 "); }));
|
|
@@ -6233,7 +6252,7 @@
|
|
|
6233
6252
|
// Note: 4️⃣ Process each template of the pipeline
|
|
6234
6253
|
templates: for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
|
|
6235
6254
|
var section = pipelineSections_1_1.value;
|
|
6236
|
-
var state_1 =
|
|
6255
|
+
var state_1 = _loop_2(section);
|
|
6237
6256
|
switch (state_1) {
|
|
6238
6257
|
case "continue-templates": continue templates;
|
|
6239
6258
|
}
|