@promptbook/node 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 +2 -2
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.68.0
|
|
3
|
+
"version": "0.68.0",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.68.0
|
|
50
|
+
"@promptbook/core": "0.68.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
/**
|
|
36
36
|
* The version of the Promptbook library
|
|
37
37
|
*/
|
|
38
|
-
var PROMPTBOOK_VERSION = '0.68.0-
|
|
38
|
+
var PROMPTBOOK_VERSION = '0.68.0-5';
|
|
39
39
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
40
40
|
|
|
41
41
|
/*! *****************************************************************************
|
|
@@ -895,7 +895,7 @@
|
|
|
895
895
|
});
|
|
896
896
|
}
|
|
897
897
|
|
|
898
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-
|
|
898
|
+
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"}];
|
|
899
899
|
|
|
900
900
|
/**
|
|
901
901
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -4604,12 +4604,11 @@
|
|
|
4604
4604
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
4605
4605
|
*/
|
|
4606
4606
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4607
|
-
// TODO: !!!!!! Test multiple / no template type
|
|
4608
4607
|
if ($templateJson.isTemplateTypeSet === true) {
|
|
4609
4608
|
throw new ParseError(spaceTrim__default["default"]("\n Template type is already defined in the template.\n It can be defined only once.\n "));
|
|
4610
4609
|
}
|
|
4611
4610
|
$templateJson.isTemplateTypeSet = true;
|
|
4612
|
-
// TODO:
|
|
4611
|
+
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
4613
4612
|
var expectResultingParameterName = function () {
|
|
4614
4613
|
if ($templateJson.resultingParameterName) {
|
|
4615
4614
|
return;
|
|
@@ -4650,12 +4649,6 @@
|
|
|
4650
4649
|
}
|
|
4651
4650
|
expectResultingParameterName();
|
|
4652
4651
|
$templateJson.templateType = command.templateType;
|
|
4653
|
-
/*
|
|
4654
|
-
TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
|
|
4655
|
-
if (command.templateType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
|
|
4656
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
4657
|
-
}
|
|
4658
|
-
*/
|
|
4659
4652
|
$templateJson.isTemplate = true;
|
|
4660
4653
|
},
|
|
4661
4654
|
/**
|
|
@@ -4678,7 +4671,15 @@
|
|
|
4678
4671
|
},
|
|
4679
4672
|
};
|
|
4680
4673
|
/**
|
|
4681
|
-
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands
|
|
4674
|
+
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
|
|
4675
|
+
* 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
|
|
4676
|
+
* - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4677
|
+
* 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
|
|
4678
|
+
* - KNOWLEDGE TEMPLATE
|
|
4679
|
+
*
|
|
4680
|
+
* ```
|
|
4681
|
+
* Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4682
|
+
* ```
|
|
4682
4683
|
*/
|
|
4683
4684
|
|
|
4684
4685
|
/**
|
|
@@ -5226,8 +5227,16 @@
|
|
|
5226
5227
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
5227
5228
|
*/
|
|
5228
5229
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5229
|
-
// TODO: !!!!!! Error on redefine
|
|
5230
5230
|
$pipelineJson.defaultModelRequirements = $pipelineJson.defaultModelRequirements || {};
|
|
5231
|
+
// TODO: [🚜] DRY
|
|
5232
|
+
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
5233
|
+
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
5234
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
5235
|
+
}
|
|
5236
|
+
else {
|
|
5237
|
+
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 ")));
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5231
5240
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
5232
5241
|
},
|
|
5233
5242
|
/**
|
|
@@ -5235,13 +5244,23 @@
|
|
|
5235
5244
|
*
|
|
5236
5245
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5237
5246
|
*/
|
|
5238
|
-
$applyToTemplateJson: function (command, $templateJson) {
|
|
5247
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5239
5248
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5240
5249
|
throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
|
|
5241
5250
|
}
|
|
5242
|
-
// TODO: !!!!!! Error on redefine
|
|
5243
|
-
// TODO: Warn if setting same as default in `$pipelineJson`
|
|
5244
5251
|
$templateJson.modelRequirements = $templateJson.modelRequirements || {};
|
|
5252
|
+
// TODO: [🚜] DRY
|
|
5253
|
+
if ($templateJson.modelRequirements[command.key] !== undefined) {
|
|
5254
|
+
if ($templateJson.modelRequirements[command.key] === command.value) {
|
|
5255
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the template \"").concat($templateJson.title || $templateJson.name, "\""));
|
|
5256
|
+
}
|
|
5257
|
+
else {
|
|
5258
|
+
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 ")));
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
5262
|
+
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 ")));
|
|
5263
|
+
}
|
|
5245
5264
|
$templateJson.modelRequirements[command.key] = command.value;
|
|
5246
5265
|
},
|
|
5247
5266
|
/**
|
|
@@ -6018,9 +6037,6 @@
|
|
|
6018
6037
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
6019
6038
|
},
|
|
6020
6039
|
};
|
|
6021
|
-
/**
|
|
6022
|
-
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
6023
|
-
*/
|
|
6024
6040
|
|
|
6025
6041
|
/**
|
|
6026
6042
|
* All available command parsers
|
|
@@ -6043,6 +6059,7 @@
|
|
|
6043
6059
|
personaCommandParser,
|
|
6044
6060
|
foreachCommandParser,
|
|
6045
6061
|
boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
|
|
6062
|
+
// <- 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
|
|
6046
6063
|
];
|
|
6047
6064
|
|
|
6048
6065
|
/**
|
|
@@ -6729,9 +6746,7 @@
|
|
|
6729
6746
|
}
|
|
6730
6747
|
};
|
|
6731
6748
|
try {
|
|
6732
|
-
// TODO
|
|
6733
|
-
// TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE TEMPLATE`
|
|
6734
|
-
// TODO [♓️] List commands and before apply order them
|
|
6749
|
+
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
6735
6750
|
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()) {
|
|
6736
6751
|
var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
|
|
6737
6752
|
_loop_3(listItem, command);
|
|
@@ -6744,7 +6759,7 @@
|
|
|
6744
6759
|
}
|
|
6745
6760
|
finally { if (e_3) throw e_3.error; }
|
|
6746
6761
|
}
|
|
6747
|
-
// TODO: [🍧]
|
|
6762
|
+
// TODO: [🍧] Should be done in TEMPLATE command
|
|
6748
6763
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
6749
6764
|
if (!language) {
|
|
6750
6765
|
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 "); }));
|
|
@@ -6757,9 +6772,7 @@
|
|
|
6757
6772
|
}
|
|
6758
6773
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
6759
6774
|
/*
|
|
6760
|
-
// TODO: [🍧]
|
|
6761
|
-
// TODO: [🍧] !!!!!! Write error `.ptbk.md` file for `MODEL` and `PERSONA` command used in non-prompt template
|
|
6762
|
-
// TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
|
|
6775
|
+
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
6763
6776
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
6764
6777
|
throw new UnexpectedError(
|
|
6765
6778
|
spaceTrim(
|