@promptbook/node 0.67.6 → 0.67.7
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 +20 -20
- package/esm/index.es.js.map +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +20 -20
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -13,7 +13,7 @@ import * as dotenv from 'dotenv';
|
|
|
13
13
|
/**
|
|
14
14
|
* The version of the Promptbook library
|
|
15
15
|
*/
|
|
16
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
16
|
+
var PROMPTBOOK_VERSION = '0.67.6';
|
|
17
17
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
18
18
|
|
|
19
19
|
/*! *****************************************************************************
|
|
@@ -867,7 +867,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
867
867
|
});
|
|
868
868
|
}
|
|
869
869
|
|
|
870
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
870
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.6",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.67.6",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.67.6",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.67.6",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
871
871
|
|
|
872
872
|
/**
|
|
873
873
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -5759,7 +5759,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5759
5759
|
personas: [],
|
|
5760
5760
|
preparations: [],
|
|
5761
5761
|
};
|
|
5762
|
-
|
|
5762
|
+
function getPipelineIdentification() {
|
|
5763
5763
|
// Note: This is a 😐 implementation of [🚞]
|
|
5764
5764
|
var _ = [];
|
|
5765
5765
|
if (pipelineJson.sourceFile !== undefined) {
|
|
@@ -5769,7 +5769,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5769
5769
|
_.push("Url: ".concat(pipelineJson.pipelineUrl));
|
|
5770
5770
|
}
|
|
5771
5771
|
return _.join('\n');
|
|
5772
|
-
}
|
|
5772
|
+
}
|
|
5773
5773
|
// =============================================================
|
|
5774
5774
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
5775
5775
|
pipelineString = removeContentComments(pipelineString);
|
|
@@ -5778,27 +5778,27 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5778
5778
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
5779
5779
|
var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
|
|
5780
5780
|
if (pipelineHead === undefined) {
|
|
5781
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(
|
|
5781
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
5782
5782
|
}
|
|
5783
5783
|
if (pipelineHead.level !== 1) {
|
|
5784
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(
|
|
5784
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
5785
5785
|
}
|
|
5786
5786
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
5787
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(
|
|
5787
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
5788
5788
|
}
|
|
5789
5789
|
// =============================================================
|
|
5790
5790
|
///Note: 2️⃣ Function for defining parameters
|
|
5791
5791
|
var defineParam = function (parameterCommand) {
|
|
5792
5792
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
5793
5793
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
5794
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(
|
|
5794
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(getPipelineIdentification()), "\n "); }) /* <- TODO: [🚞] */);
|
|
5795
5795
|
}
|
|
5796
5796
|
var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
5797
5797
|
if (existingParameter &&
|
|
5798
5798
|
existingParameter.description &&
|
|
5799
5799
|
existingParameter.description !== parameterDescription &&
|
|
5800
5800
|
parameterDescription) {
|
|
5801
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(
|
|
5801
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
5802
5802
|
}
|
|
5803
5803
|
if (existingParameter) {
|
|
5804
5804
|
if (parameterDescription) {
|
|
@@ -5861,10 +5861,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5861
5861
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
5862
5862
|
break;
|
|
5863
5863
|
case 'BOILERPLATE':
|
|
5864
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(
|
|
5864
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
5865
5865
|
// <- [💐]
|
|
5866
5866
|
default:
|
|
5867
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(
|
|
5867
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
5868
5868
|
}
|
|
5869
5869
|
};
|
|
5870
5870
|
try {
|
|
@@ -5897,7 +5897,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5897
5897
|
if (resultingParameterName !== null) {
|
|
5898
5898
|
return resultingParameterName;
|
|
5899
5899
|
}
|
|
5900
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(
|
|
5900
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
|
|
5901
5901
|
// TODO: Show code of invalid sections each time + DRY
|
|
5902
5902
|
section.content
|
|
5903
5903
|
.split('\n')
|
|
@@ -5940,13 +5940,13 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5940
5940
|
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
5941
5941
|
case 'BLOCK':
|
|
5942
5942
|
if (isBlockTypeSet) {
|
|
5943
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(
|
|
5943
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
5944
5944
|
}
|
|
5945
5945
|
if (command.blockType === 'SAMPLE') {
|
|
5946
5946
|
expectResultingParameterName();
|
|
5947
5947
|
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
5948
5948
|
if (parameter === undefined) {
|
|
5949
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(
|
|
5949
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
5950
5950
|
}
|
|
5951
5951
|
parameter.sampleValues = parameter.sampleValues || [];
|
|
5952
5952
|
parameter.sampleValues.push(content);
|
|
@@ -5981,20 +5981,20 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5981
5981
|
templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
|
|
5982
5982
|
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
5983
5983
|
if (templateJson.expectations[unit_1].min !== undefined) {
|
|
5984
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(
|
|
5984
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
5985
5985
|
}
|
|
5986
5986
|
templateJson.expectations[unit_1].min = command.amount;
|
|
5987
5987
|
} /* not else */
|
|
5988
5988
|
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
5989
5989
|
if (templateJson.expectations[unit_1].max !== undefined) {
|
|
5990
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(
|
|
5990
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
5991
5991
|
}
|
|
5992
5992
|
templateJson.expectations[unit_1].max = command.amount;
|
|
5993
5993
|
}
|
|
5994
5994
|
break;
|
|
5995
5995
|
case 'EXPECT_FORMAT':
|
|
5996
5996
|
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
5997
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(
|
|
5997
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
5998
5998
|
}
|
|
5999
5999
|
templateJson.expectFormat = command.format;
|
|
6000
6000
|
break;
|
|
@@ -6030,11 +6030,11 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6030
6030
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6031
6031
|
break;
|
|
6032
6032
|
case 'BOILERPLATE':
|
|
6033
|
-
console.error(new ParsingError(spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(
|
|
6033
|
+
console.error(new ParsingError(spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })));
|
|
6034
6034
|
break;
|
|
6035
6035
|
// <- [💐]
|
|
6036
6036
|
default:
|
|
6037
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(
|
|
6037
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(getPipelineIdentification()), "\n\n "); }));
|
|
6038
6038
|
}
|
|
6039
6039
|
};
|
|
6040
6040
|
try {
|
|
@@ -6056,7 +6056,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6056
6056
|
// TODO: [🍧] Should be done in BLOCK command
|
|
6057
6057
|
if (templateJson.blockType === 'SCRIPT') {
|
|
6058
6058
|
if (!language) {
|
|
6059
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(
|
|
6059
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
6060
6060
|
}
|
|
6061
6061
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6062
6062
|
throw new ParsingError(spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|