@promptbook/cli 0.74.0-11 → 0.74.0-12
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 +3 -12
- package/esm/index.es.js +59 -57
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
- package/esm/typings/src/collection/collectionToJson.test.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
- package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +7 -7
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +6 -4
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +2 -2
- package/package.json +1 -1
- package/umd/index.umd.js +59 -57
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*
|
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
|
51
51
|
*/
|
|
52
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-
|
|
52
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-11';
|
|
53
53
|
/**
|
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
55
55
|
*/
|
|
@@ -728,13 +728,13 @@
|
|
|
728
728
|
/**
|
|
729
729
|
* Converts promptbook in JSON format to string format
|
|
730
730
|
*
|
|
731
|
-
* @param pipelineJson Promptbook in JSON format (.
|
|
732
|
-
* @returns Promptbook in string format (.
|
|
731
|
+
* @param pipelineJson Promptbook in JSON format (.book.json)
|
|
732
|
+
* @returns Promptbook in string format (.book.md)
|
|
733
733
|
* @public exported from `@promptbook/core`
|
|
734
734
|
*/
|
|
735
735
|
function pipelineJsonToString(pipelineJson) {
|
|
736
736
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
737
|
-
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl,
|
|
737
|
+
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
|
|
738
738
|
var pipelineString = "# ".concat(title);
|
|
739
739
|
if (description) {
|
|
740
740
|
pipelineString += '\n\n';
|
|
@@ -744,8 +744,10 @@
|
|
|
744
744
|
if (pipelineUrl) {
|
|
745
745
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
746
746
|
}
|
|
747
|
-
|
|
748
|
-
|
|
747
|
+
if (bookVersion !== "undefined") {
|
|
748
|
+
commands.push("BOOK VERSION ".concat(bookVersion));
|
|
749
|
+
}
|
|
750
|
+
// TODO: [main] !!!!!! This increase size of the bundle and is probbably not necessary
|
|
749
751
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
750
752
|
try {
|
|
751
753
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -925,7 +927,7 @@
|
|
|
925
927
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
926
928
|
* TODO: [🏛] Maybe make some markdown builder
|
|
927
929
|
* TODO: [🏛] Escape all
|
|
928
|
-
* TODO: [🧠] Should be in generated .
|
|
930
|
+
* TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
929
931
|
*/
|
|
930
932
|
|
|
931
933
|
/**
|
|
@@ -1563,7 +1565,7 @@
|
|
|
1563
1565
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
1564
1566
|
*/
|
|
1565
1567
|
|
|
1566
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
1568
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",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.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",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.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",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.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",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## Example\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.book.md"}];
|
|
1567
1569
|
|
|
1568
1570
|
/**
|
|
1569
1571
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1738,7 +1740,7 @@
|
|
|
1738
1740
|
if (!url.startsWith('https://')) {
|
|
1739
1741
|
return false;
|
|
1740
1742
|
}
|
|
1741
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.
|
|
1743
|
+
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
1742
1744
|
return false;
|
|
1743
1745
|
}
|
|
1744
1746
|
if (url.includes('#')) {
|
|
@@ -1807,9 +1809,9 @@
|
|
|
1807
1809
|
// <- Note: [🚲]
|
|
1808
1810
|
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1809
1811
|
}
|
|
1810
|
-
if (pipeline.
|
|
1812
|
+
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
1811
1813
|
// <- Note: [🚲]
|
|
1812
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.
|
|
1814
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1813
1815
|
}
|
|
1814
1816
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
1815
1817
|
if (!Array.isArray(pipeline.parameters)) {
|
|
@@ -3763,7 +3765,7 @@
|
|
|
3763
3765
|
promptTitle: template.title,
|
|
3764
3766
|
promptMessage: replaceParameters(template.description || '', parameters),
|
|
3765
3767
|
defaultValue: replaceParameters(preparedContent, parameters),
|
|
3766
|
-
// TODO: [🧠] !! Figure out how to define placeholder in .
|
|
3768
|
+
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
3767
3769
|
placeholder: undefined,
|
|
3768
3770
|
priority: priority,
|
|
3769
3771
|
}))];
|
|
@@ -4329,7 +4331,7 @@
|
|
|
4329
4331
|
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
4330
4332
|
title: preparedPipeline.title,
|
|
4331
4333
|
promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
4332
|
-
promptbookRequestedVersion: preparedPipeline.
|
|
4334
|
+
promptbookRequestedVersion: preparedPipeline.bookVersion,
|
|
4333
4335
|
description: preparedPipeline.description,
|
|
4334
4336
|
promptExecutions: [],
|
|
4335
4337
|
};
|
|
@@ -4678,7 +4680,7 @@
|
|
|
4678
4680
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
4679
4681
|
_b = createPipelineExecutor;
|
|
4680
4682
|
_c = {};
|
|
4681
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.
|
|
4683
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
|
|
4682
4684
|
case 1:
|
|
4683
4685
|
preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
|
|
4684
4686
|
_c.tools = tools,
|
|
@@ -5435,12 +5437,12 @@
|
|
|
5435
5437
|
*/
|
|
5436
5438
|
function clonePipeline(pipeline) {
|
|
5437
5439
|
// Note: Not using spread operator (...) because @@@
|
|
5438
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title,
|
|
5440
|
+
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
5439
5441
|
return {
|
|
5440
5442
|
pipelineUrl: pipelineUrl,
|
|
5441
5443
|
sourceFile: sourceFile,
|
|
5442
5444
|
title: title,
|
|
5443
|
-
|
|
5445
|
+
bookVersion: bookVersion,
|
|
5444
5446
|
description: description,
|
|
5445
5447
|
parameters: parameters,
|
|
5446
5448
|
templates: templates,
|
|
@@ -5652,7 +5654,7 @@
|
|
|
5652
5654
|
throw new ParseError("Source not valid");
|
|
5653
5655
|
}
|
|
5654
5656
|
if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
|
|
5655
|
-
throw new ParseError("Source cannot be outside of the .
|
|
5657
|
+
throw new ParseError("Source cannot be outside of the .book.md folder");
|
|
5656
5658
|
}
|
|
5657
5659
|
return {
|
|
5658
5660
|
type: 'KNOWLEDGE',
|
|
@@ -6302,7 +6304,7 @@
|
|
|
6302
6304
|
/**
|
|
6303
6305
|
* Parses the foreach command
|
|
6304
6306
|
*
|
|
6305
|
-
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.
|
|
6307
|
+
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
|
|
6306
6308
|
*
|
|
6307
6309
|
* @see `documentationUrl` for more details
|
|
6308
6310
|
* @private within the commands folder
|
|
@@ -6452,7 +6454,7 @@
|
|
|
6452
6454
|
},
|
|
6453
6455
|
};
|
|
6454
6456
|
/**
|
|
6455
|
-
* TODO: [🍭] Make .
|
|
6457
|
+
* TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
|
|
6456
6458
|
*/
|
|
6457
6459
|
|
|
6458
6460
|
/**
|
|
@@ -7086,7 +7088,7 @@
|
|
|
7086
7088
|
/**
|
|
7087
7089
|
* Description of the BOOK_VERSION command
|
|
7088
7090
|
*/
|
|
7089
|
-
description: "Which version of the Book language is the .
|
|
7091
|
+
description: "Which version of the Book language is the .book.md using",
|
|
7090
7092
|
/**
|
|
7091
7093
|
* Link to documentation
|
|
7092
7094
|
*/
|
|
@@ -7100,19 +7102,19 @@
|
|
|
7100
7102
|
*/
|
|
7101
7103
|
parse: function (input) {
|
|
7102
7104
|
var args = input.args;
|
|
7103
|
-
var
|
|
7104
|
-
if (
|
|
7105
|
+
var bookVersion = args.pop();
|
|
7106
|
+
if (bookVersion === undefined) {
|
|
7105
7107
|
throw new ParseError("Version is required");
|
|
7106
7108
|
}
|
|
7107
|
-
if (!isValidPromptbookVersion(
|
|
7108
|
-
throw new ParseError("Invalid Promptbook version \"".concat(
|
|
7109
|
+
if (!isValidPromptbookVersion(bookVersion)) {
|
|
7110
|
+
throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
|
|
7109
7111
|
}
|
|
7110
7112
|
if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
|
|
7111
7113
|
throw new ParseError("Can not have more than one Promptbook version");
|
|
7112
7114
|
}
|
|
7113
7115
|
return {
|
|
7114
7116
|
type: 'BOOK_VERSION',
|
|
7115
|
-
|
|
7117
|
+
bookVersion: bookVersion,
|
|
7116
7118
|
};
|
|
7117
7119
|
},
|
|
7118
7120
|
/**
|
|
@@ -7122,7 +7124,7 @@
|
|
|
7122
7124
|
*/
|
|
7123
7125
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7124
7126
|
// TODO: Warn if the version is overridden
|
|
7125
|
-
$pipelineJson.
|
|
7127
|
+
$pipelineJson.bookVersion = command.bookVersion;
|
|
7126
7128
|
},
|
|
7127
7129
|
/**
|
|
7128
7130
|
* Converts the BOOK_VERSION command back to string
|
|
@@ -7175,9 +7177,9 @@
|
|
|
7175
7177
|
* Example usages of the URL command
|
|
7176
7178
|
*/
|
|
7177
7179
|
examples: [
|
|
7178
|
-
'PIPELINE URL https://promptbook.studio/library/write-cv.
|
|
7179
|
-
'URL https://promptbook.studio/library/write-cv.
|
|
7180
|
-
'https://promptbook.studio/library/write-cv.
|
|
7180
|
+
'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
|
|
7181
|
+
'URL https://promptbook.studio/library/write-cv.book.md',
|
|
7182
|
+
'https://promptbook.studio/library/write-cv.book.md',
|
|
7181
7183
|
],
|
|
7182
7184
|
/**
|
|
7183
7185
|
* Parses the URL command
|
|
@@ -7378,7 +7380,7 @@
|
|
|
7378
7380
|
/**
|
|
7379
7381
|
* Parses the boilerplate command
|
|
7380
7382
|
*
|
|
7381
|
-
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.
|
|
7383
|
+
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
|
|
7382
7384
|
*
|
|
7383
7385
|
* @see `documentationUrl` for more details
|
|
7384
7386
|
* @private within the commands folder
|
|
@@ -7432,7 +7434,7 @@
|
|
|
7432
7434
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7433
7435
|
*/
|
|
7434
7436
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7435
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .
|
|
7437
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
7436
7438
|
},
|
|
7437
7439
|
/**
|
|
7438
7440
|
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
@@ -7440,7 +7442,7 @@
|
|
|
7440
7442
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
7441
7443
|
*/
|
|
7442
7444
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
7443
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .
|
|
7445
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
7444
7446
|
},
|
|
7445
7447
|
/**
|
|
7446
7448
|
* Converts the BOILERPLATE command back to string
|
|
@@ -7456,7 +7458,7 @@
|
|
|
7456
7458
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7457
7459
|
*/
|
|
7458
7460
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7459
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .
|
|
7461
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
7460
7462
|
},
|
|
7461
7463
|
/**
|
|
7462
7464
|
* Reads the BOILERPLATE command from the `TemplateJson`
|
|
@@ -7464,7 +7466,7 @@
|
|
|
7464
7466
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7465
7467
|
*/
|
|
7466
7468
|
takeFromTemplateJson: function ($templateJson) {
|
|
7467
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .
|
|
7469
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
7468
7470
|
},
|
|
7469
7471
|
};
|
|
7470
7472
|
|
|
@@ -7940,8 +7942,8 @@
|
|
|
7940
7942
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
7941
7943
|
* Note: This function acts as compilation process
|
|
7942
7944
|
*
|
|
7943
|
-
* @param pipelineString {Promptbook} in string markdown format (.
|
|
7944
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
7945
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
7946
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
7945
7947
|
* @throws {ParseError} if the promptbook string is not valid
|
|
7946
7948
|
* @public exported from `@promptbook/core`
|
|
7947
7949
|
*/
|
|
@@ -7950,7 +7952,7 @@
|
|
|
7950
7952
|
var $pipelineJson = {
|
|
7951
7953
|
title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
|
|
7952
7954
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
7953
|
-
|
|
7955
|
+
bookVersion: undefined /* <- Note: By default no explicit version */,
|
|
7954
7956
|
description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
|
|
7955
7957
|
parameters: [],
|
|
7956
7958
|
templates: [],
|
|
@@ -8333,10 +8335,10 @@
|
|
|
8333
8335
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
8334
8336
|
* Note: This function acts as compilation process
|
|
8335
8337
|
*
|
|
8336
|
-
* @param pipelineString {Promptbook} in string markdown format (.
|
|
8338
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
8337
8339
|
* @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
|
|
8338
8340
|
* @param options - Options and tools for the compilation
|
|
8339
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
8341
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
8340
8342
|
* @throws {ParseError} if the promptbook string is not valid
|
|
8341
8343
|
* @public exported from `@promptbook/core`
|
|
8342
8344
|
*/
|
|
@@ -9708,13 +9710,13 @@
|
|
|
9708
9710
|
return [4 /*yield*/, listAllFiles(path$1, isRecursive, tools.fs)];
|
|
9709
9711
|
case 1:
|
|
9710
9712
|
fileNames = _b.sent();
|
|
9711
|
-
// Note: First load all .
|
|
9712
|
-
// .
|
|
9713
|
+
// Note: First load all .book.json and then .book.md files
|
|
9714
|
+
// .book.json can be prepared so it is faster to load
|
|
9713
9715
|
fileNames.sort(function (a, b) {
|
|
9714
|
-
if (a.endsWith('.
|
|
9716
|
+
if (a.endsWith('.book.json') && b.endsWith('.book.md')) {
|
|
9715
9717
|
return -1;
|
|
9716
9718
|
}
|
|
9717
|
-
if (a.endsWith('.
|
|
9719
|
+
if (a.endsWith('.book.md') && b.endsWith('.book.json')) {
|
|
9718
9720
|
return 1;
|
|
9719
9721
|
}
|
|
9720
9722
|
return 0;
|
|
@@ -9731,7 +9733,7 @@
|
|
|
9731
9733
|
case 1:
|
|
9732
9734
|
_e.trys.push([1, 8, , 9]);
|
|
9733
9735
|
pipeline = null;
|
|
9734
|
-
if (!fileName.endsWith('.
|
|
9736
|
+
if (!fileName.endsWith('.book.md')) return [3 /*break*/, 4];
|
|
9735
9737
|
return [4 /*yield*/, promises.readFile(fileName, 'utf-8')];
|
|
9736
9738
|
case 2:
|
|
9737
9739
|
pipelineString = (_e.sent());
|
|
@@ -9743,7 +9745,7 @@
|
|
|
9743
9745
|
pipeline = __assign(__assign({}, pipeline), { sourceFile: sourceFile });
|
|
9744
9746
|
return [3 /*break*/, 7];
|
|
9745
9747
|
case 4:
|
|
9746
|
-
if (!fileName.endsWith('.
|
|
9748
|
+
if (!fileName.endsWith('.book.json')) return [3 /*break*/, 6];
|
|
9747
9749
|
_d = (_c = JSON).parse;
|
|
9748
9750
|
return [4 /*yield*/, promises.readFile(fileName, 'utf-8')];
|
|
9749
9751
|
case 5:
|
|
@@ -9911,7 +9913,7 @@
|
|
|
9911
9913
|
return pipelineJsonStringified;
|
|
9912
9914
|
}
|
|
9913
9915
|
/**
|
|
9914
|
-
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.
|
|
9916
|
+
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
|
|
9915
9917
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
9916
9918
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
9917
9919
|
* TODO: [🍙] Make some standard order of json properties
|
|
@@ -10641,7 +10643,7 @@
|
|
|
10641
10643
|
function initializePrettifyCommand(program) {
|
|
10642
10644
|
var _this = this;
|
|
10643
10645
|
var prettifyCommand = program.command('prettify');
|
|
10644
|
-
prettifyCommand.description(spaceTrim__default["default"]("\n Iterates over `.
|
|
10646
|
+
prettifyCommand.description(spaceTrim__default["default"]("\n Iterates over `.book.md` files and does multiple enhancing operations on them:\n\n 1) Adds Mermaid graph\n 2) Prettifies the markdown\n "));
|
|
10645
10647
|
prettifyCommand.argument('<filesGlob>',
|
|
10646
10648
|
// <- TODO: [🧟♂️] Unite path to promptbook collection argument
|
|
10647
10649
|
'Pipelines to prettify as glob pattern');
|
|
@@ -10665,7 +10667,7 @@
|
|
|
10665
10667
|
case 3:
|
|
10666
10668
|
if (!!filenames_1_1.done) return [3 /*break*/, 10];
|
|
10667
10669
|
filename = filenames_1_1.value;
|
|
10668
|
-
if (!filename.endsWith('.
|
|
10670
|
+
if (!filename.endsWith('.book.md') && isVerbose) {
|
|
10669
10671
|
console.info(colors__default["default"].gray("Skipping ".concat(filename)));
|
|
10670
10672
|
return [3 /*break*/, 9];
|
|
10671
10673
|
}
|
|
@@ -11064,7 +11066,7 @@
|
|
|
11064
11066
|
runCommand.description(spaceTrim__default["default"]("\n Runs a pipeline\n "));
|
|
11065
11067
|
// TODO: [🧅] DRY command arguments
|
|
11066
11068
|
runCommand.argument('<path>',
|
|
11067
|
-
// <- Note: [🧟♂️] This is NOT promptbook collection directory BUT direct path to .
|
|
11069
|
+
// <- Note: [🧟♂️] This is NOT promptbook collection directory BUT direct path to .book.md file
|
|
11068
11070
|
'Path to book file');
|
|
11069
11071
|
runCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
|
|
11070
11072
|
runCommand.option('-v, --verbose', "Is output verbose", false);
|
|
@@ -11096,7 +11098,7 @@
|
|
|
11096
11098
|
filePathRaw,
|
|
11097
11099
|
"".concat(filePathRaw, ".md"),
|
|
11098
11100
|
"".concat(filePathRaw, ".book.md"),
|
|
11099
|
-
"".concat(filePathRaw, ".
|
|
11101
|
+
"".concat(filePathRaw, ".book.md"),
|
|
11100
11102
|
];
|
|
11101
11103
|
_m.label = 1;
|
|
11102
11104
|
case 1:
|
|
@@ -11334,7 +11336,7 @@
|
|
|
11334
11336
|
function initializeTestCommand(program) {
|
|
11335
11337
|
var _this = this;
|
|
11336
11338
|
var testCommand = program.command('test');
|
|
11337
|
-
testCommand.description(spaceTrim__default["default"]("\n Iterates over `.
|
|
11339
|
+
testCommand.description(spaceTrim__default["default"]("\n Iterates over `.book.md` and `.book.json` and checks if they are parsable and logically valid\n "));
|
|
11338
11340
|
testCommand.argument('<filesGlob>',
|
|
11339
11341
|
// <- TODO: [🧟♂️] Unite path to promptbook collection argument
|
|
11340
11342
|
'Pipelines to test as glob pattern');
|
|
@@ -11384,7 +11386,7 @@
|
|
|
11384
11386
|
case 6:
|
|
11385
11387
|
_f.trys.push([6, 13, , 14]);
|
|
11386
11388
|
pipeline = void 0;
|
|
11387
|
-
if (!filename.endsWith('.
|
|
11389
|
+
if (!filename.endsWith('.book.md')) return [3 /*break*/, 9];
|
|
11388
11390
|
return [4 /*yield*/, promises.readFile(filename, 'utf-8')];
|
|
11389
11391
|
case 7:
|
|
11390
11392
|
pipelineMarkdown = (_f.sent());
|
|
@@ -11396,7 +11398,7 @@
|
|
|
11396
11398
|
}
|
|
11397
11399
|
_f.label = 9;
|
|
11398
11400
|
case 9:
|
|
11399
|
-
if (!filename.endsWith('.
|
|
11401
|
+
if (!filename.endsWith('.book.json')) return [3 /*break*/, 11];
|
|
11400
11402
|
_c = (_b = JSON).parse;
|
|
11401
11403
|
return [4 /*yield*/, promises.readFile(filename, 'utf-8')];
|
|
11402
11404
|
case 10:
|
|
@@ -11483,7 +11485,7 @@
|
|
|
11483
11485
|
});
|
|
11484
11486
|
}
|
|
11485
11487
|
/**
|
|
11486
|
-
* TODO: [🧠] Maybe `run` command the default, instead of `ptbk run ./foo.
|
|
11488
|
+
* TODO: [🧠] Maybe `run` command the default, instead of `ptbk run ./foo.book.md` -> `ptbk ./foo.book.md`
|
|
11487
11489
|
* TODO: [🥠] Do not export, its just for CLI script
|
|
11488
11490
|
* TODO: [🕌] When more functionalities, rename
|
|
11489
11491
|
* Note: 11:11
|
|
@@ -14051,7 +14053,7 @@
|
|
|
14051
14053
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
14052
14054
|
_d = createPipelineExecutor;
|
|
14053
14055
|
_g = {};
|
|
14054
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
14056
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
|
|
14055
14057
|
case 1:
|
|
14056
14058
|
prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
|
|
14057
14059
|
_g.tools = {
|
|
@@ -14060,7 +14062,7 @@
|
|
|
14060
14062
|
_g)]);
|
|
14061
14063
|
_e = createPipelineExecutor;
|
|
14062
14064
|
_h = {};
|
|
14063
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.
|
|
14065
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
|
|
14064
14066
|
case 2:
|
|
14065
14067
|
prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
|
|
14066
14068
|
_h.tools = {
|
|
@@ -14069,7 +14071,7 @@
|
|
|
14069
14071
|
_h)]);
|
|
14070
14072
|
_f = createPipelineExecutor;
|
|
14071
14073
|
_j = {};
|
|
14072
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.
|
|
14074
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
|
|
14073
14075
|
case 3:
|
|
14074
14076
|
prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
|
|
14075
14077
|
_j.tools = {
|