@promptbook/cli 0.68.0-4 → 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/esm/index.es.js +38 -25
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/commands/TEMPLATE/templateCommandParser.d.ts +9 -1
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +0 -3
- package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +38 -25
- package/umd/index.umd.js.map +1 -1
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
|
/*! *****************************************************************************
|
|
@@ -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
|
|
@@ -4733,12 +4733,11 @@ var templateCommandParser = {
|
|
|
4733
4733
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
4734
4734
|
*/
|
|
4735
4735
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4736
|
-
// TODO: !!!!!! Test multiple / no template type
|
|
4737
4736
|
if ($templateJson.isTemplateTypeSet === true) {
|
|
4738
4737
|
throw new ParseError(spaceTrim$1("\n Template type is already defined in the template.\n It can be defined only once.\n "));
|
|
4739
4738
|
}
|
|
4740
4739
|
$templateJson.isTemplateTypeSet = true;
|
|
4741
|
-
// TODO:
|
|
4740
|
+
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
4742
4741
|
var expectResultingParameterName = function () {
|
|
4743
4742
|
if ($templateJson.resultingParameterName) {
|
|
4744
4743
|
return;
|
|
@@ -4779,12 +4778,6 @@ var templateCommandParser = {
|
|
|
4779
4778
|
}
|
|
4780
4779
|
expectResultingParameterName();
|
|
4781
4780
|
$templateJson.templateType = command.templateType;
|
|
4782
|
-
/*
|
|
4783
|
-
TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
|
|
4784
|
-
if (command.templateType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
|
|
4785
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
4786
|
-
}
|
|
4787
|
-
*/
|
|
4788
4781
|
$templateJson.isTemplate = true;
|
|
4789
4782
|
},
|
|
4790
4783
|
/**
|
|
@@ -4807,7 +4800,15 @@ var templateCommandParser = {
|
|
|
4807
4800
|
},
|
|
4808
4801
|
};
|
|
4809
4802
|
/**
|
|
4810
|
-
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands
|
|
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
|
+
* ```
|
|
4811
4812
|
*/
|
|
4812
4813
|
|
|
4813
4814
|
/**
|
|
@@ -5355,8 +5356,16 @@ var modelCommandParser = {
|
|
|
5355
5356
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
5356
5357
|
*/
|
|
5357
5358
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5358
|
-
// TODO: !!!!!! Error on redefine
|
|
5359
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
|
+
}
|
|
5360
5369
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
5361
5370
|
},
|
|
5362
5371
|
/**
|
|
@@ -5364,13 +5373,23 @@ var modelCommandParser = {
|
|
|
5364
5373
|
*
|
|
5365
5374
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5366
5375
|
*/
|
|
5367
|
-
$applyToTemplateJson: function (command, $templateJson) {
|
|
5376
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5368
5377
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5369
5378
|
throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
|
|
5370
5379
|
}
|
|
5371
|
-
// TODO: !!!!!! Error on redefine
|
|
5372
|
-
// TODO: Warn if setting same as default in `$pipelineJson`
|
|
5373
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
|
+
}
|
|
5374
5393
|
$templateJson.modelRequirements[command.key] = command.value;
|
|
5375
5394
|
},
|
|
5376
5395
|
/**
|
|
@@ -6147,9 +6166,6 @@ var boilerplateCommandParser = {
|
|
|
6147
6166
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
6148
6167
|
},
|
|
6149
6168
|
};
|
|
6150
|
-
/**
|
|
6151
|
-
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
6152
|
-
*/
|
|
6153
6169
|
|
|
6154
6170
|
/**
|
|
6155
6171
|
* All available command parsers
|
|
@@ -6172,6 +6188,7 @@ var COMMANDS = [
|
|
|
6172
6188
|
personaCommandParser,
|
|
6173
6189
|
foreachCommandParser,
|
|
6174
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
|
|
6175
6192
|
];
|
|
6176
6193
|
|
|
6177
6194
|
/**
|
|
@@ -6858,9 +6875,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6858
6875
|
}
|
|
6859
6876
|
};
|
|
6860
6877
|
try {
|
|
6861
|
-
// TODO
|
|
6862
|
-
// TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE TEMPLATE`
|
|
6863
|
-
// TODO [♓️] List commands and before apply order them
|
|
6878
|
+
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
6864
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()) {
|
|
6865
6880
|
var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
|
|
6866
6881
|
_loop_3(listItem, command);
|
|
@@ -6873,7 +6888,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6873
6888
|
}
|
|
6874
6889
|
finally { if (e_3) throw e_3.error; }
|
|
6875
6890
|
}
|
|
6876
|
-
// TODO: [🍧]
|
|
6891
|
+
// TODO: [🍧] Should be done in TEMPLATE command
|
|
6877
6892
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
6878
6893
|
if (!language) {
|
|
6879
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 "); }));
|
|
@@ -6886,9 +6901,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6886
6901
|
}
|
|
6887
6902
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
6888
6903
|
/*
|
|
6889
|
-
// TODO: [🍧]
|
|
6890
|
-
// TODO: [🍧] !!!!!! Write error `.ptbk.md` file for `MODEL` and `PERSONA` command used in non-prompt template
|
|
6891
|
-
// TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
|
|
6904
|
+
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
6892
6905
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
6893
6906
|
throw new UnexpectedError(
|
|
6894
6907
|
spaceTrim(
|