@promptbook/core 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
|
@@ -14,6 +14,7 @@ import type { PrettifyOptions } from '../conversion/prettify/PrettifyOptions';
|
|
|
14
14
|
import type { renderPipelineMermaidOptions } from '../conversion/prettify/renderPipelineMermaidOptions';
|
|
15
15
|
import type { ErrorJson } from '../errors/utils/ErrorJson';
|
|
16
16
|
import type { AvailableModel } from '../execution/AvailableModel';
|
|
17
|
+
import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
|
|
17
18
|
import type { EmbeddingVector } from '../execution/EmbeddingVector';
|
|
18
19
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
19
20
|
import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
|
|
@@ -238,6 +239,7 @@ export type { PrettifyOptions };
|
|
|
238
239
|
export type { renderPipelineMermaidOptions };
|
|
239
240
|
export type { ErrorJson };
|
|
240
241
|
export type { AvailableModel };
|
|
242
|
+
export type { CommonExecutionToolsOptions };
|
|
241
243
|
export type { EmbeddingVector };
|
|
242
244
|
export type { ExecutionTools };
|
|
243
245
|
export type { LlmExecutionTools };
|
|
@@ -8,5 +8,13 @@ import type { TemplateCommand } from './TemplateCommand';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const templateCommandParser: PipelineTemplateCommandParser<TemplateCommand>;
|
|
10
10
|
/**
|
|
11
|
-
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands
|
|
11
|
+
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
|
|
12
|
+
* 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
|
|
13
|
+
* - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
14
|
+
* 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
|
|
15
|
+
* - KNOWLEDGE TEMPLATE
|
|
16
|
+
*
|
|
17
|
+
* ```
|
|
18
|
+
* Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
19
|
+
* ```
|
|
12
20
|
*/
|
|
@@ -9,6 +9,3 @@ import type { BoilerplateCommand } from './BoilerplateCommand';
|
|
|
9
9
|
* @private within the commands folder
|
|
10
10
|
*/
|
|
11
11
|
export declare const boilerplateCommandParser: PipelineBothCommandParser<BoilerplateCommand>;
|
|
12
|
-
/**
|
|
13
|
-
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
14
|
-
*/
|
|
@@ -86,6 +86,7 @@ export type PipelineJson = {
|
|
|
86
86
|
readonly preparations: Array<PreparationJson>;
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
+
* TODO: [🛳] Default PERSONA for the pipeline `defaultPersonaName` (same as `defaultModelRequirements`)
|
|
89
90
|
* TODO: [🍙] Make some standard order of json properties
|
|
90
91
|
* TODO: [🧠] Maybe wrap all {parameterNames} in brackets for example { "resultingParameterName": "{foo}" }
|
|
91
92
|
* Note: [💼] There was a proposal for multiple types of promptbook objects 78816ff33e2705ee1a187aa2eb8affd976d4ea1a
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.68.0-
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.68.0-4';
|
|
20
20
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
/*! *****************************************************************************
|
|
@@ -1794,7 +1794,7 @@
|
|
|
1794
1794
|
});
|
|
1795
1795
|
}
|
|
1796
1796
|
|
|
1797
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-
|
|
1797
|
+
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"}];
|
|
1798
1798
|
|
|
1799
1799
|
var defaultDiacriticsRemovalMap = [
|
|
1800
1800
|
{
|
|
@@ -4891,12 +4891,11 @@
|
|
|
4891
4891
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
4892
4892
|
*/
|
|
4893
4893
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4894
|
-
// TODO: !!!!!! Test multiple / no template type
|
|
4895
4894
|
if ($templateJson.isTemplateTypeSet === true) {
|
|
4896
4895
|
throw new ParseError(spaceTrim__default["default"]("\n Template type is already defined in the template.\n It can be defined only once.\n "));
|
|
4897
4896
|
}
|
|
4898
4897
|
$templateJson.isTemplateTypeSet = true;
|
|
4899
|
-
// TODO:
|
|
4898
|
+
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
4900
4899
|
var expectResultingParameterName = function () {
|
|
4901
4900
|
if ($templateJson.resultingParameterName) {
|
|
4902
4901
|
return;
|
|
@@ -4937,12 +4936,6 @@
|
|
|
4937
4936
|
}
|
|
4938
4937
|
expectResultingParameterName();
|
|
4939
4938
|
$templateJson.templateType = command.templateType;
|
|
4940
|
-
/*
|
|
4941
|
-
TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
|
|
4942
|
-
if (command.templateType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
|
|
4943
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
4944
|
-
}
|
|
4945
|
-
*/
|
|
4946
4939
|
$templateJson.isTemplate = true;
|
|
4947
4940
|
},
|
|
4948
4941
|
/**
|
|
@@ -4965,7 +4958,15 @@
|
|
|
4965
4958
|
},
|
|
4966
4959
|
};
|
|
4967
4960
|
/**
|
|
4968
|
-
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands
|
|
4961
|
+
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
|
|
4962
|
+
* 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
|
|
4963
|
+
* - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4964
|
+
* 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
|
|
4965
|
+
* - KNOWLEDGE TEMPLATE
|
|
4966
|
+
*
|
|
4967
|
+
* ```
|
|
4968
|
+
* Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4969
|
+
* ```
|
|
4969
4970
|
*/
|
|
4970
4971
|
|
|
4971
4972
|
/**
|
|
@@ -5513,8 +5514,16 @@
|
|
|
5513
5514
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
5514
5515
|
*/
|
|
5515
5516
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5516
|
-
// TODO: !!!!!! Error on redefine
|
|
5517
5517
|
$pipelineJson.defaultModelRequirements = $pipelineJson.defaultModelRequirements || {};
|
|
5518
|
+
// TODO: [🚜] DRY
|
|
5519
|
+
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
5520
|
+
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
5521
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
5522
|
+
}
|
|
5523
|
+
else {
|
|
5524
|
+
throw new ParseError(spaceTrim__default["default"]("\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 ")));
|
|
5525
|
+
}
|
|
5526
|
+
}
|
|
5518
5527
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
5519
5528
|
},
|
|
5520
5529
|
/**
|
|
@@ -5522,13 +5531,23 @@
|
|
|
5522
5531
|
*
|
|
5523
5532
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5524
5533
|
*/
|
|
5525
|
-
$applyToTemplateJson: function (command, $templateJson) {
|
|
5534
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5526
5535
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5527
5536
|
throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
|
|
5528
5537
|
}
|
|
5529
|
-
// TODO: !!!!!! Error on redefine
|
|
5530
|
-
// TODO: Warn if setting same as default in `$pipelineJson`
|
|
5531
5538
|
$templateJson.modelRequirements = $templateJson.modelRequirements || {};
|
|
5539
|
+
// TODO: [🚜] DRY
|
|
5540
|
+
if ($templateJson.modelRequirements[command.key] !== undefined) {
|
|
5541
|
+
if ($templateJson.modelRequirements[command.key] === command.value) {
|
|
5542
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the template \"").concat($templateJson.title || $templateJson.name, "\""));
|
|
5543
|
+
}
|
|
5544
|
+
else {
|
|
5545
|
+
throw new ParseError(spaceTrim__default["default"]("\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 ")));
|
|
5546
|
+
}
|
|
5547
|
+
}
|
|
5548
|
+
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
5549
|
+
console.log(spaceTrim__default["default"]("\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 ")));
|
|
5550
|
+
}
|
|
5532
5551
|
$templateJson.modelRequirements[command.key] = command.value;
|
|
5533
5552
|
},
|
|
5534
5553
|
/**
|
|
@@ -6305,9 +6324,6 @@
|
|
|
6305
6324
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
6306
6325
|
},
|
|
6307
6326
|
};
|
|
6308
|
-
/**
|
|
6309
|
-
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
6310
|
-
*/
|
|
6311
6327
|
|
|
6312
6328
|
/**
|
|
6313
6329
|
* All available command parsers
|
|
@@ -6330,6 +6346,7 @@
|
|
|
6330
6346
|
personaCommandParser,
|
|
6331
6347
|
foreachCommandParser,
|
|
6332
6348
|
boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
|
|
6349
|
+
// <- 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
|
|
6333
6350
|
];
|
|
6334
6351
|
|
|
6335
6352
|
/**
|
|
@@ -7016,9 +7033,7 @@
|
|
|
7016
7033
|
}
|
|
7017
7034
|
};
|
|
7018
7035
|
try {
|
|
7019
|
-
// TODO
|
|
7020
|
-
// TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE TEMPLATE`
|
|
7021
|
-
// TODO [♓️] List commands and before apply order them
|
|
7036
|
+
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
7022
7037
|
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()) {
|
|
7023
7038
|
var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
|
|
7024
7039
|
_loop_3(listItem, command);
|
|
@@ -7031,7 +7046,7 @@
|
|
|
7031
7046
|
}
|
|
7032
7047
|
finally { if (e_3) throw e_3.error; }
|
|
7033
7048
|
}
|
|
7034
|
-
// TODO: [🍧]
|
|
7049
|
+
// TODO: [🍧] Should be done in TEMPLATE command
|
|
7035
7050
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
7036
7051
|
if (!language) {
|
|
7037
7052
|
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the SCRIPT TEMPLATE\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
@@ -7044,9 +7059,7 @@
|
|
|
7044
7059
|
}
|
|
7045
7060
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
7046
7061
|
/*
|
|
7047
|
-
// TODO: [🍧]
|
|
7048
|
-
// TODO: [🍧] !!!!!! Write error `.ptbk.md` file for `MODEL` and `PERSONA` command used in non-prompt template
|
|
7049
|
-
// TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
|
|
7062
|
+
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
7050
7063
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
7051
7064
|
throw new UnexpectedError(
|
|
7052
7065
|
spaceTrim(
|