@promptbook/cli 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
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/**
|
|
40
40
|
* The version of the Promptbook library
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_VERSION = '0.68.0-
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.68.0-4';
|
|
43
43
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -1059,7 +1059,7 @@
|
|
|
1059
1059
|
});
|
|
1060
1060
|
}
|
|
1061
1061
|
|
|
1062
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-
|
|
1062
|
+
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"}];
|
|
1063
1063
|
|
|
1064
1064
|
/**
|
|
1065
1065
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -4752,12 +4752,11 @@
|
|
|
4752
4752
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
4753
4753
|
*/
|
|
4754
4754
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4755
|
-
// TODO: !!!!!! Test multiple / no template type
|
|
4756
4755
|
if ($templateJson.isTemplateTypeSet === true) {
|
|
4757
4756
|
throw new ParseError(spaceTrim__default["default"]("\n Template type is already defined in the template.\n It can be defined only once.\n "));
|
|
4758
4757
|
}
|
|
4759
4758
|
$templateJson.isTemplateTypeSet = true;
|
|
4760
|
-
// TODO:
|
|
4759
|
+
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
4761
4760
|
var expectResultingParameterName = function () {
|
|
4762
4761
|
if ($templateJson.resultingParameterName) {
|
|
4763
4762
|
return;
|
|
@@ -4798,12 +4797,6 @@
|
|
|
4798
4797
|
}
|
|
4799
4798
|
expectResultingParameterName();
|
|
4800
4799
|
$templateJson.templateType = command.templateType;
|
|
4801
|
-
/*
|
|
4802
|
-
TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
|
|
4803
|
-
if (command.templateType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
|
|
4804
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
4805
|
-
}
|
|
4806
|
-
*/
|
|
4807
4800
|
$templateJson.isTemplate = true;
|
|
4808
4801
|
},
|
|
4809
4802
|
/**
|
|
@@ -4826,7 +4819,15 @@
|
|
|
4826
4819
|
},
|
|
4827
4820
|
};
|
|
4828
4821
|
/**
|
|
4829
|
-
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands
|
|
4822
|
+
* Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
|
|
4823
|
+
* 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
|
|
4824
|
+
* - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4825
|
+
* 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
|
|
4826
|
+
* - KNOWLEDGE TEMPLATE
|
|
4827
|
+
*
|
|
4828
|
+
* ```
|
|
4829
|
+
* Look at https://en.wikipedia.org/wiki/Artificial_intelligence
|
|
4830
|
+
* ```
|
|
4830
4831
|
*/
|
|
4831
4832
|
|
|
4832
4833
|
/**
|
|
@@ -5374,8 +5375,16 @@
|
|
|
5374
5375
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
5375
5376
|
*/
|
|
5376
5377
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5377
|
-
// TODO: !!!!!! Error on redefine
|
|
5378
5378
|
$pipelineJson.defaultModelRequirements = $pipelineJson.defaultModelRequirements || {};
|
|
5379
|
+
// TODO: [🚜] DRY
|
|
5380
|
+
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
5381
|
+
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
5382
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
5383
|
+
}
|
|
5384
|
+
else {
|
|
5385
|
+
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 ")));
|
|
5386
|
+
}
|
|
5387
|
+
}
|
|
5379
5388
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
5380
5389
|
},
|
|
5381
5390
|
/**
|
|
@@ -5383,13 +5392,23 @@
|
|
|
5383
5392
|
*
|
|
5384
5393
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5385
5394
|
*/
|
|
5386
|
-
$applyToTemplateJson: function (command, $templateJson) {
|
|
5395
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5387
5396
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
|
|
5388
5397
|
throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
|
|
5389
5398
|
}
|
|
5390
|
-
// TODO: !!!!!! Error on redefine
|
|
5391
|
-
// TODO: Warn if setting same as default in `$pipelineJson`
|
|
5392
5399
|
$templateJson.modelRequirements = $templateJson.modelRequirements || {};
|
|
5400
|
+
// TODO: [🚜] DRY
|
|
5401
|
+
if ($templateJson.modelRequirements[command.key] !== undefined) {
|
|
5402
|
+
if ($templateJson.modelRequirements[command.key] === command.value) {
|
|
5403
|
+
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the template \"").concat($templateJson.title || $templateJson.name, "\""));
|
|
5404
|
+
}
|
|
5405
|
+
else {
|
|
5406
|
+
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 ")));
|
|
5407
|
+
}
|
|
5408
|
+
}
|
|
5409
|
+
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
5410
|
+
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 ")));
|
|
5411
|
+
}
|
|
5393
5412
|
$templateJson.modelRequirements[command.key] = command.value;
|
|
5394
5413
|
},
|
|
5395
5414
|
/**
|
|
@@ -6166,9 +6185,6 @@
|
|
|
6166
6185
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
6167
6186
|
},
|
|
6168
6187
|
};
|
|
6169
|
-
/**
|
|
6170
|
-
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
6171
|
-
*/
|
|
6172
6188
|
|
|
6173
6189
|
/**
|
|
6174
6190
|
* All available command parsers
|
|
@@ -6191,6 +6207,7 @@
|
|
|
6191
6207
|
personaCommandParser,
|
|
6192
6208
|
foreachCommandParser,
|
|
6193
6209
|
boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
|
|
6210
|
+
// <- 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
|
|
6194
6211
|
];
|
|
6195
6212
|
|
|
6196
6213
|
/**
|
|
@@ -6877,9 +6894,7 @@
|
|
|
6877
6894
|
}
|
|
6878
6895
|
};
|
|
6879
6896
|
try {
|
|
6880
|
-
// TODO
|
|
6881
|
-
// TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE TEMPLATE`
|
|
6882
|
-
// TODO [♓️] List commands and before apply order them
|
|
6897
|
+
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
6883
6898
|
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()) {
|
|
6884
6899
|
var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
|
|
6885
6900
|
_loop_3(listItem, command);
|
|
@@ -6892,7 +6907,7 @@
|
|
|
6892
6907
|
}
|
|
6893
6908
|
finally { if (e_3) throw e_3.error; }
|
|
6894
6909
|
}
|
|
6895
|
-
// TODO: [🍧]
|
|
6910
|
+
// TODO: [🍧] Should be done in TEMPLATE command
|
|
6896
6911
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
6897
6912
|
if (!language) {
|
|
6898
6913
|
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 "); }));
|
|
@@ -6905,9 +6920,7 @@
|
|
|
6905
6920
|
}
|
|
6906
6921
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
6907
6922
|
/*
|
|
6908
|
-
// TODO: [🍧]
|
|
6909
|
-
// TODO: [🍧] !!!!!! Write error `.ptbk.md` file for `MODEL` and `PERSONA` command used in non-prompt template
|
|
6910
|
-
// TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
|
|
6923
|
+
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
6911
6924
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
6912
6925
|
throw new UnexpectedError(
|
|
6913
6926
|
spaceTrim(
|