@promptbook/cli 0.68.0-3 → 0.68.0-5
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/README.md +2 -2
- package/esm/index.es.js +218 -185
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +3 -3
- package/esm/typings/src/_packages/core.index.d.ts +4 -4
- package/esm/typings/src/_packages/types.index.d.ts +4 -2
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +3 -0
- package/esm/typings/src/commands/TEMPLATE/TemplateCommand.d.ts +11 -0
- package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +15 -0
- package/esm/typings/src/commands/TEMPLATE/templateCommandParser.d.ts +20 -0
- package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +3 -0
- package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +3 -0
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +0 -3
- package/esm/typings/src/commands/_common/getParserForCommand.d.ts +11 -0
- package/esm/typings/src/commands/_common/stringifyCommand.d.ts +11 -0
- package/esm/typings/src/commands/_common/stringifyCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -2
- package/esm/typings/src/commands/index.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +1 -1
- package/esm/typings/src/conversion/validation/pipelineStringToJson-parseErrors.test.d.ts +4 -0
- package/esm/typings/src/conversion/validation/validatePipeline-logicErrors.test.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.test.d.ts +3 -0
- package/esm/typings/src/errors/PipelineLogicError.d.ts +1 -1
- package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
- package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +2 -2
- package/esm/typings/src/types/PipelineJson/ScriptTemplateJson.d.ts +2 -2
- package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
- package/esm/typings/src/types/TaskProgress.d.ts +2 -2
- package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +0 -1
- package/package.json +1 -1
- package/umd/index.umd.js +218 -185
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/BLOCK/BlockCommand.d.ts +0 -11
- package/esm/typings/src/commands/BLOCK/BlockTypes.d.ts +0 -15
- package/esm/typings/src/commands/BLOCK/blockCommandParser.d.ts +0 -9
- /package/esm/typings/src/commands/{BLOCK/blockCommand.test.d.ts → TEMPLATE/templateCommand.test.d.ts} +0 -0
- /package/esm/typings/src/{conversion/validation/pipelineStringToJson-syntaxErrors.test.d.ts → commands/_common/getParserForCommand.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -20,7 +20,7 @@ import OpenAI from 'openai';
|
|
|
20
20
|
/**
|
|
21
21
|
* The version of the Promptbook library
|
|
22
22
|
*/
|
|
23
|
-
var PROMPTBOOK_VERSION = '0.68.0-
|
|
23
|
+
var PROMPTBOOK_VERSION = '0.68.0-4';
|
|
24
24
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
25
25
|
|
|
26
26
|
/*! *****************************************************************************
|
|
@@ -703,7 +703,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
703
703
|
/* Note: Not using:> name, */
|
|
704
704
|
title_1 = template.title, description_1 = template.description,
|
|
705
705
|
/* Note: dependentParameterNames, */
|
|
706
|
-
jokers = template.jokerParameterNames,
|
|
706
|
+
jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
|
|
707
707
|
pipelineString += '\n\n';
|
|
708
708
|
pipelineString += "## ".concat(title_1);
|
|
709
709
|
if (description_1) {
|
|
@@ -713,7 +713,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
713
713
|
// TODO:> const commands: Array<Command>
|
|
714
714
|
var commands_1 = [];
|
|
715
715
|
var contentLanguage = 'text';
|
|
716
|
-
if (
|
|
716
|
+
if (templateType === 'PROMPT_TEMPLATE') {
|
|
717
717
|
var modelRequirements = template.modelRequirements;
|
|
718
718
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
719
719
|
commands_1.push("EXECUTE PROMPT TEMPLATE");
|
|
@@ -724,12 +724,12 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
724
724
|
commands_1.push("MODEL NAME `".concat(modelName, "`"));
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
|
-
else if (
|
|
727
|
+
else if (templateType === 'SIMPLE_TEMPLATE') {
|
|
728
728
|
commands_1.push("SIMPLE TEMPLATE");
|
|
729
729
|
// Note: Nothing special here
|
|
730
730
|
}
|
|
731
|
-
else if (
|
|
732
|
-
commands_1.push("
|
|
731
|
+
else if (templateType === 'SCRIPT_TEMPLATE') {
|
|
732
|
+
commands_1.push("SCRIPT TEMPLATE");
|
|
733
733
|
if (template.contentLanguage) {
|
|
734
734
|
contentLanguage = template.contentLanguage;
|
|
735
735
|
}
|
|
@@ -737,8 +737,8 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
737
737
|
contentLanguage = '';
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
|
-
else if (
|
|
741
|
-
commands_1.push("DIALOG
|
|
740
|
+
else if (templateType === 'DIALOG_TEMPLATE') {
|
|
741
|
+
commands_1.push("DIALOG TEMPLATE");
|
|
742
742
|
// Note: Nothing special here
|
|
743
743
|
} // <- }else if([🅱]
|
|
744
744
|
if (jokers) {
|
|
@@ -837,7 +837,7 @@ function templateParameterJsonToString(templateParameterJson) {
|
|
|
837
837
|
return parameterString;
|
|
838
838
|
}
|
|
839
839
|
/**
|
|
840
|
-
* TODO:
|
|
840
|
+
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `templateParameterJsonToString` , use `stringifyCommand`
|
|
841
841
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
842
842
|
* TODO: [🏛] Maybe make some markdown builder
|
|
843
843
|
* TODO: [🏛] Escape all
|
|
@@ -1040,7 +1040,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1040
1040
|
});
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-
|
|
1043
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-4",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],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.68.0-4",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],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.68.0-4",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],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.68.0-4",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}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",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}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1044
1044
|
|
|
1045
1045
|
/**
|
|
1046
1046
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1062,7 +1062,7 @@ var ParseError = /** @class */ (function (_super) {
|
|
|
1062
1062
|
*/
|
|
1063
1063
|
|
|
1064
1064
|
/**
|
|
1065
|
-
* This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
|
|
1065
|
+
* This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
|
|
1066
1066
|
*
|
|
1067
1067
|
* @public exported from `@promptbook/core`
|
|
1068
1068
|
*/
|
|
@@ -1644,7 +1644,7 @@ var SimplePipelineCollection = /** @class */ (function () {
|
|
|
1644
1644
|
* Creates PipelineCollection from array of PipelineJson or PipelineString
|
|
1645
1645
|
*
|
|
1646
1646
|
* Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
|
|
1647
|
-
* Note:
|
|
1647
|
+
* Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
|
|
1648
1648
|
*
|
|
1649
1649
|
* @param promptbookSources
|
|
1650
1650
|
* @returns PipelineCollection
|
|
@@ -2227,7 +2227,7 @@ function extractVariables(script) {
|
|
|
2227
2227
|
*/
|
|
2228
2228
|
function extractParameterNamesFromTemplate(template) {
|
|
2229
2229
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
2230
|
-
var title = template.title, description = template.description,
|
|
2230
|
+
var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
|
|
2231
2231
|
var parameterNames = new Set();
|
|
2232
2232
|
try {
|
|
2233
2233
|
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
@@ -2242,7 +2242,7 @@ function extractParameterNamesFromTemplate(template) {
|
|
|
2242
2242
|
}
|
|
2243
2243
|
finally { if (e_1) throw e_1.error; }
|
|
2244
2244
|
}
|
|
2245
|
-
if (
|
|
2245
|
+
if (templateType === 'SCRIPT_TEMPLATE') {
|
|
2246
2246
|
try {
|
|
2247
2247
|
for (var _f = __values(extractVariables(content)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
2248
2248
|
var parameterName = _g.value;
|
|
@@ -3222,7 +3222,7 @@ function createPipelineExecutor(options) {
|
|
|
3222
3222
|
title: title,
|
|
3223
3223
|
isStarted: false,
|
|
3224
3224
|
isDone: false,
|
|
3225
|
-
|
|
3225
|
+
templateType: currentTemplate.templateType,
|
|
3226
3226
|
parameterName: currentTemplate.resultingParameterName,
|
|
3227
3227
|
parameterValue: null,
|
|
3228
3228
|
// <- [3]
|
|
@@ -3287,7 +3287,7 @@ function createPipelineExecutor(options) {
|
|
|
3287
3287
|
result = null;
|
|
3288
3288
|
resultString = null;
|
|
3289
3289
|
expectError = null;
|
|
3290
|
-
maxAttempts = currentTemplate.
|
|
3290
|
+
maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
|
|
3291
3291
|
jokerParameterNames = currentTemplate.jokerParameterNames || [];
|
|
3292
3292
|
preparedContent = (currentTemplate.preparedContent || '{content}')
|
|
3293
3293
|
.split('{content}')
|
|
@@ -3319,7 +3319,7 @@ function createPipelineExecutor(options) {
|
|
|
3319
3319
|
case 1:
|
|
3320
3320
|
_v.trys.push([1, 44, 45, 46]);
|
|
3321
3321
|
if (!!isJokerAttempt) return [3 /*break*/, 26];
|
|
3322
|
-
_j = currentTemplate.
|
|
3322
|
+
_j = currentTemplate.templateType;
|
|
3323
3323
|
switch (_j) {
|
|
3324
3324
|
case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
|
|
3325
3325
|
case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
|
|
@@ -3453,10 +3453,10 @@ function createPipelineExecutor(options) {
|
|
|
3453
3453
|
priority: priority,
|
|
3454
3454
|
}))];
|
|
3455
3455
|
case 24:
|
|
3456
|
-
// TODO: [🌹] When making next attempt for `DIALOG
|
|
3456
|
+
// TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
|
|
3457
3457
|
resultString = _v.sent();
|
|
3458
3458
|
return [3 /*break*/, 26];
|
|
3459
|
-
case 25: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(currentTemplate.
|
|
3459
|
+
case 25: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(currentTemplate.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3460
3460
|
case 26:
|
|
3461
3461
|
if (!(!isJokerAttempt && currentTemplate.postprocessingFunctionNames)) return [3 /*break*/, 43];
|
|
3462
3462
|
_v.label = 27;
|
|
@@ -3571,12 +3571,12 @@ function createPipelineExecutor(options) {
|
|
|
3571
3571
|
return [3 /*break*/, 46];
|
|
3572
3572
|
case 45:
|
|
3573
3573
|
if (!isJokerAttempt &&
|
|
3574
|
-
currentTemplate.
|
|
3574
|
+
currentTemplate.templateType === 'PROMPT_TEMPLATE' &&
|
|
3575
3575
|
prompt
|
|
3576
3576
|
// <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
|
|
3577
3577
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
3578
3578
|
) {
|
|
3579
|
-
// TODO: [🧠] Maybe put other
|
|
3579
|
+
// TODO: [🧠] Maybe put other templateTypes into report
|
|
3580
3580
|
executionReport.promptExecutions.push({
|
|
3581
3581
|
prompt: __assign({}, prompt),
|
|
3582
3582
|
result: result || undefined,
|
|
@@ -3627,7 +3627,7 @@ function createPipelineExecutor(options) {
|
|
|
3627
3627
|
title: title,
|
|
3628
3628
|
isStarted: true,
|
|
3629
3629
|
isDone: true,
|
|
3630
|
-
|
|
3630
|
+
templateType: currentTemplate.templateType,
|
|
3631
3631
|
parameterName: currentTemplate.resultingParameterName,
|
|
3632
3632
|
parameterValue: resultString,
|
|
3633
3633
|
// <- [3]
|
|
@@ -4595,7 +4595,7 @@ var knowledgeCommandParser = {
|
|
|
4595
4595
|
*/
|
|
4596
4596
|
stringify: function (command) {
|
|
4597
4597
|
keepUnused(command);
|
|
4598
|
-
return "
|
|
4598
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
4599
4599
|
},
|
|
4600
4600
|
/**
|
|
4601
4601
|
* Reads the KNOWLEDGE command from the `PipelineJson`
|
|
@@ -4604,17 +4604,20 @@ var knowledgeCommandParser = {
|
|
|
4604
4604
|
*/
|
|
4605
4605
|
takeFromPipelineJson: function (pipelineJson) {
|
|
4606
4606
|
keepUnused(pipelineJson);
|
|
4607
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
4607
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
4608
4608
|
},
|
|
4609
4609
|
};
|
|
4610
|
+
/**
|
|
4611
|
+
* Note: [⛱] There are two types of KNOWLEDGE commands *...(read more in [⛱])*
|
|
4612
|
+
*/
|
|
4610
4613
|
|
|
4611
4614
|
/**
|
|
4612
|
-
*
|
|
4615
|
+
* Template type describes the way how the template is templated
|
|
4613
4616
|
*
|
|
4614
|
-
* @see https://github.com/webgptorg/promptbook#
|
|
4617
|
+
* @see https://github.com/webgptorg/promptbook#template-type
|
|
4615
4618
|
* @public exported from `@promptbook/core`
|
|
4616
4619
|
*/
|
|
4617
|
-
var
|
|
4620
|
+
var TemplateTypes = [
|
|
4618
4621
|
'PROMPT_TEMPLATE',
|
|
4619
4622
|
'SIMPLE_TEMPLATE',
|
|
4620
4623
|
'SCRIPT_TEMPLATE',
|
|
@@ -4627,109 +4630,114 @@ var BlockTypes = [
|
|
|
4627
4630
|
];
|
|
4628
4631
|
|
|
4629
4632
|
/**
|
|
4630
|
-
* Parses the
|
|
4633
|
+
* Parses the template command
|
|
4631
4634
|
*
|
|
4632
|
-
* @see ./
|
|
4635
|
+
* @see ./TEMPLATE-README.md for more details
|
|
4633
4636
|
* @private within the commands folder
|
|
4634
4637
|
*/
|
|
4635
|
-
var
|
|
4638
|
+
var templateCommandParser = {
|
|
4636
4639
|
/**
|
|
4637
4640
|
* Name of the command
|
|
4638
4641
|
*/
|
|
4639
|
-
name: '
|
|
4642
|
+
name: 'TEMPLATE',
|
|
4640
4643
|
/**
|
|
4641
|
-
* Aliases for the
|
|
4644
|
+
* Aliases for the TEMPLATE command
|
|
4642
4645
|
*/
|
|
4643
4646
|
aliasNames: [
|
|
4644
|
-
'
|
|
4645
|
-
'
|
|
4646
|
-
'
|
|
4647
|
-
'
|
|
4647
|
+
'PROMPT',
|
|
4648
|
+
'SIMPLE',
|
|
4649
|
+
'SCRIPT',
|
|
4650
|
+
'DIALOG',
|
|
4648
4651
|
'SAMPLE',
|
|
4649
4652
|
'EXAMPLE',
|
|
4650
4653
|
'KNOWLEDGE',
|
|
4651
4654
|
'INSTRUMENT',
|
|
4652
|
-
'ACTION',
|
|
4653
|
-
// <- [🅱]
|
|
4655
|
+
'ACTION', // <- Note: [⛱]
|
|
4654
4656
|
],
|
|
4655
4657
|
/**
|
|
4656
|
-
* Aliases for the
|
|
4658
|
+
* Aliases for the TEMPLATE command
|
|
4657
4659
|
*/
|
|
4658
|
-
deprecatedNames: ['EXECUTE'],
|
|
4660
|
+
deprecatedNames: ['BLOCK', 'EXECUTE'],
|
|
4659
4661
|
/**
|
|
4660
4662
|
* BOILERPLATE command can be used in:
|
|
4661
4663
|
*/
|
|
4662
4664
|
isUsedInPipelineHead: false,
|
|
4663
4665
|
isUsedInPipelineTemplate: true,
|
|
4664
4666
|
/**
|
|
4665
|
-
* Description of the
|
|
4667
|
+
* Description of the TEMPLATE command
|
|
4666
4668
|
*/
|
|
4667
|
-
description: "What should the code
|
|
4669
|
+
description: "What should the code template template do",
|
|
4668
4670
|
/**
|
|
4669
4671
|
* Link to discussion
|
|
4670
4672
|
*/
|
|
4671
4673
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/64',
|
|
4672
4674
|
/**
|
|
4673
|
-
* Example usages of the
|
|
4675
|
+
* Example usages of the TEMPLATE command
|
|
4674
4676
|
*/
|
|
4675
4677
|
examples: [
|
|
4676
|
-
//
|
|
4677
|
-
'PROMPT
|
|
4678
|
-
'SIMPLE
|
|
4679
|
-
'SCRIPT
|
|
4680
|
-
'DIALOG
|
|
4678
|
+
// Short form:
|
|
4679
|
+
'PROMPT',
|
|
4680
|
+
'SIMPLE',
|
|
4681
|
+
'SCRIPT',
|
|
4682
|
+
'DIALOG',
|
|
4681
4683
|
// <- [🅱]
|
|
4682
|
-
|
|
4683
|
-
'
|
|
4684
|
-
'
|
|
4685
|
-
'
|
|
4686
|
-
|
|
4684
|
+
'SAMPLE',
|
|
4685
|
+
'KNOWLEDGE',
|
|
4686
|
+
'INSTRUMENT',
|
|
4687
|
+
'ACTION',
|
|
4688
|
+
// -----------------
|
|
4689
|
+
// Recommended (reversed) form:
|
|
4690
|
+
'PROMPT TEMPLATE',
|
|
4691
|
+
'SIMPLE TEMPLATE',
|
|
4692
|
+
'SCRIPT TEMPLATE',
|
|
4693
|
+
'DIALOG TEMPLATE',
|
|
4687
4694
|
// <- [🅱]
|
|
4688
|
-
|
|
4689
|
-
'
|
|
4690
|
-
'
|
|
4691
|
-
'
|
|
4692
|
-
|
|
4695
|
+
'SAMPLE TEMPLATE',
|
|
4696
|
+
'KNOWLEDGE TEMPLATE',
|
|
4697
|
+
'INSTRUMENT TEMPLATE',
|
|
4698
|
+
'ACTION TEMPLATE',
|
|
4699
|
+
// -----------------
|
|
4700
|
+
// Standard form:
|
|
4701
|
+
'TEMPLATE PROMPT',
|
|
4702
|
+
'TEMPLATE SIMPLE',
|
|
4703
|
+
'TEMPLATE SCRIPT',
|
|
4704
|
+
'TEMPLATE DIALOG',
|
|
4693
4705
|
// <- [🅱]
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
'
|
|
4698
|
-
// 'Instrument', // <- Note: [⛱]
|
|
4699
|
-
'Action BLOCK',
|
|
4700
|
-
// 'Action', // <- Note: [⛱]
|
|
4701
|
-
//---
|
|
4702
|
-
/* <- TODO: [🧠] Maybe dynamic */
|
|
4706
|
+
'SAMPLE TEMPLATE',
|
|
4707
|
+
'KNOWLEDGE TEMPLATE',
|
|
4708
|
+
'INSTRUMENT TEMPLATE',
|
|
4709
|
+
'ACTION TEMPLATE',
|
|
4703
4710
|
],
|
|
4704
4711
|
// TODO: [♓️] order: -10 /* <- Note: Putting before other commands */
|
|
4705
4712
|
/**
|
|
4706
|
-
* Parses the
|
|
4713
|
+
* Parses the TEMPLATE command
|
|
4707
4714
|
*/
|
|
4708
4715
|
parse: function (input) {
|
|
4709
4716
|
var normalized = input.normalized;
|
|
4710
4717
|
normalized = normalized.split('EXAMPLE').join('SAMPLE');
|
|
4711
|
-
var
|
|
4712
|
-
|
|
4713
|
-
|
|
4718
|
+
var templateTypes = TemplateTypes.filter(function (templateType) {
|
|
4719
|
+
return normalized.includes(templateType.split('_TEMPLATE').join(''));
|
|
4720
|
+
});
|
|
4721
|
+
if (templateTypes.length !== 1) {
|
|
4722
|
+
throw new ParseError(spaceTrim$1(function (template) { return "\n Unknown template type in TEMPLATE command\n\n Supported template types are:\n ".concat(template(TemplateTypes.join(', ')), "\n "); }));
|
|
4714
4723
|
}
|
|
4715
|
-
var
|
|
4724
|
+
var templateType = templateTypes[0];
|
|
4716
4725
|
return {
|
|
4717
|
-
type: '
|
|
4718
|
-
|
|
4726
|
+
type: 'TEMPLATE',
|
|
4727
|
+
templateType: templateType,
|
|
4719
4728
|
};
|
|
4720
4729
|
},
|
|
4721
4730
|
/**
|
|
4722
|
-
* Apply the
|
|
4731
|
+
* Apply the TEMPLATE command to the `pipelineJson`
|
|
4723
4732
|
*
|
|
4724
4733
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
4725
4734
|
*/
|
|
4726
4735
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
throw new ParseError(spaceTrim$1("\n Block type is already defined in the template.\n It can be defined only once.\n "));
|
|
4736
|
+
if ($templateJson.isTemplateTypeSet === true) {
|
|
4737
|
+
throw new ParseError(spaceTrim$1("\n Template type is already defined in the template.\n It can be defined only once.\n "));
|
|
4730
4738
|
}
|
|
4731
|
-
$templateJson.
|
|
4732
|
-
// TODO:
|
|
4739
|
+
$templateJson.isTemplateTypeSet = true;
|
|
4740
|
+
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
4733
4741
|
var expectResultingParameterName = function () {
|
|
4734
4742
|
if ($templateJson.resultingParameterName) {
|
|
4735
4743
|
return;
|
|
@@ -4739,7 +4747,7 @@ var blockCommandParser = {
|
|
|
4739
4747
|
if ($templateJson.content === undefined) {
|
|
4740
4748
|
throw new UnexpectedError("Content is missing in the templateJson - probbably commands are applied in wrong order");
|
|
4741
4749
|
}
|
|
4742
|
-
if (command.
|
|
4750
|
+
if (command.templateType === 'SAMPLE') {
|
|
4743
4751
|
expectResultingParameterName();
|
|
4744
4752
|
var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $templateJson.resultingParameterName; });
|
|
4745
4753
|
if (parameter === undefined) {
|
|
@@ -4747,66 +4755,61 @@ var blockCommandParser = {
|
|
|
4747
4755
|
}
|
|
4748
4756
|
parameter.sampleValues = parameter.sampleValues || [];
|
|
4749
4757
|
parameter.sampleValues.push($templateJson.content);
|
|
4750
|
-
|
|
4751
|
-
// continue templates;
|
|
4752
|
-
$templateJson.isTemplateBlock = false;
|
|
4758
|
+
$templateJson.isTemplate = false;
|
|
4753
4759
|
return;
|
|
4754
4760
|
}
|
|
4755
|
-
if (command.
|
|
4761
|
+
if (command.templateType === 'KNOWLEDGE') {
|
|
4756
4762
|
knowledgeCommandParser.$applyToPipelineJson({
|
|
4757
4763
|
type: 'KNOWLEDGE',
|
|
4758
4764
|
sourceContent: $templateJson.content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
4759
4765
|
}, $pipelineJson);
|
|
4760
|
-
|
|
4761
|
-
// continue templates;
|
|
4762
|
-
$templateJson.isTemplateBlock = false;
|
|
4766
|
+
$templateJson.isTemplate = false;
|
|
4763
4767
|
return;
|
|
4764
4768
|
}
|
|
4765
|
-
if (command.
|
|
4769
|
+
if (command.templateType === 'ACTION') {
|
|
4766
4770
|
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
4767
|
-
|
|
4768
|
-
// continue templates;
|
|
4769
|
-
$templateJson.isTemplateBlock = false;
|
|
4771
|
+
$templateJson.isTemplate = false;
|
|
4770
4772
|
return;
|
|
4771
4773
|
}
|
|
4772
|
-
if (command.
|
|
4774
|
+
if (command.templateType === 'INSTRUMENT') {
|
|
4773
4775
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
4774
|
-
|
|
4775
|
-
// continue templates;
|
|
4776
|
-
$templateJson.isTemplateBlock = false;
|
|
4776
|
+
$templateJson.isTemplate = false;
|
|
4777
4777
|
return;
|
|
4778
4778
|
}
|
|
4779
4779
|
expectResultingParameterName();
|
|
4780
|
-
$templateJson.
|
|
4781
|
-
|
|
4782
|
-
TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
|
|
4783
|
-
if (command.blockType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
|
|
4784
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
4785
|
-
}
|
|
4786
|
-
*/
|
|
4787
|
-
// !!!!!!
|
|
4788
|
-
// isBlockTypeSet = true; //<- Note: [2]
|
|
4789
|
-
$templateJson.isTemplateBlock = true;
|
|
4780
|
+
$templateJson.templateType = command.templateType;
|
|
4781
|
+
$templateJson.isTemplate = true;
|
|
4790
4782
|
},
|
|
4791
4783
|
/**
|
|
4792
|
-
* Converts the
|
|
4784
|
+
* Converts the TEMPLATE command back to string
|
|
4793
4785
|
*
|
|
4794
4786
|
* Note: This is used in `pipelineJsonToString` utility
|
|
4795
4787
|
*/
|
|
4796
4788
|
stringify: function (command) {
|
|
4797
4789
|
keepUnused(command);
|
|
4798
|
-
return "
|
|
4790
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
4799
4791
|
},
|
|
4800
4792
|
/**
|
|
4801
|
-
* Reads the
|
|
4793
|
+
* Reads the TEMPLATE command from the `TemplateJson`
|
|
4802
4794
|
*
|
|
4803
4795
|
* Note: This is used in `pipelineJsonToString` utility
|
|
4804
4796
|
*/
|
|
4805
4797
|
takeFromTemplateJson: function ($templateJson) {
|
|
4806
4798
|
keepUnused($templateJson);
|
|
4807
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
4799
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
4808
4800
|
},
|
|
4809
4801
|
};
|
|
4802
|
+
/**
|
|
4803
|
+
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
|
|
4804
|
+
* 1) There are commands `KNOWLEDGE`, `ACTION` and `INSTRUMENT` used in the pipeline head, they just define the knowledge, action or instrument as single line after the command
|
|
4805
|
+
* - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4806
|
+
* 2) `KNOWLEDGE TEMPLATE` which has short form `KNOWLEDGE` is used in the template, does not refer the line itself, but the content of the template
|
|
4807
|
+
* - KNOWLEDGE TEMPLATE
|
|
4808
|
+
*
|
|
4809
|
+
* ```
|
|
4810
|
+
* Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4811
|
+
* ```
|
|
4812
|
+
*/
|
|
4810
4813
|
|
|
4811
4814
|
/**
|
|
4812
4815
|
* Units of text measurement
|
|
@@ -5025,7 +5028,7 @@ var expectCommandParser = {
|
|
|
5025
5028
|
*/
|
|
5026
5029
|
stringify: function (command) {
|
|
5027
5030
|
keepUnused(command);
|
|
5028
|
-
return "
|
|
5031
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5029
5032
|
},
|
|
5030
5033
|
/**
|
|
5031
5034
|
* Reads the FORMAT command from the `TemplateJson`
|
|
@@ -5034,7 +5037,7 @@ var expectCommandParser = {
|
|
|
5034
5037
|
*/
|
|
5035
5038
|
takeFromTemplateJson: function ($templateJson) {
|
|
5036
5039
|
keepUnused($templateJson);
|
|
5037
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5040
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5038
5041
|
},
|
|
5039
5042
|
};
|
|
5040
5043
|
|
|
@@ -5119,7 +5122,7 @@ var foreachCommandParser = {
|
|
|
5119
5122
|
},
|
|
5120
5123
|
};
|
|
5121
5124
|
/**
|
|
5122
|
-
* TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong
|
|
5125
|
+
* TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
|
|
5123
5126
|
*/
|
|
5124
5127
|
|
|
5125
5128
|
/**
|
|
@@ -5183,7 +5186,7 @@ var formatCommandParser = {
|
|
|
5183
5186
|
*/
|
|
5184
5187
|
stringify: function (command) {
|
|
5185
5188
|
keepUnused(command);
|
|
5186
|
-
return "
|
|
5189
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5187
5190
|
},
|
|
5188
5191
|
/**
|
|
5189
5192
|
* Reads the FORMAT command from the `TemplateJson`
|
|
@@ -5192,7 +5195,7 @@ var formatCommandParser = {
|
|
|
5192
5195
|
*/
|
|
5193
5196
|
takeFromTemplateJson: function ($templateJson) {
|
|
5194
5197
|
keepUnused($templateJson);
|
|
5195
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5198
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5196
5199
|
},
|
|
5197
5200
|
};
|
|
5198
5201
|
|
|
@@ -5255,7 +5258,7 @@ var jokerCommandParser = {
|
|
|
5255
5258
|
*/
|
|
5256
5259
|
stringify: function (command) {
|
|
5257
5260
|
keepUnused(command);
|
|
5258
|
-
return "
|
|
5261
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5259
5262
|
},
|
|
5260
5263
|
/**
|
|
5261
5264
|
* Reads the JOKER command from the `TemplateJson`
|
|
@@ -5264,7 +5267,7 @@ var jokerCommandParser = {
|
|
|
5264
5267
|
*/
|
|
5265
5268
|
takeFromTemplateJson: function ($templateJson) {
|
|
5266
5269
|
keepUnused($templateJson);
|
|
5267
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5270
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5268
5271
|
},
|
|
5269
5272
|
};
|
|
5270
5273
|
|
|
@@ -5344,7 +5347,7 @@ var modelCommandParser = {
|
|
|
5344
5347
|
};
|
|
5345
5348
|
}
|
|
5346
5349
|
else {
|
|
5347
|
-
throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown model key in command.\n\n Supported model keys are:\n ".concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n
|
|
5350
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown model key in command.\n\n Supported model keys are:\n ".concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
|
|
5348
5351
|
}
|
|
5349
5352
|
},
|
|
5350
5353
|
/**
|
|
@@ -5353,8 +5356,16 @@ var modelCommandParser = {
|
|
|
5353
5356
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
5354
5357
|
*/
|
|
5355
5358
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5356
|
-
// TODO: !!!!!! Error on redefine
|
|
5357
5359
|
$pipelineJson.defaultModelRequirements = $pipelineJson.defaultModelRequirements || {};
|
|
5360
|
+
// TODO: [🚜] DRY
|
|
5361
|
+
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
5362
|
+
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
5363
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
5364
|
+
}
|
|
5365
|
+
else {
|
|
5366
|
+
throw new ParseError(spaceTrim$1("\n Redefinition of MODEL `".concat(command.key, "` in the pipeline head\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|
|
5367
|
+
}
|
|
5368
|
+
}
|
|
5358
5369
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
5359
5370
|
},
|
|
5360
5371
|
/**
|
|
@@ -5362,13 +5373,23 @@ var modelCommandParser = {
|
|
|
5362
5373
|
*
|
|
5363
5374
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5364
5375
|
*/
|
|
5365
|
-
$applyToTemplateJson: function (command, $templateJson) {
|
|
5366
|
-
if ($templateJson.
|
|
5376
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5377
|
+
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5367
5378
|
throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
|
|
5368
5379
|
}
|
|
5369
|
-
// TODO: !!!!!! Error on redefine
|
|
5370
|
-
// TODO: Warn if setting same as default in `$pipelineJson`
|
|
5371
5380
|
$templateJson.modelRequirements = $templateJson.modelRequirements || {};
|
|
5381
|
+
// TODO: [🚜] DRY
|
|
5382
|
+
if ($templateJson.modelRequirements[command.key] !== undefined) {
|
|
5383
|
+
if ($templateJson.modelRequirements[command.key] === command.value) {
|
|
5384
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the template \"").concat($templateJson.title || $templateJson.name, "\""));
|
|
5385
|
+
}
|
|
5386
|
+
else {
|
|
5387
|
+
throw new ParseError(spaceTrim$1("\n Redefinition of MODEL `".concat(command.key, "` in the template \"").concat($templateJson.title || $templateJson.name, "\"\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($templateJson.modelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
5391
|
+
console.log(spaceTrim$1("\n Setting MODEL `".concat(command.key, "` in the template \"").concat($templateJson.title || $templateJson.name, "\" to the same value as in the pipeline head\n\n In pipeline head:\n - MODEL ").concat(command.key, " ").concat(($pipelineJson.defaultModelRequirements || {})[command.key], "\n\n But same value is used in the template:\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|
|
5392
|
+
}
|
|
5372
5393
|
$templateJson.modelRequirements[command.key] = command.value;
|
|
5373
5394
|
},
|
|
5374
5395
|
/**
|
|
@@ -5378,7 +5399,7 @@ var modelCommandParser = {
|
|
|
5378
5399
|
*/
|
|
5379
5400
|
stringify: function (command) {
|
|
5380
5401
|
keepUnused(command);
|
|
5381
|
-
return "
|
|
5402
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5382
5403
|
},
|
|
5383
5404
|
/**
|
|
5384
5405
|
* Reads the MODEL command from the `PipelineJson`
|
|
@@ -5387,7 +5408,7 @@ var modelCommandParser = {
|
|
|
5387
5408
|
*/
|
|
5388
5409
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5389
5410
|
keepUnused(pipelineJson);
|
|
5390
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5411
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5391
5412
|
},
|
|
5392
5413
|
/**
|
|
5393
5414
|
* Reads the MODEL command from the `TemplateJson`
|
|
@@ -5396,7 +5417,7 @@ var modelCommandParser = {
|
|
|
5396
5417
|
*/
|
|
5397
5418
|
takeFromTemplateJson: function ($templateJson) {
|
|
5398
5419
|
keepUnused($templateJson);
|
|
5399
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5420
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5400
5421
|
},
|
|
5401
5422
|
};
|
|
5402
5423
|
|
|
@@ -5487,7 +5508,7 @@ var parameterCommandParser = {
|
|
|
5487
5508
|
*/
|
|
5488
5509
|
stringify: function (command) {
|
|
5489
5510
|
keepUnused(command);
|
|
5490
|
-
return "
|
|
5511
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5491
5512
|
},
|
|
5492
5513
|
/**
|
|
5493
5514
|
* Reads the PARAMETER command from the `PipelineJson`
|
|
@@ -5496,7 +5517,7 @@ var parameterCommandParser = {
|
|
|
5496
5517
|
*/
|
|
5497
5518
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5498
5519
|
keepUnused(pipelineJson);
|
|
5499
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5520
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5500
5521
|
},
|
|
5501
5522
|
/**
|
|
5502
5523
|
* Reads the PARAMETER command from the `TemplateJson`
|
|
@@ -5505,7 +5526,7 @@ var parameterCommandParser = {
|
|
|
5505
5526
|
*/
|
|
5506
5527
|
takeFromTemplateJson: function ($templateJson) {
|
|
5507
5528
|
keepUnused($templateJson);
|
|
5508
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5529
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5509
5530
|
},
|
|
5510
5531
|
};
|
|
5511
5532
|
|
|
@@ -5577,7 +5598,7 @@ var personaCommandParser = {
|
|
|
5577
5598
|
*/
|
|
5578
5599
|
stringify: function (command) {
|
|
5579
5600
|
keepUnused(command);
|
|
5580
|
-
return "
|
|
5601
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5581
5602
|
},
|
|
5582
5603
|
/**
|
|
5583
5604
|
* Reads the PERSONA command from the `PipelineJson`
|
|
@@ -5586,7 +5607,7 @@ var personaCommandParser = {
|
|
|
5586
5607
|
*/
|
|
5587
5608
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5588
5609
|
keepUnused(pipelineJson);
|
|
5589
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5610
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5590
5611
|
},
|
|
5591
5612
|
/**
|
|
5592
5613
|
* Reads the PERSONA command from the `TemplateJson`
|
|
@@ -5595,7 +5616,7 @@ var personaCommandParser = {
|
|
|
5595
5616
|
*/
|
|
5596
5617
|
takeFromTemplateJson: function ($templateJson) {
|
|
5597
5618
|
keepUnused($templateJson);
|
|
5598
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5619
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5599
5620
|
},
|
|
5600
5621
|
};
|
|
5601
5622
|
/**
|
|
@@ -5606,7 +5627,7 @@ var personaCommandParser = {
|
|
|
5606
5627
|
function $applyToTemplateJson(command, $templateJson, $pipelineJson) {
|
|
5607
5628
|
var personaName = command.personaName, personaDescription = command.personaDescription;
|
|
5608
5629
|
if ($templateJson !== null) {
|
|
5609
|
-
if ($templateJson.
|
|
5630
|
+
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5610
5631
|
throw new ParseError("PERSONA command can be used only in PROMPT_TEMPLATE block");
|
|
5611
5632
|
}
|
|
5612
5633
|
$templateJson.personaName = personaName;
|
|
@@ -5714,7 +5735,7 @@ var postprocessCommandParser = {
|
|
|
5714
5735
|
*/
|
|
5715
5736
|
stringify: function (command) {
|
|
5716
5737
|
keepUnused(command);
|
|
5717
|
-
return "
|
|
5738
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5718
5739
|
},
|
|
5719
5740
|
/**
|
|
5720
5741
|
* Reads the POSTPROCESS command from the `TemplateJson`
|
|
@@ -5723,7 +5744,7 @@ var postprocessCommandParser = {
|
|
|
5723
5744
|
*/
|
|
5724
5745
|
takeFromTemplateJson: function ($templateJson) {
|
|
5725
5746
|
keepUnused($templateJson);
|
|
5726
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5747
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5727
5748
|
},
|
|
5728
5749
|
};
|
|
5729
5750
|
|
|
@@ -5791,7 +5812,7 @@ var promptbookVersionCommandParser = {
|
|
|
5791
5812
|
*/
|
|
5792
5813
|
stringify: function (command) {
|
|
5793
5814
|
keepUnused(command);
|
|
5794
|
-
return "
|
|
5815
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5795
5816
|
},
|
|
5796
5817
|
/**
|
|
5797
5818
|
* Reads the PROMPTBOOK_VERSION command from the `PipelineJson`
|
|
@@ -5800,7 +5821,7 @@ var promptbookVersionCommandParser = {
|
|
|
5800
5821
|
*/
|
|
5801
5822
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5802
5823
|
keepUnused(pipelineJson);
|
|
5803
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5824
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5804
5825
|
},
|
|
5805
5826
|
};
|
|
5806
5827
|
|
|
@@ -5850,7 +5871,7 @@ var urlCommandParser = {
|
|
|
5850
5871
|
if (pipelineUrl === undefined) {
|
|
5851
5872
|
throw new ParseError("URL is required");
|
|
5852
5873
|
}
|
|
5853
|
-
// TODO: [🧠][🚲] This should be maybe tested as logic not
|
|
5874
|
+
// TODO: [🧠][🚲] This should be maybe tested as logic not parse
|
|
5854
5875
|
if (!isValidPipelineUrl(pipelineUrl)) {
|
|
5855
5876
|
throw new ParseError("Invalid pipeline URL \"".concat(pipelineUrl, "\""));
|
|
5856
5877
|
}
|
|
@@ -5894,7 +5915,7 @@ var urlCommandParser = {
|
|
|
5894
5915
|
*/
|
|
5895
5916
|
stringify: function (command) {
|
|
5896
5917
|
keepUnused(command);
|
|
5897
|
-
return "
|
|
5918
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5898
5919
|
},
|
|
5899
5920
|
/**
|
|
5900
5921
|
* Reads the URL command from the `PipelineJson`
|
|
@@ -5903,7 +5924,7 @@ var urlCommandParser = {
|
|
|
5903
5924
|
*/
|
|
5904
5925
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5905
5926
|
keepUnused(pipelineJson);
|
|
5906
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5927
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5907
5928
|
},
|
|
5908
5929
|
};
|
|
5909
5930
|
|
|
@@ -5952,7 +5973,7 @@ var actionCommandParser = {
|
|
|
5952
5973
|
*/
|
|
5953
5974
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5954
5975
|
keepUnused(command, $pipelineJson);
|
|
5955
|
-
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
5976
|
+
console.error(new NotYetImplementedError('[🛠] Actions are not implemented yet'));
|
|
5956
5977
|
},
|
|
5957
5978
|
/**
|
|
5958
5979
|
* Converts the ACTION command back to string
|
|
@@ -5961,7 +5982,7 @@ var actionCommandParser = {
|
|
|
5961
5982
|
*/
|
|
5962
5983
|
stringify: function (command) {
|
|
5963
5984
|
keepUnused(command);
|
|
5964
|
-
|
|
5985
|
+
throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
|
|
5965
5986
|
},
|
|
5966
5987
|
/**
|
|
5967
5988
|
* Reads the ACTION command from the `PipelineJson`
|
|
@@ -5970,9 +5991,12 @@ var actionCommandParser = {
|
|
|
5970
5991
|
*/
|
|
5971
5992
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5972
5993
|
keepUnused(pipelineJson);
|
|
5973
|
-
throw new NotYetImplementedError(
|
|
5994
|
+
throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
|
|
5974
5995
|
},
|
|
5975
5996
|
};
|
|
5997
|
+
/**
|
|
5998
|
+
* Note: [⛱] There are two types of ACTION commands *...(read more in [⛱])*
|
|
5999
|
+
*/
|
|
5976
6000
|
|
|
5977
6001
|
/**
|
|
5978
6002
|
* Parses the instrument command
|
|
@@ -6007,6 +6031,7 @@ var instrumentCommandParser = {
|
|
|
6007
6031
|
*/
|
|
6008
6032
|
parse: function (input) {
|
|
6009
6033
|
var args = input.args;
|
|
6034
|
+
// TODO: [🛠] Implement
|
|
6010
6035
|
TODO_USE(args);
|
|
6011
6036
|
return {
|
|
6012
6037
|
type: 'INSTRUMENT',
|
|
@@ -6019,7 +6044,7 @@ var instrumentCommandParser = {
|
|
|
6019
6044
|
*/
|
|
6020
6045
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6021
6046
|
keepUnused(command, $pipelineJson);
|
|
6022
|
-
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6047
|
+
console.error(new NotYetImplementedError('[🛠] Instruments are not implemented yet'));
|
|
6023
6048
|
},
|
|
6024
6049
|
/**
|
|
6025
6050
|
* Converts the INSTRUMENT command back to string
|
|
@@ -6028,7 +6053,7 @@ var instrumentCommandParser = {
|
|
|
6028
6053
|
*/
|
|
6029
6054
|
stringify: function (command) {
|
|
6030
6055
|
keepUnused(command);
|
|
6031
|
-
|
|
6056
|
+
throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
|
|
6032
6057
|
},
|
|
6033
6058
|
/**
|
|
6034
6059
|
* Reads the INSTRUMENT command from the `PipelineJson`
|
|
@@ -6037,9 +6062,12 @@ var instrumentCommandParser = {
|
|
|
6037
6062
|
*/
|
|
6038
6063
|
takeFromPipelineJson: function (pipelineJson) {
|
|
6039
6064
|
keepUnused(pipelineJson);
|
|
6040
|
-
throw new NotYetImplementedError(
|
|
6065
|
+
throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
|
|
6041
6066
|
},
|
|
6042
6067
|
};
|
|
6068
|
+
/**
|
|
6069
|
+
* Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
|
|
6070
|
+
*/
|
|
6043
6071
|
|
|
6044
6072
|
/**
|
|
6045
6073
|
* Parses the boilerplate command
|
|
@@ -6117,7 +6145,7 @@ var boilerplateCommandParser = {
|
|
|
6117
6145
|
*/
|
|
6118
6146
|
stringify: function (command) {
|
|
6119
6147
|
keepUnused(command);
|
|
6120
|
-
return "
|
|
6148
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
6121
6149
|
},
|
|
6122
6150
|
/**
|
|
6123
6151
|
* Reads the BOILERPLATE command from the `PipelineJson`
|
|
@@ -6138,9 +6166,6 @@ var boilerplateCommandParser = {
|
|
|
6138
6166
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
6139
6167
|
},
|
|
6140
6168
|
};
|
|
6141
|
-
/**
|
|
6142
|
-
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
6143
|
-
*/
|
|
6144
6169
|
|
|
6145
6170
|
/**
|
|
6146
6171
|
* All available command parsers
|
|
@@ -6148,7 +6173,7 @@ var boilerplateCommandParser = {
|
|
|
6148
6173
|
* @private internal index of `parseCommand`
|
|
6149
6174
|
*/
|
|
6150
6175
|
var COMMANDS = [
|
|
6151
|
-
|
|
6176
|
+
templateCommandParser,
|
|
6152
6177
|
expectCommandParser,
|
|
6153
6178
|
formatCommandParser,
|
|
6154
6179
|
jokerCommandParser,
|
|
@@ -6163,8 +6188,28 @@ var COMMANDS = [
|
|
|
6163
6188
|
personaCommandParser,
|
|
6164
6189
|
foreachCommandParser,
|
|
6165
6190
|
boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
|
|
6191
|
+
// <- Note: [♓️] This is the order of the commands in the pipeline, BUT its not used in parsing and before usage maybe it should be done better
|
|
6166
6192
|
];
|
|
6167
6193
|
|
|
6194
|
+
/**
|
|
6195
|
+
* Gets the parser for the command
|
|
6196
|
+
*
|
|
6197
|
+
* @returns the parser for the command
|
|
6198
|
+
* @throws {UnexpectedError} if the parser is not found
|
|
6199
|
+
*
|
|
6200
|
+
* @private within the pipelineStringToJson
|
|
6201
|
+
*/
|
|
6202
|
+
function getParserForCommand(command) {
|
|
6203
|
+
var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
|
|
6204
|
+
if (commandParser === undefined) {
|
|
6205
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found\n\n ").concat(block(JSON.stringify(command, null, 4)
|
|
6206
|
+
.split('\n')
|
|
6207
|
+
.map(function (line) { return "> ".concat(line); })
|
|
6208
|
+
.join('\n')), "\n "); }));
|
|
6209
|
+
}
|
|
6210
|
+
return commandParser;
|
|
6211
|
+
}
|
|
6212
|
+
|
|
6168
6213
|
/**
|
|
6169
6214
|
* Removes Markdown formatting tags from a string.
|
|
6170
6215
|
*
|
|
@@ -6300,7 +6345,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
6300
6345
|
.map(function (item) { return item.trim(); });
|
|
6301
6346
|
if (items.length === 0 || items[0] === '') {
|
|
6302
6347
|
throw new ParseError(spaceTrim(function (block) {
|
|
6303
|
-
return "\n Malformed command:\n
|
|
6348
|
+
return "\n Malformed command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
|
|
6304
6349
|
}));
|
|
6305
6350
|
}
|
|
6306
6351
|
// Note: Taking command name from beginning of the line
|
|
@@ -6327,7 +6372,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
6327
6372
|
}
|
|
6328
6373
|
}
|
|
6329
6374
|
throw new ParseError(spaceTrim(function (block) {
|
|
6330
|
-
return "\n Malformed or unknown command:\n
|
|
6375
|
+
return "\n Malformed or unknown command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
|
|
6331
6376
|
}));
|
|
6332
6377
|
}
|
|
6333
6378
|
/**
|
|
@@ -6371,7 +6416,7 @@ function parseCommandVariant(input) {
|
|
|
6371
6416
|
throw error;
|
|
6372
6417
|
}
|
|
6373
6418
|
throw new ParseError(spaceTrim(function (block) {
|
|
6374
|
-
return "\n Invalid ".concat(commandName, " command:\n ").concat(
|
|
6419
|
+
return "\n Invalid ".concat(commandName, " command:\n\n Your command:\n - ").concat(raw, "\n\n The detailed error:\n ").concat(block(error.message), "\n\n Usage of ").concat(commandName, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n All supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
|
|
6375
6420
|
}));
|
|
6376
6421
|
}
|
|
6377
6422
|
}
|
|
@@ -6634,7 +6679,7 @@ function removeContentComments(content) {
|
|
|
6634
6679
|
* - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
6635
6680
|
* - `preparePipeline` - just one step in the compilation process
|
|
6636
6681
|
*
|
|
6637
|
-
* Note: This function does not validate logic of the pipeline only the
|
|
6682
|
+
* Note: This function does not validate logic of the pipeline only the parsing
|
|
6638
6683
|
* Note: This function acts as compilation process
|
|
6639
6684
|
*
|
|
6640
6685
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
@@ -6731,10 +6776,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6731
6776
|
var _loop_1 = function (listItem) {
|
|
6732
6777
|
// TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineHeadCommands`
|
|
6733
6778
|
var command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
6734
|
-
var commandParser =
|
|
6735
|
-
if (commandParser === undefined) {
|
|
6736
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found \uD83C\uDF4E\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6737
|
-
}
|
|
6779
|
+
var commandParser = getParserForCommand(command);
|
|
6738
6780
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
6739
6781
|
throw new ParseError(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(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
6740
6782
|
}
|
|
@@ -6783,9 +6825,9 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6783
6825
|
description_1 = undefined;
|
|
6784
6826
|
}
|
|
6785
6827
|
var $templateJson = {
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6828
|
+
isTemplateTypeSet: false,
|
|
6829
|
+
isTemplate: true,
|
|
6830
|
+
templateType: undefined /* <- Note: [🍙] Putting here placeholder to keep `templateType` on top at final JSON */,
|
|
6789
6831
|
name: titleToName(section.title),
|
|
6790
6832
|
title: section.title,
|
|
6791
6833
|
description: description_1,
|
|
@@ -6807,15 +6849,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6807
6849
|
// Note: If block type is not set, set it to 'PROMPT_TEMPLATE'
|
|
6808
6850
|
if (commands.some(function (_a) {
|
|
6809
6851
|
var command = _a.command;
|
|
6810
|
-
return command.type === '
|
|
6852
|
+
return command.type === 'TEMPLATE';
|
|
6811
6853
|
}) === false) {
|
|
6812
|
-
|
|
6854
|
+
templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
|
|
6813
6855
|
}
|
|
6814
6856
|
var _loop_3 = function (listItem, command) {
|
|
6815
|
-
var commandParser =
|
|
6816
|
-
if (commandParser === undefined) {
|
|
6817
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found \uD83C\uDF4F\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6818
|
-
}
|
|
6857
|
+
var commandParser = getParserForCommand(command);
|
|
6819
6858
|
if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
|
|
6820
6859
|
throw new ParseError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the template of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
6821
6860
|
}
|
|
@@ -6830,16 +6869,13 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6830
6869
|
}
|
|
6831
6870
|
throw new ParseError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " failed to apply to the template\n\n The error:\n ").concat(block(error.message), "\n\n Current state of the template:\n ").concat(block(JSON.stringify($templateJson, null, 4)), "\n <- Maybe wrong order of commands?\n\n Raw command:\n - ").concat(listItem, "\n\n Usage of ").concat(command.type, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
6832
6871
|
}
|
|
6833
|
-
// TODO: !!!!!! Multiple problematic things in BLOCK command - blockCommandParser.$applyToTemplateJson
|
|
6834
6872
|
if (command.type === 'PARAMETER') {
|
|
6835
6873
|
defineParam(command);
|
|
6836
6874
|
// <- Note: [🍣]
|
|
6837
6875
|
}
|
|
6838
6876
|
};
|
|
6839
6877
|
try {
|
|
6840
|
-
// TODO
|
|
6841
|
-
// TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE BLOCK`
|
|
6842
|
-
// TODO [♓️] List commands and before apply order them
|
|
6878
|
+
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
6843
6879
|
for (var commands_1 = (e_3 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
6844
6880
|
var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
|
|
6845
6881
|
_loop_3(listItem, command);
|
|
@@ -6852,8 +6888,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6852
6888
|
}
|
|
6853
6889
|
finally { if (e_3) throw e_3.error; }
|
|
6854
6890
|
}
|
|
6855
|
-
// TODO: [🍧]
|
|
6856
|
-
if ($templateJson.
|
|
6891
|
+
// TODO: [🍧] Should be done in TEMPLATE command
|
|
6892
|
+
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
6857
6893
|
if (!language) {
|
|
6858
6894
|
throw new ParseError(spaceTrim(function (block) { return "\n You must specify the language of the script in the SCRIPT TEMPLATE\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
6859
6895
|
}
|
|
@@ -6865,15 +6901,13 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6865
6901
|
}
|
|
6866
6902
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
6867
6903
|
/*
|
|
6868
|
-
// TODO: [🍧]
|
|
6869
|
-
|
|
6870
|
-
// TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
|
|
6871
|
-
if ($templateJson.blockType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
6904
|
+
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
6905
|
+
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
6872
6906
|
throw new UnexpectedError(
|
|
6873
6907
|
spaceTrim(
|
|
6874
6908
|
(block) => `
|
|
6875
6909
|
Model requirements are defined for the block type ${
|
|
6876
|
-
$templateJson.
|
|
6910
|
+
$templateJson.templateType
|
|
6877
6911
|
} which is not a PROMPT TEMPLATE
|
|
6878
6912
|
|
|
6879
6913
|
This should be avoided by the \`modelCommandParser\`
|
|
@@ -6884,9 +6918,9 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6884
6918
|
);
|
|
6885
6919
|
}
|
|
6886
6920
|
*/
|
|
6887
|
-
if ($templateJson.
|
|
6888
|
-
delete $templateJson.
|
|
6889
|
-
delete $templateJson.
|
|
6921
|
+
if ($templateJson.isTemplate) {
|
|
6922
|
+
delete $templateJson.isTemplateTypeSet;
|
|
6923
|
+
delete $templateJson.isTemplate;
|
|
6890
6924
|
// TODO: [🍙] Maybe do reorder of `$templateJson` here
|
|
6891
6925
|
$pipelineJson.templates.push($templateJson);
|
|
6892
6926
|
}
|
|
@@ -6894,7 +6928,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6894
6928
|
try {
|
|
6895
6929
|
// =============================================================
|
|
6896
6930
|
// Note: 4️⃣ Process each template of the pipeline
|
|
6897
|
-
|
|
6931
|
+
for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
|
|
6898
6932
|
var section = pipelineSections_1_1.value;
|
|
6899
6933
|
_loop_2(section);
|
|
6900
6934
|
}
|
|
@@ -6967,7 +7001,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6967
7001
|
* - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
6968
7002
|
* - `preparePipeline` - just one step in the compilation process
|
|
6969
7003
|
*
|
|
6970
|
-
* Note: This function does not validate logic of the pipeline only the
|
|
7004
|
+
* Note: This function does not validate logic of the pipeline only the parsing
|
|
6971
7005
|
* Note: This function acts as compilation process
|
|
6972
7006
|
*
|
|
6973
7007
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
@@ -8326,7 +8360,6 @@ function addAutoGeneratedSection(content, options) {
|
|
|
8326
8360
|
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
8327
8361
|
}
|
|
8328
8362
|
/**
|
|
8329
|
-
* TODO: !!!!!! Somw way how to connect this with commands
|
|
8330
8363
|
* TODO: [🏛] This can be part of markdown builder
|
|
8331
8364
|
*/
|
|
8332
8365
|
|