@promptbook/core 0.68.0-4 → 0.68.0
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
|
@@ -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-5';
|
|
14
14
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
15
15
|
|
|
16
16
|
/*! *****************************************************************************
|
|
@@ -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-5",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-5",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-5",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-5",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],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
|
{
|
|
@@ -4885,12 +4885,11 @@ var templateCommandParser = {
|
|
|
4885
4885
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
4886
4886
|
*/
|
|
4887
4887
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4888
|
-
// TODO: !!!!!! Test multiple / no template type
|
|
4889
4888
|
if ($templateJson.isTemplateTypeSet === true) {
|
|
4890
4889
|
throw new ParseError(spaceTrim("\n Template type is already defined in the template.\n It can be defined only once.\n "));
|
|
4891
4890
|
}
|
|
4892
4891
|
$templateJson.isTemplateTypeSet = true;
|
|
4893
|
-
// TODO:
|
|
4892
|
+
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
4894
4893
|
var expectResultingParameterName = function () {
|
|
4895
4894
|
if ($templateJson.resultingParameterName) {
|
|
4896
4895
|
return;
|
|
@@ -4931,12 +4930,6 @@ var templateCommandParser = {
|
|
|
4931
4930
|
}
|
|
4932
4931
|
expectResultingParameterName();
|
|
4933
4932
|
$templateJson.templateType = command.templateType;
|
|
4934
|
-
/*
|
|
4935
|
-
TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
|
|
4936
|
-
if (command.templateType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
|
|
4937
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
4938
|
-
}
|
|
4939
|
-
*/
|
|
4940
4933
|
$templateJson.isTemplate = true;
|
|
4941
4934
|
},
|
|
4942
4935
|
/**
|
|
@@ -4959,7 +4952,15 @@ var templateCommandParser = {
|
|
|
4959
4952
|
},
|
|
4960
4953
|
};
|
|
4961
4954
|
/**
|
|
4962
|
-
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands
|
|
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
|
+
* ```
|
|
4963
4964
|
*/
|
|
4964
4965
|
|
|
4965
4966
|
/**
|
|
@@ -5507,8 +5508,16 @@ var modelCommandParser = {
|
|
|
5507
5508
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
5508
5509
|
*/
|
|
5509
5510
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5510
|
-
// TODO: !!!!!! Error on redefine
|
|
5511
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
|
+
}
|
|
5512
5521
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
5513
5522
|
},
|
|
5514
5523
|
/**
|
|
@@ -5516,13 +5525,23 @@ var modelCommandParser = {
|
|
|
5516
5525
|
*
|
|
5517
5526
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5518
5527
|
*/
|
|
5519
|
-
$applyToTemplateJson: function (command, $templateJson) {
|
|
5528
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5520
5529
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5521
5530
|
throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
|
|
5522
5531
|
}
|
|
5523
|
-
// TODO: !!!!!! Error on redefine
|
|
5524
|
-
// TODO: Warn if setting same as default in `$pipelineJson`
|
|
5525
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
|
+
}
|
|
5526
5545
|
$templateJson.modelRequirements[command.key] = command.value;
|
|
5527
5546
|
},
|
|
5528
5547
|
/**
|
|
@@ -6299,9 +6318,6 @@ var boilerplateCommandParser = {
|
|
|
6299
6318
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
6300
6319
|
},
|
|
6301
6320
|
};
|
|
6302
|
-
/**
|
|
6303
|
-
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
6304
|
-
*/
|
|
6305
6321
|
|
|
6306
6322
|
/**
|
|
6307
6323
|
* All available command parsers
|
|
@@ -6324,6 +6340,7 @@ var COMMANDS = [
|
|
|
6324
6340
|
personaCommandParser,
|
|
6325
6341
|
foreachCommandParser,
|
|
6326
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
|
|
6327
6344
|
];
|
|
6328
6345
|
|
|
6329
6346
|
/**
|
|
@@ -7010,9 +7027,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7010
7027
|
}
|
|
7011
7028
|
};
|
|
7012
7029
|
try {
|
|
7013
|
-
// TODO
|
|
7014
|
-
// TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE TEMPLATE`
|
|
7015
|
-
// TODO [♓️] List commands and before apply order them
|
|
7030
|
+
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
7016
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()) {
|
|
7017
7032
|
var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
|
|
7018
7033
|
_loop_3(listItem, command);
|
|
@@ -7025,7 +7040,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7025
7040
|
}
|
|
7026
7041
|
finally { if (e_3) throw e_3.error; }
|
|
7027
7042
|
}
|
|
7028
|
-
// TODO: [🍧]
|
|
7043
|
+
// TODO: [🍧] Should be done in TEMPLATE command
|
|
7029
7044
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
7030
7045
|
if (!language) {
|
|
7031
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 "); }));
|
|
@@ -7038,9 +7053,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7038
7053
|
}
|
|
7039
7054
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
7040
7055
|
/*
|
|
7041
|
-
// TODO: [🍧]
|
|
7042
|
-
// TODO: [🍧] !!!!!! Write error `.ptbk.md` file for `MODEL` and `PERSONA` command used in non-prompt template
|
|
7043
|
-
// TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
|
|
7056
|
+
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
7044
7057
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
7045
7058
|
throw new UnexpectedError(
|
|
7046
7059
|
spaceTrim(
|