@promptbook/core 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 +1 -1
- package/umd/index.umd.js +20 -20
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -9,7 +9,7 @@ import moment from 'moment';
|
|
|
9
9
|
/**
|
|
10
10
|
* The version of the Promptbook library
|
|
11
11
|
*/
|
|
12
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
12
|
+
var PROMPTBOOK_VERSION = '0.67.6';
|
|
13
13
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
14
14
|
|
|
15
15
|
/*! *****************************************************************************
|
|
@@ -1779,7 +1779,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1779
1779
|
});
|
|
1780
1780
|
}
|
|
1781
1781
|
|
|
1782
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
1782
|
+
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"}];
|
|
1783
1783
|
|
|
1784
1784
|
var defaultDiacriticsRemovalMap = [
|
|
1785
1785
|
{
|
|
@@ -6061,7 +6061,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6061
6061
|
personas: [],
|
|
6062
6062
|
preparations: [],
|
|
6063
6063
|
};
|
|
6064
|
-
|
|
6064
|
+
function getPipelineIdentification() {
|
|
6065
6065
|
// Note: This is a 😐 implementation of [🚞]
|
|
6066
6066
|
var _ = [];
|
|
6067
6067
|
if (pipelineJson.sourceFile !== undefined) {
|
|
@@ -6071,7 +6071,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6071
6071
|
_.push("Url: ".concat(pipelineJson.pipelineUrl));
|
|
6072
6072
|
}
|
|
6073
6073
|
return _.join('\n');
|
|
6074
|
-
}
|
|
6074
|
+
}
|
|
6075
6075
|
// =============================================================
|
|
6076
6076
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
6077
6077
|
pipelineString = removeContentComments(pipelineString);
|
|
@@ -6080,27 +6080,27 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6080
6080
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
6081
6081
|
var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
|
|
6082
6082
|
if (pipelineHead === undefined) {
|
|
6083
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(
|
|
6083
|
+
throw new UnexpectedError(spaceTrim$1(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 "); }));
|
|
6084
6084
|
}
|
|
6085
6085
|
if (pipelineHead.level !== 1) {
|
|
6086
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(
|
|
6086
|
+
throw new UnexpectedError(spaceTrim$1(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 "); }));
|
|
6087
6087
|
}
|
|
6088
6088
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
6089
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(
|
|
6089
|
+
throw new UnexpectedError(spaceTrim$1(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 "); }));
|
|
6090
6090
|
}
|
|
6091
6091
|
// =============================================================
|
|
6092
6092
|
///Note: 2️⃣ Function for defining parameters
|
|
6093
6093
|
var defineParam = function (parameterCommand) {
|
|
6094
6094
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
6095
6095
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
6096
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(
|
|
6096
|
+
throw new ParsingError(spaceTrim$1(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: [🚞] */);
|
|
6097
6097
|
}
|
|
6098
6098
|
var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
6099
6099
|
if (existingParameter &&
|
|
6100
6100
|
existingParameter.description &&
|
|
6101
6101
|
existingParameter.description !== parameterDescription &&
|
|
6102
6102
|
parameterDescription) {
|
|
6103
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(
|
|
6103
|
+
throw new ParsingError(spaceTrim$1(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 "); }));
|
|
6104
6104
|
}
|
|
6105
6105
|
if (existingParameter) {
|
|
6106
6106
|
if (parameterDescription) {
|
|
@@ -6163,10 +6163,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6163
6163
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6164
6164
|
break;
|
|
6165
6165
|
case 'BOILERPLATE':
|
|
6166
|
-
throw new ParsingError(spaceTrim$1(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(
|
|
6166
|
+
throw new ParsingError(spaceTrim$1(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: [🚞]
|
|
6167
6167
|
// <- [💐]
|
|
6168
6168
|
default:
|
|
6169
|
-
throw new ParsingError(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(
|
|
6169
|
+
throw new ParsingError(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: [🚞]
|
|
6170
6170
|
}
|
|
6171
6171
|
};
|
|
6172
6172
|
try {
|
|
@@ -6199,7 +6199,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6199
6199
|
if (resultingParameterName !== null) {
|
|
6200
6200
|
return resultingParameterName;
|
|
6201
6201
|
}
|
|
6202
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(
|
|
6202
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
|
|
6203
6203
|
// TODO: Show code of invalid sections each time + DRY
|
|
6204
6204
|
section.content
|
|
6205
6205
|
.split('\n')
|
|
@@ -6242,13 +6242,13 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6242
6242
|
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6243
6243
|
case 'BLOCK':
|
|
6244
6244
|
if (isBlockTypeSet) {
|
|
6245
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(
|
|
6245
|
+
throw new ParsingError(spaceTrim$1(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 "); }));
|
|
6246
6246
|
}
|
|
6247
6247
|
if (command.blockType === 'SAMPLE') {
|
|
6248
6248
|
expectResultingParameterName();
|
|
6249
6249
|
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
6250
6250
|
if (parameter === undefined) {
|
|
6251
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(
|
|
6251
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6252
6252
|
}
|
|
6253
6253
|
parameter.sampleValues = parameter.sampleValues || [];
|
|
6254
6254
|
parameter.sampleValues.push(content);
|
|
@@ -6283,20 +6283,20 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6283
6283
|
templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
|
|
6284
6284
|
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6285
6285
|
if (templateJson.expectations[unit_1].min !== undefined) {
|
|
6286
|
-
throw new ParsingError(spaceTrim$1(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(
|
|
6286
|
+
throw new ParsingError(spaceTrim$1(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 "); }));
|
|
6287
6287
|
}
|
|
6288
6288
|
templateJson.expectations[unit_1].min = command.amount;
|
|
6289
6289
|
} /* not else */
|
|
6290
6290
|
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6291
6291
|
if (templateJson.expectations[unit_1].max !== undefined) {
|
|
6292
|
-
throw new ParsingError(spaceTrim$1(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(
|
|
6292
|
+
throw new ParsingError(spaceTrim$1(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 "); }));
|
|
6293
6293
|
}
|
|
6294
6294
|
templateJson.expectations[unit_1].max = command.amount;
|
|
6295
6295
|
}
|
|
6296
6296
|
break;
|
|
6297
6297
|
case 'EXPECT_FORMAT':
|
|
6298
6298
|
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6299
|
-
throw new ParsingError(spaceTrim$1(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(
|
|
6299
|
+
throw new ParsingError(spaceTrim$1(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 "); }));
|
|
6300
6300
|
}
|
|
6301
6301
|
templateJson.expectFormat = command.format;
|
|
6302
6302
|
break;
|
|
@@ -6332,11 +6332,11 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6332
6332
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6333
6333
|
break;
|
|
6334
6334
|
case 'BOILERPLATE':
|
|
6335
|
-
console.error(new ParsingError(spaceTrim$1(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(
|
|
6335
|
+
console.error(new ParsingError(spaceTrim$1(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 "); })));
|
|
6336
6336
|
break;
|
|
6337
6337
|
// <- [💐]
|
|
6338
6338
|
default:
|
|
6339
|
-
throw new ParsingError(spaceTrim$1(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(
|
|
6339
|
+
throw new ParsingError(spaceTrim$1(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 "); }));
|
|
6340
6340
|
}
|
|
6341
6341
|
};
|
|
6342
6342
|
try {
|
|
@@ -6358,7 +6358,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6358
6358
|
// TODO: [🍧] Should be done in BLOCK command
|
|
6359
6359
|
if (templateJson.blockType === 'SCRIPT') {
|
|
6360
6360
|
if (!language) {
|
|
6361
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(
|
|
6361
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
6362
6362
|
}
|
|
6363
6363
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6364
6364
|
throw new ParsingError(spaceTrim$1(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 "); }));
|