@promptbook/core 0.68.0-1 → 0.68.0-3
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/README.md +2 -2
- package/esm/index.es.js +15 -15
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +1 -1
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +1 -1
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +2 -2
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +3 -3
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +9 -9
- package/esm/typings/src/types/PipelineString.d.ts +1 -1
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +15 -15
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -289,7 +289,7 @@ flowchart LR
|
|
|
289
289
|
end;
|
|
290
290
|
```
|
|
291
291
|
|
|
292
|
-
- [More template samples](./samples/
|
|
292
|
+
- [More template samples](./samples/pipelines/)
|
|
293
293
|
- [Read more about `.ptbk.md` file format here](https://github.com/webgptorg/promptbook/discussions/categories/concepts?discussions_q=is%3Aopen+label%3A.ptbk.md+category%3AConcepts)
|
|
294
294
|
|
|
295
295
|
_Note: We are using [postprocessing functions](#postprocessing-functions) like `unwrapResult` that can be used to postprocess the result._
|
|
@@ -406,7 +406,7 @@ If you have a question [start a discussion](https://github.com/webgptorg/promptb
|
|
|
406
406
|
|
|
407
407
|
### Why not just use the OpenAI SDK / Anthropic Claude SDK / ...?
|
|
408
408
|
|
|
409
|
-
Different levels of abstraction. OpenAI library is for direct use of OpenAI API. This library is for a higher level of abstraction. It
|
|
409
|
+
Different levels of abstraction. OpenAI library is for direct use of OpenAI API. This library is for a higher level of abstraction. It define pipelines that are independent of the underlying library, LLM model, or even LLM provider.
|
|
410
410
|
|
|
411
411
|
### How is it different from the Langchain library?
|
|
412
412
|
|
package/esm/index.es.js
CHANGED
|
@@ -10,7 +10,7 @@ import moment from 'moment';
|
|
|
10
10
|
/**
|
|
11
11
|
* The version of the Promptbook library
|
|
12
12
|
*/
|
|
13
|
-
var PROMPTBOOK_VERSION = '0.68.0-
|
|
13
|
+
var PROMPTBOOK_VERSION = '0.68.0-2';
|
|
14
14
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
15
15
|
|
|
16
16
|
/*! *****************************************************************************
|
|
@@ -1005,7 +1005,7 @@ function validatePipeline(pipeline) {
|
|
|
1005
1005
|
// Note: Testing that parameter is either input or result of some template
|
|
1006
1006
|
if (!parameter.isInput &&
|
|
1007
1007
|
!pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
|
|
1008
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n
|
|
1008
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of {").concat(parameter.name, "}\n 2) Add template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1009
1009
|
}
|
|
1010
1010
|
};
|
|
1011
1011
|
try {
|
|
@@ -1788,7 +1788,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1788
1788
|
});
|
|
1789
1789
|
}
|
|
1790
1790
|
|
|
1791
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-
|
|
1791
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-2",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{blockType:"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-2",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{blockType:"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-2",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{blockType:"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-2",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:[{blockType:"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"}];
|
|
1792
1792
|
|
|
1793
1793
|
var defaultDiacriticsRemovalMap = [
|
|
1794
1794
|
{
|
|
@@ -2366,7 +2366,7 @@ function extractVariables(script) {
|
|
|
2366
2366
|
*/
|
|
2367
2367
|
|
|
2368
2368
|
/**
|
|
2369
|
-
* Parses the
|
|
2369
|
+
* Parses the template and returns the set of all used parameters
|
|
2370
2370
|
*
|
|
2371
2371
|
* @param template the template with used parameters
|
|
2372
2372
|
* @returns the set of parameter names
|
|
@@ -3551,7 +3551,7 @@ function createPipelineExecutor(options) {
|
|
|
3551
3551
|
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3552
3552
|
}
|
|
3553
3553
|
if (!currentTemplate.contentLanguage) {
|
|
3554
|
-
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for
|
|
3554
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(currentTemplate.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3555
3555
|
}
|
|
3556
3556
|
// TODO: DRY [1]
|
|
3557
3557
|
scriptPipelineExecutionErrors = [];
|
|
@@ -4878,7 +4878,7 @@ var blockCommandParser = {
|
|
|
4878
4878
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4879
4879
|
// TODO: !!!!!! Test multiple / no block type
|
|
4880
4880
|
if ($templateJson.isBlockTypeSet === true) {
|
|
4881
|
-
throw new ParseError("Block type is already defined in the
|
|
4881
|
+
throw new ParseError(spaceTrim("\n Block type is already defined in the template.\n It can be defined only once.\n "));
|
|
4882
4882
|
}
|
|
4883
4883
|
$templateJson.isBlockTypeSet = true;
|
|
4884
4884
|
// TODO: !!!!!! Rearrange better - but at bottom and unwrap from function
|
|
@@ -5058,7 +5058,7 @@ var expectCommandParser = {
|
|
|
5058
5058
|
/**
|
|
5059
5059
|
* Description of the FORMAT command
|
|
5060
5060
|
*/
|
|
5061
|
-
description: spaceTrim("\n Expect command describes the desired output of the
|
|
5061
|
+
description: spaceTrim("\n Expect command describes the desired output of the template (after post-processing)\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
|
|
5062
5062
|
/**
|
|
5063
5063
|
* Link to discussion
|
|
5064
5064
|
*/
|
|
@@ -5293,7 +5293,7 @@ var formatCommandParser = {
|
|
|
5293
5293
|
/**
|
|
5294
5294
|
* Description of the FORMAT command
|
|
5295
5295
|
*/
|
|
5296
|
-
description: spaceTrim("\n Format command describes the desired output of the
|
|
5296
|
+
description: spaceTrim("\n Format command describes the desired output of the template (after post-processing)\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
|
|
5297
5297
|
/**
|
|
5298
5298
|
* Link to discussion
|
|
5299
5299
|
*/
|
|
@@ -5367,7 +5367,7 @@ var jokerCommandParser = {
|
|
|
5367
5367
|
/**
|
|
5368
5368
|
* Description of the JOKER command
|
|
5369
5369
|
*/
|
|
5370
|
-
description: "Joker parameter is used instead of executing the
|
|
5370
|
+
description: "Joker parameter is used instead of executing the template result if jokers value meets the expectations requirements",
|
|
5371
5371
|
/**
|
|
5372
5372
|
* Link to discussion
|
|
5373
5373
|
*/
|
|
@@ -5446,7 +5446,7 @@ var modelCommandParser = {
|
|
|
5446
5446
|
/**
|
|
5447
5447
|
* Description of the MODEL command
|
|
5448
5448
|
*/
|
|
5449
|
-
description: "Tells which
|
|
5449
|
+
description: "Tells which `modelRequirements` (for example which model) to use for the prompt template execution",
|
|
5450
5450
|
/**
|
|
5451
5451
|
* Link to discussion
|
|
5452
5452
|
*/
|
|
@@ -5578,7 +5578,7 @@ var parameterCommandParser = {
|
|
|
5578
5578
|
/**
|
|
5579
5579
|
* Description of the PARAMETER command
|
|
5580
5580
|
*/
|
|
5581
|
-
description: "Describes one parameter of the
|
|
5581
|
+
description: "Describes one parameter of the template",
|
|
5582
5582
|
/**
|
|
5583
5583
|
* Link to discussion
|
|
5584
5584
|
*/
|
|
@@ -6020,7 +6020,7 @@ var urlCommandParser = {
|
|
|
6020
6020
|
spaceTrim(
|
|
6021
6021
|
`
|
|
6022
6022
|
URL must not contain hash
|
|
6023
|
-
Hash is used for identification of the
|
|
6023
|
+
Hash is used for identification of the template in the pipeline
|
|
6024
6024
|
`,
|
|
6025
6025
|
),
|
|
6026
6026
|
);
|
|
@@ -6920,7 +6920,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6920
6920
|
}
|
|
6921
6921
|
var _loop_2 = function (section) {
|
|
6922
6922
|
var e_3, _d;
|
|
6923
|
-
// TODO: Parse
|
|
6923
|
+
// TODO: Parse template description (the content out of the codeblock and lists)
|
|
6924
6924
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
6925
6925
|
var _e = extractOneBlockFromMarkdown(section.content), language = _e.language, content = _e.content;
|
|
6926
6926
|
// TODO: [🎾][1] DRY description
|
|
@@ -7007,7 +7007,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7007
7007
|
// TODO: [🍧] !!!!!! Should be done in BLOCK command
|
|
7008
7008
|
if ($templateJson.blockType === 'SCRIPT_TEMPLATE') {
|
|
7009
7009
|
if (!language) {
|
|
7010
|
-
throw new ParseError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the
|
|
7010
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the SCRIPT TEMPLATE\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
7011
7011
|
}
|
|
7012
7012
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
7013
7013
|
throw new ParseError(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 "); }));
|
|
@@ -7026,7 +7026,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7026
7026
|
(block) => `
|
|
7027
7027
|
Model requirements are defined for the block type ${
|
|
7028
7028
|
$templateJson.blockType
|
|
7029
|
-
} which is not a
|
|
7029
|
+
} which is not a PROMPT TEMPLATE
|
|
7030
7030
|
|
|
7031
7031
|
This should be avoided by the \`modelCommandParser\`
|
|
7032
7032
|
|