@promptbook/core 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 +219 -186
- 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 +219 -186
- 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
|
@@ -10,7 +10,7 @@ import moment from 'moment';
|
|
|
10
10
|
/**
|
|
11
11
|
* The version of the Promptbook library
|
|
12
12
|
*/
|
|
13
|
-
var PROMPTBOOK_VERSION = '0.68.0-
|
|
13
|
+
var PROMPTBOOK_VERSION = '0.68.0-4';
|
|
14
14
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
15
15
|
|
|
16
16
|
/*! *****************************************************************************
|
|
@@ -266,7 +266,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
266
266
|
/* Note: Not using:> name, */
|
|
267
267
|
title_1 = template.title, description_1 = template.description,
|
|
268
268
|
/* Note: dependentParameterNames, */
|
|
269
|
-
jokers = template.jokerParameterNames,
|
|
269
|
+
jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
|
|
270
270
|
pipelineString += '\n\n';
|
|
271
271
|
pipelineString += "## ".concat(title_1);
|
|
272
272
|
if (description_1) {
|
|
@@ -276,7 +276,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
276
276
|
// TODO:> const commands: Array<Command>
|
|
277
277
|
var commands_1 = [];
|
|
278
278
|
var contentLanguage = 'text';
|
|
279
|
-
if (
|
|
279
|
+
if (templateType === 'PROMPT_TEMPLATE') {
|
|
280
280
|
var modelRequirements = template.modelRequirements;
|
|
281
281
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
282
282
|
commands_1.push("EXECUTE PROMPT TEMPLATE");
|
|
@@ -287,12 +287,12 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
287
287
|
commands_1.push("MODEL NAME `".concat(modelName, "`"));
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
else if (
|
|
290
|
+
else if (templateType === 'SIMPLE_TEMPLATE') {
|
|
291
291
|
commands_1.push("SIMPLE TEMPLATE");
|
|
292
292
|
// Note: Nothing special here
|
|
293
293
|
}
|
|
294
|
-
else if (
|
|
295
|
-
commands_1.push("
|
|
294
|
+
else if (templateType === 'SCRIPT_TEMPLATE') {
|
|
295
|
+
commands_1.push("SCRIPT TEMPLATE");
|
|
296
296
|
if (template.contentLanguage) {
|
|
297
297
|
contentLanguage = template.contentLanguage;
|
|
298
298
|
}
|
|
@@ -300,8 +300,8 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
300
300
|
contentLanguage = '';
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
else if (
|
|
304
|
-
commands_1.push("DIALOG
|
|
303
|
+
else if (templateType === 'DIALOG_TEMPLATE') {
|
|
304
|
+
commands_1.push("DIALOG TEMPLATE");
|
|
305
305
|
// Note: Nothing special here
|
|
306
306
|
} // <- }else if([🅱]
|
|
307
307
|
if (jokers) {
|
|
@@ -400,7 +400,7 @@ function templateParameterJsonToString(templateParameterJson) {
|
|
|
400
400
|
return parameterString;
|
|
401
401
|
}
|
|
402
402
|
/**
|
|
403
|
-
* TODO:
|
|
403
|
+
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `templateParameterJsonToString` , use `stringifyCommand`
|
|
404
404
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
405
405
|
* TODO: [🏛] Maybe make some markdown builder
|
|
406
406
|
* TODO: [🏛] Escape all
|
|
@@ -776,7 +776,7 @@ var ParseError = /** @class */ (function (_super) {
|
|
|
776
776
|
*/
|
|
777
777
|
|
|
778
778
|
/**
|
|
779
|
-
* This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
|
|
779
|
+
* This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
|
|
780
780
|
*
|
|
781
781
|
* @public exported from `@promptbook/core`
|
|
782
782
|
*/
|
|
@@ -1358,7 +1358,7 @@ var SimplePipelineCollection = /** @class */ (function () {
|
|
|
1358
1358
|
* Creates PipelineCollection from array of PipelineJson or PipelineString
|
|
1359
1359
|
*
|
|
1360
1360
|
* Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
|
|
1361
|
-
* Note:
|
|
1361
|
+
* Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
|
|
1362
1362
|
*
|
|
1363
1363
|
* @param promptbookSources
|
|
1364
1364
|
* @returns PipelineCollection
|
|
@@ -1575,12 +1575,12 @@ function createSubcollection(collection, predicate) {
|
|
|
1575
1575
|
}
|
|
1576
1576
|
|
|
1577
1577
|
/**
|
|
1578
|
-
*
|
|
1578
|
+
* Template type describes the way how the template is templated
|
|
1579
1579
|
*
|
|
1580
|
-
* @see https://github.com/webgptorg/promptbook#
|
|
1580
|
+
* @see https://github.com/webgptorg/promptbook#template-type
|
|
1581
1581
|
* @public exported from `@promptbook/core`
|
|
1582
1582
|
*/
|
|
1583
|
-
var
|
|
1583
|
+
var TemplateTypes = [
|
|
1584
1584
|
'PROMPT_TEMPLATE',
|
|
1585
1585
|
'SIMPLE_TEMPLATE',
|
|
1586
1586
|
'SCRIPT_TEMPLATE',
|
|
@@ -1788,7 +1788,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1788
1788
|
});
|
|
1789
1789
|
}
|
|
1790
1790
|
|
|
1791
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-
|
|
1791
|
+
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"}];
|
|
1792
1792
|
|
|
1793
1793
|
var defaultDiacriticsRemovalMap = [
|
|
1794
1794
|
{
|
|
@@ -2375,7 +2375,7 @@ function extractVariables(script) {
|
|
|
2375
2375
|
*/
|
|
2376
2376
|
function extractParameterNamesFromTemplate(template) {
|
|
2377
2377
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
2378
|
-
var title = template.title, description = template.description,
|
|
2378
|
+
var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
|
|
2379
2379
|
var parameterNames = new Set();
|
|
2380
2380
|
try {
|
|
2381
2381
|
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()) {
|
|
@@ -2390,7 +2390,7 @@ function extractParameterNamesFromTemplate(template) {
|
|
|
2390
2390
|
}
|
|
2391
2391
|
finally { if (e_1) throw e_1.error; }
|
|
2392
2392
|
}
|
|
2393
|
-
if (
|
|
2393
|
+
if (templateType === 'SCRIPT_TEMPLATE') {
|
|
2394
2394
|
try {
|
|
2395
2395
|
for (var _f = __values(extractVariables(content)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
2396
2396
|
var parameterName = _g.value;
|
|
@@ -3392,7 +3392,7 @@ function createPipelineExecutor(options) {
|
|
|
3392
3392
|
title: title,
|
|
3393
3393
|
isStarted: false,
|
|
3394
3394
|
isDone: false,
|
|
3395
|
-
|
|
3395
|
+
templateType: currentTemplate.templateType,
|
|
3396
3396
|
parameterName: currentTemplate.resultingParameterName,
|
|
3397
3397
|
parameterValue: null,
|
|
3398
3398
|
// <- [3]
|
|
@@ -3457,7 +3457,7 @@ function createPipelineExecutor(options) {
|
|
|
3457
3457
|
result = null;
|
|
3458
3458
|
resultString = null;
|
|
3459
3459
|
expectError = null;
|
|
3460
|
-
maxAttempts = currentTemplate.
|
|
3460
|
+
maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
|
|
3461
3461
|
jokerParameterNames = currentTemplate.jokerParameterNames || [];
|
|
3462
3462
|
preparedContent = (currentTemplate.preparedContent || '{content}')
|
|
3463
3463
|
.split('{content}')
|
|
@@ -3489,7 +3489,7 @@ function createPipelineExecutor(options) {
|
|
|
3489
3489
|
case 1:
|
|
3490
3490
|
_v.trys.push([1, 44, 45, 46]);
|
|
3491
3491
|
if (!!isJokerAttempt) return [3 /*break*/, 26];
|
|
3492
|
-
_j = currentTemplate.
|
|
3492
|
+
_j = currentTemplate.templateType;
|
|
3493
3493
|
switch (_j) {
|
|
3494
3494
|
case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
|
|
3495
3495
|
case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
|
|
@@ -3623,10 +3623,10 @@ function createPipelineExecutor(options) {
|
|
|
3623
3623
|
priority: priority,
|
|
3624
3624
|
}))];
|
|
3625
3625
|
case 24:
|
|
3626
|
-
// TODO: [🌹] When making next attempt for `DIALOG
|
|
3626
|
+
// TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
|
|
3627
3627
|
resultString = _v.sent();
|
|
3628
3628
|
return [3 /*break*/, 26];
|
|
3629
|
-
case 25: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(currentTemplate.
|
|
3629
|
+
case 25: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(currentTemplate.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3630
3630
|
case 26:
|
|
3631
3631
|
if (!(!isJokerAttempt && currentTemplate.postprocessingFunctionNames)) return [3 /*break*/, 43];
|
|
3632
3632
|
_v.label = 27;
|
|
@@ -3741,12 +3741,12 @@ function createPipelineExecutor(options) {
|
|
|
3741
3741
|
return [3 /*break*/, 46];
|
|
3742
3742
|
case 45:
|
|
3743
3743
|
if (!isJokerAttempt &&
|
|
3744
|
-
currentTemplate.
|
|
3744
|
+
currentTemplate.templateType === 'PROMPT_TEMPLATE' &&
|
|
3745
3745
|
prompt
|
|
3746
3746
|
// <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
|
|
3747
3747
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
3748
3748
|
) {
|
|
3749
|
-
// TODO: [🧠] Maybe put other
|
|
3749
|
+
// TODO: [🧠] Maybe put other templateTypes into report
|
|
3750
3750
|
executionReport.promptExecutions.push({
|
|
3751
3751
|
prompt: __assign({}, prompt),
|
|
3752
3752
|
result: result || undefined,
|
|
@@ -3797,7 +3797,7 @@ function createPipelineExecutor(options) {
|
|
|
3797
3797
|
title: title,
|
|
3798
3798
|
isStarted: true,
|
|
3799
3799
|
isDone: true,
|
|
3800
|
-
|
|
3800
|
+
templateType: currentTemplate.templateType,
|
|
3801
3801
|
parameterName: currentTemplate.resultingParameterName,
|
|
3802
3802
|
parameterValue: resultString,
|
|
3803
3803
|
// <- [3]
|
|
@@ -4765,7 +4765,7 @@ var knowledgeCommandParser = {
|
|
|
4765
4765
|
*/
|
|
4766
4766
|
stringify: function (command) {
|
|
4767
4767
|
keepUnused(command);
|
|
4768
|
-
return "
|
|
4768
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
4769
4769
|
},
|
|
4770
4770
|
/**
|
|
4771
4771
|
* Reads the KNOWLEDGE command from the `PipelineJson`
|
|
@@ -4774,114 +4774,122 @@ var knowledgeCommandParser = {
|
|
|
4774
4774
|
*/
|
|
4775
4775
|
takeFromPipelineJson: function (pipelineJson) {
|
|
4776
4776
|
keepUnused(pipelineJson);
|
|
4777
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
4777
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
4778
4778
|
},
|
|
4779
4779
|
};
|
|
4780
|
+
/**
|
|
4781
|
+
* Note: [⛱] There are two types of KNOWLEDGE commands *...(read more in [⛱])*
|
|
4782
|
+
*/
|
|
4780
4783
|
|
|
4781
4784
|
/**
|
|
4782
|
-
* Parses the
|
|
4785
|
+
* Parses the template command
|
|
4783
4786
|
*
|
|
4784
|
-
* @see ./
|
|
4787
|
+
* @see ./TEMPLATE-README.md for more details
|
|
4785
4788
|
* @private within the commands folder
|
|
4786
4789
|
*/
|
|
4787
|
-
var
|
|
4790
|
+
var templateCommandParser = {
|
|
4788
4791
|
/**
|
|
4789
4792
|
* Name of the command
|
|
4790
4793
|
*/
|
|
4791
|
-
name: '
|
|
4794
|
+
name: 'TEMPLATE',
|
|
4792
4795
|
/**
|
|
4793
|
-
* Aliases for the
|
|
4796
|
+
* Aliases for the TEMPLATE command
|
|
4794
4797
|
*/
|
|
4795
4798
|
aliasNames: [
|
|
4796
|
-
'
|
|
4797
|
-
'
|
|
4798
|
-
'
|
|
4799
|
-
'
|
|
4799
|
+
'PROMPT',
|
|
4800
|
+
'SIMPLE',
|
|
4801
|
+
'SCRIPT',
|
|
4802
|
+
'DIALOG',
|
|
4800
4803
|
'SAMPLE',
|
|
4801
4804
|
'EXAMPLE',
|
|
4802
4805
|
'KNOWLEDGE',
|
|
4803
4806
|
'INSTRUMENT',
|
|
4804
|
-
'ACTION',
|
|
4805
|
-
// <- [🅱]
|
|
4807
|
+
'ACTION', // <- Note: [⛱]
|
|
4806
4808
|
],
|
|
4807
4809
|
/**
|
|
4808
|
-
* Aliases for the
|
|
4810
|
+
* Aliases for the TEMPLATE command
|
|
4809
4811
|
*/
|
|
4810
|
-
deprecatedNames: ['EXECUTE'],
|
|
4812
|
+
deprecatedNames: ['BLOCK', 'EXECUTE'],
|
|
4811
4813
|
/**
|
|
4812
4814
|
* BOILERPLATE command can be used in:
|
|
4813
4815
|
*/
|
|
4814
4816
|
isUsedInPipelineHead: false,
|
|
4815
4817
|
isUsedInPipelineTemplate: true,
|
|
4816
4818
|
/**
|
|
4817
|
-
* Description of the
|
|
4819
|
+
* Description of the TEMPLATE command
|
|
4818
4820
|
*/
|
|
4819
|
-
description: "What should the code
|
|
4821
|
+
description: "What should the code template template do",
|
|
4820
4822
|
/**
|
|
4821
4823
|
* Link to discussion
|
|
4822
4824
|
*/
|
|
4823
4825
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/64',
|
|
4824
4826
|
/**
|
|
4825
|
-
* Example usages of the
|
|
4827
|
+
* Example usages of the TEMPLATE command
|
|
4826
4828
|
*/
|
|
4827
4829
|
examples: [
|
|
4828
|
-
//
|
|
4829
|
-
'PROMPT
|
|
4830
|
-
'SIMPLE
|
|
4831
|
-
'SCRIPT
|
|
4832
|
-
'DIALOG
|
|
4830
|
+
// Short form:
|
|
4831
|
+
'PROMPT',
|
|
4832
|
+
'SIMPLE',
|
|
4833
|
+
'SCRIPT',
|
|
4834
|
+
'DIALOG',
|
|
4833
4835
|
// <- [🅱]
|
|
4834
|
-
|
|
4835
|
-
'
|
|
4836
|
-
'
|
|
4837
|
-
'
|
|
4838
|
-
|
|
4836
|
+
'SAMPLE',
|
|
4837
|
+
'KNOWLEDGE',
|
|
4838
|
+
'INSTRUMENT',
|
|
4839
|
+
'ACTION',
|
|
4840
|
+
// -----------------
|
|
4841
|
+
// Recommended (reversed) form:
|
|
4842
|
+
'PROMPT TEMPLATE',
|
|
4843
|
+
'SIMPLE TEMPLATE',
|
|
4844
|
+
'SCRIPT TEMPLATE',
|
|
4845
|
+
'DIALOG TEMPLATE',
|
|
4839
4846
|
// <- [🅱]
|
|
4840
|
-
|
|
4841
|
-
'
|
|
4842
|
-
'
|
|
4843
|
-
'
|
|
4844
|
-
|
|
4847
|
+
'SAMPLE TEMPLATE',
|
|
4848
|
+
'KNOWLEDGE TEMPLATE',
|
|
4849
|
+
'INSTRUMENT TEMPLATE',
|
|
4850
|
+
'ACTION TEMPLATE',
|
|
4851
|
+
// -----------------
|
|
4852
|
+
// Standard form:
|
|
4853
|
+
'TEMPLATE PROMPT',
|
|
4854
|
+
'TEMPLATE SIMPLE',
|
|
4855
|
+
'TEMPLATE SCRIPT',
|
|
4856
|
+
'TEMPLATE DIALOG',
|
|
4845
4857
|
// <- [🅱]
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
'
|
|
4850
|
-
// 'Instrument', // <- Note: [⛱]
|
|
4851
|
-
'Action BLOCK',
|
|
4852
|
-
// 'Action', // <- Note: [⛱]
|
|
4853
|
-
//---
|
|
4854
|
-
/* <- TODO: [🧠] Maybe dynamic */
|
|
4858
|
+
'SAMPLE TEMPLATE',
|
|
4859
|
+
'KNOWLEDGE TEMPLATE',
|
|
4860
|
+
'INSTRUMENT TEMPLATE',
|
|
4861
|
+
'ACTION TEMPLATE',
|
|
4855
4862
|
],
|
|
4856
4863
|
// TODO: [♓️] order: -10 /* <- Note: Putting before other commands */
|
|
4857
4864
|
/**
|
|
4858
|
-
* Parses the
|
|
4865
|
+
* Parses the TEMPLATE command
|
|
4859
4866
|
*/
|
|
4860
4867
|
parse: function (input) {
|
|
4861
4868
|
var normalized = input.normalized;
|
|
4862
4869
|
normalized = normalized.split('EXAMPLE').join('SAMPLE');
|
|
4863
|
-
var
|
|
4864
|
-
|
|
4865
|
-
|
|
4870
|
+
var templateTypes = TemplateTypes.filter(function (templateType) {
|
|
4871
|
+
return normalized.includes(templateType.split('_TEMPLATE').join(''));
|
|
4872
|
+
});
|
|
4873
|
+
if (templateTypes.length !== 1) {
|
|
4874
|
+
throw new ParseError(spaceTrim(function (template) { return "\n Unknown template type in TEMPLATE command\n\n Supported template types are:\n ".concat(template(TemplateTypes.join(', ')), "\n "); }));
|
|
4866
4875
|
}
|
|
4867
|
-
var
|
|
4876
|
+
var templateType = templateTypes[0];
|
|
4868
4877
|
return {
|
|
4869
|
-
type: '
|
|
4870
|
-
|
|
4878
|
+
type: 'TEMPLATE',
|
|
4879
|
+
templateType: templateType,
|
|
4871
4880
|
};
|
|
4872
4881
|
},
|
|
4873
4882
|
/**
|
|
4874
|
-
* Apply the
|
|
4883
|
+
* Apply the TEMPLATE command to the `pipelineJson`
|
|
4875
4884
|
*
|
|
4876
4885
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
4877
4886
|
*/
|
|
4878
4887
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
throw new ParseError(spaceTrim("\n Block type is already defined in the template.\n It can be defined only once.\n "));
|
|
4888
|
+
if ($templateJson.isTemplateTypeSet === true) {
|
|
4889
|
+
throw new ParseError(spaceTrim("\n Template type is already defined in the template.\n It can be defined only once.\n "));
|
|
4882
4890
|
}
|
|
4883
|
-
$templateJson.
|
|
4884
|
-
// TODO:
|
|
4891
|
+
$templateJson.isTemplateTypeSet = true;
|
|
4892
|
+
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
4885
4893
|
var expectResultingParameterName = function () {
|
|
4886
4894
|
if ($templateJson.resultingParameterName) {
|
|
4887
4895
|
return;
|
|
@@ -4891,7 +4899,7 @@ var blockCommandParser = {
|
|
|
4891
4899
|
if ($templateJson.content === undefined) {
|
|
4892
4900
|
throw new UnexpectedError("Content is missing in the templateJson - probbably commands are applied in wrong order");
|
|
4893
4901
|
}
|
|
4894
|
-
if (command.
|
|
4902
|
+
if (command.templateType === 'SAMPLE') {
|
|
4895
4903
|
expectResultingParameterName();
|
|
4896
4904
|
var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $templateJson.resultingParameterName; });
|
|
4897
4905
|
if (parameter === undefined) {
|
|
@@ -4899,66 +4907,61 @@ var blockCommandParser = {
|
|
|
4899
4907
|
}
|
|
4900
4908
|
parameter.sampleValues = parameter.sampleValues || [];
|
|
4901
4909
|
parameter.sampleValues.push($templateJson.content);
|
|
4902
|
-
|
|
4903
|
-
// continue templates;
|
|
4904
|
-
$templateJson.isTemplateBlock = false;
|
|
4910
|
+
$templateJson.isTemplate = false;
|
|
4905
4911
|
return;
|
|
4906
4912
|
}
|
|
4907
|
-
if (command.
|
|
4913
|
+
if (command.templateType === 'KNOWLEDGE') {
|
|
4908
4914
|
knowledgeCommandParser.$applyToPipelineJson({
|
|
4909
4915
|
type: 'KNOWLEDGE',
|
|
4910
4916
|
sourceContent: $templateJson.content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
4911
4917
|
}, $pipelineJson);
|
|
4912
|
-
|
|
4913
|
-
// continue templates;
|
|
4914
|
-
$templateJson.isTemplateBlock = false;
|
|
4918
|
+
$templateJson.isTemplate = false;
|
|
4915
4919
|
return;
|
|
4916
4920
|
}
|
|
4917
|
-
if (command.
|
|
4921
|
+
if (command.templateType === 'ACTION') {
|
|
4918
4922
|
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
4919
|
-
|
|
4920
|
-
// continue templates;
|
|
4921
|
-
$templateJson.isTemplateBlock = false;
|
|
4923
|
+
$templateJson.isTemplate = false;
|
|
4922
4924
|
return;
|
|
4923
4925
|
}
|
|
4924
|
-
if (command.
|
|
4926
|
+
if (command.templateType === 'INSTRUMENT') {
|
|
4925
4927
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
4926
|
-
|
|
4927
|
-
// continue templates;
|
|
4928
|
-
$templateJson.isTemplateBlock = false;
|
|
4928
|
+
$templateJson.isTemplate = false;
|
|
4929
4929
|
return;
|
|
4930
4930
|
}
|
|
4931
4931
|
expectResultingParameterName();
|
|
4932
|
-
$templateJson.
|
|
4933
|
-
|
|
4934
|
-
TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
|
|
4935
|
-
if (command.blockType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
|
|
4936
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
4937
|
-
}
|
|
4938
|
-
*/
|
|
4939
|
-
// !!!!!!
|
|
4940
|
-
// isBlockTypeSet = true; //<- Note: [2]
|
|
4941
|
-
$templateJson.isTemplateBlock = true;
|
|
4932
|
+
$templateJson.templateType = command.templateType;
|
|
4933
|
+
$templateJson.isTemplate = true;
|
|
4942
4934
|
},
|
|
4943
4935
|
/**
|
|
4944
|
-
* Converts the
|
|
4936
|
+
* Converts the TEMPLATE command back to string
|
|
4945
4937
|
*
|
|
4946
4938
|
* Note: This is used in `pipelineJsonToString` utility
|
|
4947
4939
|
*/
|
|
4948
4940
|
stringify: function (command) {
|
|
4949
4941
|
keepUnused(command);
|
|
4950
|
-
return "
|
|
4942
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
4951
4943
|
},
|
|
4952
4944
|
/**
|
|
4953
|
-
* Reads the
|
|
4945
|
+
* Reads the TEMPLATE command from the `TemplateJson`
|
|
4954
4946
|
*
|
|
4955
4947
|
* Note: This is used in `pipelineJsonToString` utility
|
|
4956
4948
|
*/
|
|
4957
4949
|
takeFromTemplateJson: function ($templateJson) {
|
|
4958
4950
|
keepUnused($templateJson);
|
|
4959
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
4951
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
4960
4952
|
},
|
|
4961
4953
|
};
|
|
4954
|
+
/**
|
|
4955
|
+
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
|
|
4956
|
+
* 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
|
|
4957
|
+
* - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4958
|
+
* 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
|
|
4959
|
+
* - KNOWLEDGE TEMPLATE
|
|
4960
|
+
*
|
|
4961
|
+
* ```
|
|
4962
|
+
* Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4963
|
+
* ```
|
|
4964
|
+
*/
|
|
4962
4965
|
|
|
4963
4966
|
/**
|
|
4964
4967
|
* Units of text measurement
|
|
@@ -5177,7 +5180,7 @@ var expectCommandParser = {
|
|
|
5177
5180
|
*/
|
|
5178
5181
|
stringify: function (command) {
|
|
5179
5182
|
keepUnused(command);
|
|
5180
|
-
return "
|
|
5183
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5181
5184
|
},
|
|
5182
5185
|
/**
|
|
5183
5186
|
* Reads the FORMAT command from the `TemplateJson`
|
|
@@ -5186,7 +5189,7 @@ var expectCommandParser = {
|
|
|
5186
5189
|
*/
|
|
5187
5190
|
takeFromTemplateJson: function ($templateJson) {
|
|
5188
5191
|
keepUnused($templateJson);
|
|
5189
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5192
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5190
5193
|
},
|
|
5191
5194
|
};
|
|
5192
5195
|
|
|
@@ -5271,7 +5274,7 @@ var foreachCommandParser = {
|
|
|
5271
5274
|
},
|
|
5272
5275
|
};
|
|
5273
5276
|
/**
|
|
5274
|
-
* TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong
|
|
5277
|
+
* TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
|
|
5275
5278
|
*/
|
|
5276
5279
|
|
|
5277
5280
|
/**
|
|
@@ -5335,7 +5338,7 @@ var formatCommandParser = {
|
|
|
5335
5338
|
*/
|
|
5336
5339
|
stringify: function (command) {
|
|
5337
5340
|
keepUnused(command);
|
|
5338
|
-
return "
|
|
5341
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5339
5342
|
},
|
|
5340
5343
|
/**
|
|
5341
5344
|
* Reads the FORMAT command from the `TemplateJson`
|
|
@@ -5344,7 +5347,7 @@ var formatCommandParser = {
|
|
|
5344
5347
|
*/
|
|
5345
5348
|
takeFromTemplateJson: function ($templateJson) {
|
|
5346
5349
|
keepUnused($templateJson);
|
|
5347
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5350
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5348
5351
|
},
|
|
5349
5352
|
};
|
|
5350
5353
|
|
|
@@ -5407,7 +5410,7 @@ var jokerCommandParser = {
|
|
|
5407
5410
|
*/
|
|
5408
5411
|
stringify: function (command) {
|
|
5409
5412
|
keepUnused(command);
|
|
5410
|
-
return "
|
|
5413
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5411
5414
|
},
|
|
5412
5415
|
/**
|
|
5413
5416
|
* Reads the JOKER command from the `TemplateJson`
|
|
@@ -5416,7 +5419,7 @@ var jokerCommandParser = {
|
|
|
5416
5419
|
*/
|
|
5417
5420
|
takeFromTemplateJson: function ($templateJson) {
|
|
5418
5421
|
keepUnused($templateJson);
|
|
5419
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5422
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5420
5423
|
},
|
|
5421
5424
|
};
|
|
5422
5425
|
|
|
@@ -5496,7 +5499,7 @@ var modelCommandParser = {
|
|
|
5496
5499
|
};
|
|
5497
5500
|
}
|
|
5498
5501
|
else {
|
|
5499
|
-
throw new ParseError(spaceTrim(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
|
|
5502
|
+
throw new ParseError(spaceTrim(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 "); }));
|
|
5500
5503
|
}
|
|
5501
5504
|
},
|
|
5502
5505
|
/**
|
|
@@ -5505,8 +5508,16 @@ var modelCommandParser = {
|
|
|
5505
5508
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
5506
5509
|
*/
|
|
5507
5510
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5508
|
-
// TODO: !!!!!! Error on redefine
|
|
5509
5511
|
$pipelineJson.defaultModelRequirements = $pipelineJson.defaultModelRequirements || {};
|
|
5512
|
+
// TODO: [🚜] DRY
|
|
5513
|
+
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
5514
|
+
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
5515
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
5516
|
+
}
|
|
5517
|
+
else {
|
|
5518
|
+
throw new ParseError(spaceTrim("\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 ")));
|
|
5519
|
+
}
|
|
5520
|
+
}
|
|
5510
5521
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
5511
5522
|
},
|
|
5512
5523
|
/**
|
|
@@ -5514,13 +5525,23 @@ var modelCommandParser = {
|
|
|
5514
5525
|
*
|
|
5515
5526
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5516
5527
|
*/
|
|
5517
|
-
$applyToTemplateJson: function (command, $templateJson) {
|
|
5518
|
-
if ($templateJson.
|
|
5528
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5529
|
+
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5519
5530
|
throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
|
|
5520
5531
|
}
|
|
5521
|
-
// TODO: !!!!!! Error on redefine
|
|
5522
|
-
// TODO: Warn if setting same as default in `$pipelineJson`
|
|
5523
5532
|
$templateJson.modelRequirements = $templateJson.modelRequirements || {};
|
|
5533
|
+
// TODO: [🚜] DRY
|
|
5534
|
+
if ($templateJson.modelRequirements[command.key] !== undefined) {
|
|
5535
|
+
if ($templateJson.modelRequirements[command.key] === command.value) {
|
|
5536
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the template \"").concat($templateJson.title || $templateJson.name, "\""));
|
|
5537
|
+
}
|
|
5538
|
+
else {
|
|
5539
|
+
throw new ParseError(spaceTrim("\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 ")));
|
|
5540
|
+
}
|
|
5541
|
+
}
|
|
5542
|
+
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
5543
|
+
console.log(spaceTrim("\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 ")));
|
|
5544
|
+
}
|
|
5524
5545
|
$templateJson.modelRequirements[command.key] = command.value;
|
|
5525
5546
|
},
|
|
5526
5547
|
/**
|
|
@@ -5530,7 +5551,7 @@ var modelCommandParser = {
|
|
|
5530
5551
|
*/
|
|
5531
5552
|
stringify: function (command) {
|
|
5532
5553
|
keepUnused(command);
|
|
5533
|
-
return "
|
|
5554
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5534
5555
|
},
|
|
5535
5556
|
/**
|
|
5536
5557
|
* Reads the MODEL command from the `PipelineJson`
|
|
@@ -5539,7 +5560,7 @@ var modelCommandParser = {
|
|
|
5539
5560
|
*/
|
|
5540
5561
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5541
5562
|
keepUnused(pipelineJson);
|
|
5542
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5563
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5543
5564
|
},
|
|
5544
5565
|
/**
|
|
5545
5566
|
* Reads the MODEL command from the `TemplateJson`
|
|
@@ -5548,7 +5569,7 @@ var modelCommandParser = {
|
|
|
5548
5569
|
*/
|
|
5549
5570
|
takeFromTemplateJson: function ($templateJson) {
|
|
5550
5571
|
keepUnused($templateJson);
|
|
5551
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5572
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5552
5573
|
},
|
|
5553
5574
|
};
|
|
5554
5575
|
|
|
@@ -5639,7 +5660,7 @@ var parameterCommandParser = {
|
|
|
5639
5660
|
*/
|
|
5640
5661
|
stringify: function (command) {
|
|
5641
5662
|
keepUnused(command);
|
|
5642
|
-
return "
|
|
5663
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5643
5664
|
},
|
|
5644
5665
|
/**
|
|
5645
5666
|
* Reads the PARAMETER command from the `PipelineJson`
|
|
@@ -5648,7 +5669,7 @@ var parameterCommandParser = {
|
|
|
5648
5669
|
*/
|
|
5649
5670
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5650
5671
|
keepUnused(pipelineJson);
|
|
5651
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5672
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5652
5673
|
},
|
|
5653
5674
|
/**
|
|
5654
5675
|
* Reads the PARAMETER command from the `TemplateJson`
|
|
@@ -5657,7 +5678,7 @@ var parameterCommandParser = {
|
|
|
5657
5678
|
*/
|
|
5658
5679
|
takeFromTemplateJson: function ($templateJson) {
|
|
5659
5680
|
keepUnused($templateJson);
|
|
5660
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5681
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5661
5682
|
},
|
|
5662
5683
|
};
|
|
5663
5684
|
|
|
@@ -5729,7 +5750,7 @@ var personaCommandParser = {
|
|
|
5729
5750
|
*/
|
|
5730
5751
|
stringify: function (command) {
|
|
5731
5752
|
keepUnused(command);
|
|
5732
|
-
return "
|
|
5753
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5733
5754
|
},
|
|
5734
5755
|
/**
|
|
5735
5756
|
* Reads the PERSONA command from the `PipelineJson`
|
|
@@ -5738,7 +5759,7 @@ var personaCommandParser = {
|
|
|
5738
5759
|
*/
|
|
5739
5760
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5740
5761
|
keepUnused(pipelineJson);
|
|
5741
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5762
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5742
5763
|
},
|
|
5743
5764
|
/**
|
|
5744
5765
|
* Reads the PERSONA command from the `TemplateJson`
|
|
@@ -5747,7 +5768,7 @@ var personaCommandParser = {
|
|
|
5747
5768
|
*/
|
|
5748
5769
|
takeFromTemplateJson: function ($templateJson) {
|
|
5749
5770
|
keepUnused($templateJson);
|
|
5750
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5771
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5751
5772
|
},
|
|
5752
5773
|
};
|
|
5753
5774
|
/**
|
|
@@ -5758,7 +5779,7 @@ var personaCommandParser = {
|
|
|
5758
5779
|
function $applyToTemplateJson(command, $templateJson, $pipelineJson) {
|
|
5759
5780
|
var personaName = command.personaName, personaDescription = command.personaDescription;
|
|
5760
5781
|
if ($templateJson !== null) {
|
|
5761
|
-
if ($templateJson.
|
|
5782
|
+
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5762
5783
|
throw new ParseError("PERSONA command can be used only in PROMPT_TEMPLATE block");
|
|
5763
5784
|
}
|
|
5764
5785
|
$templateJson.personaName = personaName;
|
|
@@ -5866,7 +5887,7 @@ var postprocessCommandParser = {
|
|
|
5866
5887
|
*/
|
|
5867
5888
|
stringify: function (command) {
|
|
5868
5889
|
keepUnused(command);
|
|
5869
|
-
return "
|
|
5890
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5870
5891
|
},
|
|
5871
5892
|
/**
|
|
5872
5893
|
* Reads the POSTPROCESS command from the `TemplateJson`
|
|
@@ -5875,7 +5896,7 @@ var postprocessCommandParser = {
|
|
|
5875
5896
|
*/
|
|
5876
5897
|
takeFromTemplateJson: function ($templateJson) {
|
|
5877
5898
|
keepUnused($templateJson);
|
|
5878
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5899
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5879
5900
|
},
|
|
5880
5901
|
};
|
|
5881
5902
|
|
|
@@ -5943,7 +5964,7 @@ var promptbookVersionCommandParser = {
|
|
|
5943
5964
|
*/
|
|
5944
5965
|
stringify: function (command) {
|
|
5945
5966
|
keepUnused(command);
|
|
5946
|
-
return "
|
|
5967
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5947
5968
|
},
|
|
5948
5969
|
/**
|
|
5949
5970
|
* Reads the PROMPTBOOK_VERSION command from the `PipelineJson`
|
|
@@ -5952,7 +5973,7 @@ var promptbookVersionCommandParser = {
|
|
|
5952
5973
|
*/
|
|
5953
5974
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5954
5975
|
keepUnused(pipelineJson);
|
|
5955
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
5976
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5956
5977
|
},
|
|
5957
5978
|
};
|
|
5958
5979
|
|
|
@@ -6002,7 +6023,7 @@ var urlCommandParser = {
|
|
|
6002
6023
|
if (pipelineUrl === undefined) {
|
|
6003
6024
|
throw new ParseError("URL is required");
|
|
6004
6025
|
}
|
|
6005
|
-
// TODO: [🧠][🚲] This should be maybe tested as logic not
|
|
6026
|
+
// TODO: [🧠][🚲] This should be maybe tested as logic not parse
|
|
6006
6027
|
if (!isValidPipelineUrl(pipelineUrl)) {
|
|
6007
6028
|
throw new ParseError("Invalid pipeline URL \"".concat(pipelineUrl, "\""));
|
|
6008
6029
|
}
|
|
@@ -6046,7 +6067,7 @@ var urlCommandParser = {
|
|
|
6046
6067
|
*/
|
|
6047
6068
|
stringify: function (command) {
|
|
6048
6069
|
keepUnused(command);
|
|
6049
|
-
return "
|
|
6070
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
6050
6071
|
},
|
|
6051
6072
|
/**
|
|
6052
6073
|
* Reads the URL command from the `PipelineJson`
|
|
@@ -6055,7 +6076,7 @@ var urlCommandParser = {
|
|
|
6055
6076
|
*/
|
|
6056
6077
|
takeFromPipelineJson: function (pipelineJson) {
|
|
6057
6078
|
keepUnused(pipelineJson);
|
|
6058
|
-
throw new NotYetImplementedError("Not implemented yet
|
|
6079
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6059
6080
|
},
|
|
6060
6081
|
};
|
|
6061
6082
|
|
|
@@ -6104,7 +6125,7 @@ var actionCommandParser = {
|
|
|
6104
6125
|
*/
|
|
6105
6126
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6106
6127
|
keepUnused(command, $pipelineJson);
|
|
6107
|
-
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
6128
|
+
console.error(new NotYetImplementedError('[🛠] Actions are not implemented yet'));
|
|
6108
6129
|
},
|
|
6109
6130
|
/**
|
|
6110
6131
|
* Converts the ACTION command back to string
|
|
@@ -6113,7 +6134,7 @@ var actionCommandParser = {
|
|
|
6113
6134
|
*/
|
|
6114
6135
|
stringify: function (command) {
|
|
6115
6136
|
keepUnused(command);
|
|
6116
|
-
|
|
6137
|
+
throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
|
|
6117
6138
|
},
|
|
6118
6139
|
/**
|
|
6119
6140
|
* Reads the ACTION command from the `PipelineJson`
|
|
@@ -6122,9 +6143,12 @@ var actionCommandParser = {
|
|
|
6122
6143
|
*/
|
|
6123
6144
|
takeFromPipelineJson: function (pipelineJson) {
|
|
6124
6145
|
keepUnused(pipelineJson);
|
|
6125
|
-
throw new NotYetImplementedError(
|
|
6146
|
+
throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
|
|
6126
6147
|
},
|
|
6127
6148
|
};
|
|
6149
|
+
/**
|
|
6150
|
+
* Note: [⛱] There are two types of ACTION commands *...(read more in [⛱])*
|
|
6151
|
+
*/
|
|
6128
6152
|
|
|
6129
6153
|
/**
|
|
6130
6154
|
* Parses the instrument command
|
|
@@ -6159,6 +6183,7 @@ var instrumentCommandParser = {
|
|
|
6159
6183
|
*/
|
|
6160
6184
|
parse: function (input) {
|
|
6161
6185
|
var args = input.args;
|
|
6186
|
+
// TODO: [🛠] Implement
|
|
6162
6187
|
TODO_USE(args);
|
|
6163
6188
|
return {
|
|
6164
6189
|
type: 'INSTRUMENT',
|
|
@@ -6171,7 +6196,7 @@ var instrumentCommandParser = {
|
|
|
6171
6196
|
*/
|
|
6172
6197
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6173
6198
|
keepUnused(command, $pipelineJson);
|
|
6174
|
-
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
6199
|
+
console.error(new NotYetImplementedError('[🛠] Instruments are not implemented yet'));
|
|
6175
6200
|
},
|
|
6176
6201
|
/**
|
|
6177
6202
|
* Converts the INSTRUMENT command back to string
|
|
@@ -6180,7 +6205,7 @@ var instrumentCommandParser = {
|
|
|
6180
6205
|
*/
|
|
6181
6206
|
stringify: function (command) {
|
|
6182
6207
|
keepUnused(command);
|
|
6183
|
-
|
|
6208
|
+
throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
|
|
6184
6209
|
},
|
|
6185
6210
|
/**
|
|
6186
6211
|
* Reads the INSTRUMENT command from the `PipelineJson`
|
|
@@ -6189,9 +6214,12 @@ var instrumentCommandParser = {
|
|
|
6189
6214
|
*/
|
|
6190
6215
|
takeFromPipelineJson: function (pipelineJson) {
|
|
6191
6216
|
keepUnused(pipelineJson);
|
|
6192
|
-
throw new NotYetImplementedError(
|
|
6217
|
+
throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
|
|
6193
6218
|
},
|
|
6194
6219
|
};
|
|
6220
|
+
/**
|
|
6221
|
+
* Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
|
|
6222
|
+
*/
|
|
6195
6223
|
|
|
6196
6224
|
/**
|
|
6197
6225
|
* Parses the boilerplate command
|
|
@@ -6269,7 +6297,7 @@ var boilerplateCommandParser = {
|
|
|
6269
6297
|
*/
|
|
6270
6298
|
stringify: function (command) {
|
|
6271
6299
|
keepUnused(command);
|
|
6272
|
-
return "
|
|
6300
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
6273
6301
|
},
|
|
6274
6302
|
/**
|
|
6275
6303
|
* Reads the BOILERPLATE command from the `PipelineJson`
|
|
@@ -6290,9 +6318,6 @@ var boilerplateCommandParser = {
|
|
|
6290
6318
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
6291
6319
|
},
|
|
6292
6320
|
};
|
|
6293
|
-
/**
|
|
6294
|
-
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
6295
|
-
*/
|
|
6296
6321
|
|
|
6297
6322
|
/**
|
|
6298
6323
|
* All available command parsers
|
|
@@ -6300,7 +6325,7 @@ var boilerplateCommandParser = {
|
|
|
6300
6325
|
* @private internal index of `parseCommand`
|
|
6301
6326
|
*/
|
|
6302
6327
|
var COMMANDS = [
|
|
6303
|
-
|
|
6328
|
+
templateCommandParser,
|
|
6304
6329
|
expectCommandParser,
|
|
6305
6330
|
formatCommandParser,
|
|
6306
6331
|
jokerCommandParser,
|
|
@@ -6315,8 +6340,28 @@ var COMMANDS = [
|
|
|
6315
6340
|
personaCommandParser,
|
|
6316
6341
|
foreachCommandParser,
|
|
6317
6342
|
boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
|
|
6343
|
+
// <- 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
|
|
6318
6344
|
];
|
|
6319
6345
|
|
|
6346
|
+
/**
|
|
6347
|
+
* Gets the parser for the command
|
|
6348
|
+
*
|
|
6349
|
+
* @returns the parser for the command
|
|
6350
|
+
* @throws {UnexpectedError} if the parser is not found
|
|
6351
|
+
*
|
|
6352
|
+
* @private within the pipelineStringToJson
|
|
6353
|
+
*/
|
|
6354
|
+
function getParserForCommand(command) {
|
|
6355
|
+
var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
|
|
6356
|
+
if (commandParser === undefined) {
|
|
6357
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " parser is not found\n\n ").concat(block(JSON.stringify(command, null, 4)
|
|
6358
|
+
.split('\n')
|
|
6359
|
+
.map(function (line) { return "> ".concat(line); })
|
|
6360
|
+
.join('\n')), "\n "); }));
|
|
6361
|
+
}
|
|
6362
|
+
return commandParser;
|
|
6363
|
+
}
|
|
6364
|
+
|
|
6320
6365
|
/**
|
|
6321
6366
|
* Removes Markdown formatting tags from a string.
|
|
6322
6367
|
*
|
|
@@ -6452,7 +6497,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
6452
6497
|
.map(function (item) { return item.trim(); });
|
|
6453
6498
|
if (items.length === 0 || items[0] === '') {
|
|
6454
6499
|
throw new ParseError(spaceTrim$1(function (block) {
|
|
6455
|
-
return "\n Malformed command:\n
|
|
6500
|
+
return "\n Malformed command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
|
|
6456
6501
|
}));
|
|
6457
6502
|
}
|
|
6458
6503
|
// Note: Taking command name from beginning of the line
|
|
@@ -6479,7 +6524,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
6479
6524
|
}
|
|
6480
6525
|
}
|
|
6481
6526
|
throw new ParseError(spaceTrim$1(function (block) {
|
|
6482
|
-
return "\n Malformed or unknown command:\n
|
|
6527
|
+
return "\n Malformed or unknown command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
|
|
6483
6528
|
}));
|
|
6484
6529
|
}
|
|
6485
6530
|
/**
|
|
@@ -6523,7 +6568,7 @@ function parseCommandVariant(input) {
|
|
|
6523
6568
|
throw error;
|
|
6524
6569
|
}
|
|
6525
6570
|
throw new ParseError(spaceTrim$1(function (block) {
|
|
6526
|
-
return "\n Invalid ".concat(commandName, " command:\n ").concat(
|
|
6571
|
+
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 ");
|
|
6527
6572
|
}));
|
|
6528
6573
|
}
|
|
6529
6574
|
}
|
|
@@ -6786,7 +6831,7 @@ function removeContentComments(content) {
|
|
|
6786
6831
|
* - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
6787
6832
|
* - `preparePipeline` - just one step in the compilation process
|
|
6788
6833
|
*
|
|
6789
|
-
* Note: This function does not validate logic of the pipeline only the
|
|
6834
|
+
* Note: This function does not validate logic of the pipeline only the parsing
|
|
6790
6835
|
* Note: This function acts as compilation process
|
|
6791
6836
|
*
|
|
6792
6837
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
@@ -6883,10 +6928,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6883
6928
|
var _loop_1 = function (listItem) {
|
|
6884
6929
|
// TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineHeadCommands`
|
|
6885
6930
|
var command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
6886
|
-
var commandParser =
|
|
6887
|
-
if (commandParser === undefined) {
|
|
6888
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " parser is not found \uD83C\uDF4E\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6889
|
-
}
|
|
6931
|
+
var commandParser = getParserForCommand(command);
|
|
6890
6932
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
6891
6933
|
throw new ParseError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
6892
6934
|
}
|
|
@@ -6935,9 +6977,9 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6935
6977
|
description_1 = undefined;
|
|
6936
6978
|
}
|
|
6937
6979
|
var $templateJson = {
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6980
|
+
isTemplateTypeSet: false,
|
|
6981
|
+
isTemplate: true,
|
|
6982
|
+
templateType: undefined /* <- Note: [🍙] Putting here placeholder to keep `templateType` on top at final JSON */,
|
|
6941
6983
|
name: titleToName(section.title),
|
|
6942
6984
|
title: section.title,
|
|
6943
6985
|
description: description_1,
|
|
@@ -6959,15 +7001,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6959
7001
|
// Note: If block type is not set, set it to 'PROMPT_TEMPLATE'
|
|
6960
7002
|
if (commands.some(function (_a) {
|
|
6961
7003
|
var command = _a.command;
|
|
6962
|
-
return command.type === '
|
|
7004
|
+
return command.type === 'TEMPLATE';
|
|
6963
7005
|
}) === false) {
|
|
6964
|
-
|
|
7006
|
+
templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
|
|
6965
7007
|
}
|
|
6966
7008
|
var _loop_3 = function (listItem, command) {
|
|
6967
|
-
var commandParser =
|
|
6968
|
-
if (commandParser === undefined) {
|
|
6969
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " parser is not found \uD83C\uDF4F\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6970
|
-
}
|
|
7009
|
+
var commandParser = getParserForCommand(command);
|
|
6971
7010
|
if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
|
|
6972
7011
|
throw new ParseError(spaceTrim$1(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: [🚞]
|
|
6973
7012
|
}
|
|
@@ -6982,16 +7021,13 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6982
7021
|
}
|
|
6983
7022
|
throw new ParseError(spaceTrim$1(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: [🚞]
|
|
6984
7023
|
}
|
|
6985
|
-
// TODO: !!!!!! Multiple problematic things in BLOCK command - blockCommandParser.$applyToTemplateJson
|
|
6986
7024
|
if (command.type === 'PARAMETER') {
|
|
6987
7025
|
defineParam(command);
|
|
6988
7026
|
// <- Note: [🍣]
|
|
6989
7027
|
}
|
|
6990
7028
|
};
|
|
6991
7029
|
try {
|
|
6992
|
-
// TODO
|
|
6993
|
-
// TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE BLOCK`
|
|
6994
|
-
// TODO [♓️] List commands and before apply order them
|
|
7030
|
+
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
6995
7031
|
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()) {
|
|
6996
7032
|
var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
|
|
6997
7033
|
_loop_3(listItem, command);
|
|
@@ -7004,8 +7040,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7004
7040
|
}
|
|
7005
7041
|
finally { if (e_3) throw e_3.error; }
|
|
7006
7042
|
}
|
|
7007
|
-
// TODO: [🍧]
|
|
7008
|
-
if ($templateJson.
|
|
7043
|
+
// TODO: [🍧] Should be done in TEMPLATE command
|
|
7044
|
+
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
7009
7045
|
if (!language) {
|
|
7010
7046
|
throw new ParseError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the SCRIPT TEMPLATE\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
7011
7047
|
}
|
|
@@ -7017,15 +7053,13 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7017
7053
|
}
|
|
7018
7054
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
7019
7055
|
/*
|
|
7020
|
-
// TODO: [🍧]
|
|
7021
|
-
|
|
7022
|
-
// TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
|
|
7023
|
-
if ($templateJson.blockType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
7056
|
+
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
7057
|
+
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
7024
7058
|
throw new UnexpectedError(
|
|
7025
7059
|
spaceTrim(
|
|
7026
7060
|
(block) => `
|
|
7027
7061
|
Model requirements are defined for the block type ${
|
|
7028
|
-
$templateJson.
|
|
7062
|
+
$templateJson.templateType
|
|
7029
7063
|
} which is not a PROMPT TEMPLATE
|
|
7030
7064
|
|
|
7031
7065
|
This should be avoided by the \`modelCommandParser\`
|
|
@@ -7036,9 +7070,9 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7036
7070
|
);
|
|
7037
7071
|
}
|
|
7038
7072
|
*/
|
|
7039
|
-
if ($templateJson.
|
|
7040
|
-
delete $templateJson.
|
|
7041
|
-
delete $templateJson.
|
|
7073
|
+
if ($templateJson.isTemplate) {
|
|
7074
|
+
delete $templateJson.isTemplateTypeSet;
|
|
7075
|
+
delete $templateJson.isTemplate;
|
|
7042
7076
|
// TODO: [🍙] Maybe do reorder of `$templateJson` here
|
|
7043
7077
|
$pipelineJson.templates.push($templateJson);
|
|
7044
7078
|
}
|
|
@@ -7046,7 +7080,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7046
7080
|
try {
|
|
7047
7081
|
// =============================================================
|
|
7048
7082
|
// Note: 4️⃣ Process each template of the pipeline
|
|
7049
|
-
|
|
7083
|
+
for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
|
|
7050
7084
|
var section = pipelineSections_1_1.value;
|
|
7051
7085
|
_loop_2(section);
|
|
7052
7086
|
}
|
|
@@ -7119,7 +7153,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7119
7153
|
* - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
7120
7154
|
* - `preparePipeline` - just one step in the compilation process
|
|
7121
7155
|
*
|
|
7122
|
-
* Note: This function does not validate logic of the pipeline only the
|
|
7156
|
+
* Note: This function does not validate logic of the pipeline only the parsing
|
|
7123
7157
|
* Note: This function acts as compilation process
|
|
7124
7158
|
*
|
|
7125
7159
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
@@ -7179,7 +7213,6 @@ function addAutoGeneratedSection(content, options) {
|
|
|
7179
7213
|
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
7180
7214
|
}
|
|
7181
7215
|
/**
|
|
7182
|
-
* TODO: !!!!!! Somw way how to connect this with commands
|
|
7183
7216
|
* TODO: [🏛] This can be part of markdown builder
|
|
7184
7217
|
*/
|
|
7185
7218
|
|
|
@@ -8397,5 +8430,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
8397
8430
|
* TODO: [🧠] Should be in generated file GENERATOR_WARNING
|
|
8398
8431
|
*/
|
|
8399
8432
|
|
|
8400
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister,
|
|
8433
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, CLAIM, CallbackInterfaceTools, CollectionError, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MAX_EXECUTION_ATTEMPTS, MAX_FILENAME_LENGTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, MAX_PARALLEL_COUNT, MODEL_VARIANTS, MemoryStorage, NotFoundError, NotYetImplementedError, PIPELINE_COLLECTION_BASE_FILENAME, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _OpenAiMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
8401
8434
|
//# sourceMappingURL=index.es.js.map
|