@promptbook/core 0.74.0-7 → 0.74.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/README.md +3 -15
- package/esm/index.es.js +213 -73
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +5 -1
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
- package/esm/typings/src/cli/main.d.ts +4 -1
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
- package/esm/typings/src/cli/test/ptbk.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/config.d.ts +6 -0
- 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/storage/blackhole/BlackholeStorage.d.ts +33 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
- package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.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/esm/typings/src/utils/expectation-counters/config.d.ts +12 -0
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
- package/package.json +1 -1
- package/umd/index.umd.js +214 -72
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
22
22
|
*
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
*/
|
|
@@ -219,13 +219,13 @@ function capitalize(word) {
|
|
|
219
219
|
/**
|
|
220
220
|
* Converts promptbook in JSON format to string format
|
|
221
221
|
*
|
|
222
|
-
* @param pipelineJson Promptbook in JSON format (.
|
|
223
|
-
* @returns Promptbook in string format (.
|
|
222
|
+
* @param pipelineJson Promptbook in JSON format (.book.json)
|
|
223
|
+
* @returns Promptbook in string format (.book.md)
|
|
224
224
|
* @public exported from `@promptbook/core`
|
|
225
225
|
*/
|
|
226
226
|
function pipelineJsonToString(pipelineJson) {
|
|
227
227
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
228
|
-
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl,
|
|
228
|
+
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
|
|
229
229
|
var pipelineString = "# ".concat(title);
|
|
230
230
|
if (description) {
|
|
231
231
|
pipelineString += '\n\n';
|
|
@@ -235,8 +235,10 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
235
235
|
if (pipelineUrl) {
|
|
236
236
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
if (bookVersion !== "undefined") {
|
|
239
|
+
commands.push("BOOK VERSION ".concat(bookVersion));
|
|
240
|
+
}
|
|
241
|
+
// TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
|
|
240
242
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
241
243
|
try {
|
|
242
244
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -416,7 +418,7 @@ function templateParameterJsonToString(templateParameterJson) {
|
|
|
416
418
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
417
419
|
* TODO: [🏛] Maybe make some markdown builder
|
|
418
420
|
* TODO: [🏛] Escape all
|
|
419
|
-
* TODO: [🧠] Should be in generated .
|
|
421
|
+
* TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
420
422
|
*/
|
|
421
423
|
|
|
422
424
|
/**
|
|
@@ -646,6 +648,13 @@ var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so t
|
|
|
646
648
|
* @public exported from `@promptbook/core`
|
|
647
649
|
*/
|
|
648
650
|
var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
|
|
651
|
+
// <- TODO: [🐊] Pick the best claim
|
|
652
|
+
/**
|
|
653
|
+
* When the title is not provided, the default title is used
|
|
654
|
+
*
|
|
655
|
+
* @public exported from `@promptbook/core`
|
|
656
|
+
*/
|
|
657
|
+
var DEFAULT_TITLE = "Untitled";
|
|
649
658
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
650
659
|
/**
|
|
651
660
|
* The maximum number of iterations for a loops
|
|
@@ -985,7 +994,7 @@ function isValidPipelineUrl(url) {
|
|
|
985
994
|
if (!url.startsWith('https://')) {
|
|
986
995
|
return false;
|
|
987
996
|
}
|
|
988
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.
|
|
997
|
+
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
989
998
|
return false;
|
|
990
999
|
}
|
|
991
1000
|
if (url.includes('#')) {
|
|
@@ -1054,9 +1063,9 @@ function validatePipelineCore(pipeline) {
|
|
|
1054
1063
|
// <- Note: [🚲]
|
|
1055
1064
|
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1056
1065
|
}
|
|
1057
|
-
if (pipeline.
|
|
1066
|
+
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
1058
1067
|
// <- Note: [🚲]
|
|
1059
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.
|
|
1068
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1060
1069
|
}
|
|
1061
1070
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
1062
1071
|
if (!Array.isArray(pipeline.parameters)) {
|
|
@@ -2303,7 +2312,7 @@ function joinLlmExecutionTools() {
|
|
|
2303
2312
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2304
2313
|
*/
|
|
2305
2314
|
|
|
2306
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
2315
|
+
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"}];
|
|
2307
2316
|
|
|
2308
2317
|
/**
|
|
2309
2318
|
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
@@ -3306,28 +3315,42 @@ function countCharacters(text) {
|
|
|
3306
3315
|
return text.length;
|
|
3307
3316
|
}
|
|
3308
3317
|
|
|
3318
|
+
/**
|
|
3319
|
+
* Number of characters per standard line with 11pt Arial font size.
|
|
3320
|
+
*
|
|
3321
|
+
* @public exported from `@promptbook/utils`
|
|
3322
|
+
*/
|
|
3323
|
+
var CHARACTERS_PER_STANDARD_LINE = 63;
|
|
3324
|
+
/**
|
|
3325
|
+
* Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
|
|
3326
|
+
*
|
|
3327
|
+
* @public exported from `@promptbook/utils`
|
|
3328
|
+
*/
|
|
3329
|
+
var LINES_PER_STANDARD_PAGE = 44;
|
|
3330
|
+
|
|
3309
3331
|
/**
|
|
3310
3332
|
* Counts number of lines in the text
|
|
3311
3333
|
*
|
|
3334
|
+
* Note: This does not check only for the presence of newlines, but also for the length of the standard line.
|
|
3335
|
+
*
|
|
3312
3336
|
* @public exported from `@promptbook/utils`
|
|
3313
3337
|
*/
|
|
3314
3338
|
function countLines(text) {
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
return
|
|
3339
|
+
text = text.replace('\r\n', '\n');
|
|
3340
|
+
text = text.replace('\r', '\n');
|
|
3341
|
+
var lines = text.split('\n');
|
|
3342
|
+
return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
|
|
3319
3343
|
}
|
|
3320
3344
|
|
|
3321
3345
|
/**
|
|
3322
3346
|
* Counts number of pages in the text
|
|
3323
3347
|
*
|
|
3348
|
+
* Note: This does not check only for the count of newlines, but also for the length of the standard line and length of the standard page.
|
|
3349
|
+
*
|
|
3324
3350
|
* @public exported from `@promptbook/utils`
|
|
3325
3351
|
*/
|
|
3326
3352
|
function countPages(text) {
|
|
3327
|
-
|
|
3328
|
-
var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
3329
|
-
var pageCount = Math.ceil(sentences.length / sentencesPerPage);
|
|
3330
|
-
return pageCount;
|
|
3353
|
+
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
3331
3354
|
}
|
|
3332
3355
|
|
|
3333
3356
|
/**
|
|
@@ -3890,7 +3913,7 @@ function executeAttempts(options) {
|
|
|
3890
3913
|
promptTitle: template.title,
|
|
3891
3914
|
promptMessage: replaceParameters(template.description || '', parameters),
|
|
3892
3915
|
defaultValue: replaceParameters(preparedContent, parameters),
|
|
3893
|
-
// TODO: [🧠] !! Figure out how to define placeholder in .
|
|
3916
|
+
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
3894
3917
|
placeholder: undefined,
|
|
3895
3918
|
priority: priority,
|
|
3896
3919
|
}))];
|
|
@@ -4456,7 +4479,7 @@ function executePipeline(options) {
|
|
|
4456
4479
|
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
4457
4480
|
title: preparedPipeline.title,
|
|
4458
4481
|
promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
4459
|
-
promptbookRequestedVersion: preparedPipeline.
|
|
4482
|
+
promptbookRequestedVersion: preparedPipeline.bookVersion,
|
|
4460
4483
|
description: preparedPipeline.description,
|
|
4461
4484
|
promptExecutions: [],
|
|
4462
4485
|
};
|
|
@@ -4805,7 +4828,7 @@ function preparePersona(personaDescription, tools, options) {
|
|
|
4805
4828
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
4806
4829
|
_b = createPipelineExecutor;
|
|
4807
4830
|
_c = {};
|
|
4808
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.
|
|
4831
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
|
|
4809
4832
|
case 1:
|
|
4810
4833
|
preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
|
|
4811
4834
|
_c.tools = tools,
|
|
@@ -5562,12 +5585,12 @@ TODO: [🧊] This is how it can look in future
|
|
|
5562
5585
|
*/
|
|
5563
5586
|
function clonePipeline(pipeline) {
|
|
5564
5587
|
// Note: Not using spread operator (...) because @@@
|
|
5565
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title,
|
|
5588
|
+
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;
|
|
5566
5589
|
return {
|
|
5567
5590
|
pipelineUrl: pipelineUrl,
|
|
5568
5591
|
sourceFile: sourceFile,
|
|
5569
5592
|
title: title,
|
|
5570
|
-
|
|
5593
|
+
bookVersion: bookVersion,
|
|
5571
5594
|
description: description,
|
|
5572
5595
|
parameters: parameters,
|
|
5573
5596
|
templates: templates,
|
|
@@ -5779,7 +5802,7 @@ var knowledgeCommandParser = {
|
|
|
5779
5802
|
throw new ParseError("Source not valid");
|
|
5780
5803
|
}
|
|
5781
5804
|
if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
|
|
5782
|
-
throw new ParseError("Source cannot be outside of the .
|
|
5805
|
+
throw new ParseError("Source cannot be outside of the .book.md folder");
|
|
5783
5806
|
}
|
|
5784
5807
|
return {
|
|
5785
5808
|
type: 'KNOWLEDGE',
|
|
@@ -6411,7 +6434,7 @@ function validateParameterName(parameterName) {
|
|
|
6411
6434
|
/**
|
|
6412
6435
|
* Parses the foreach command
|
|
6413
6436
|
*
|
|
6414
|
-
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.
|
|
6437
|
+
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
|
|
6415
6438
|
*
|
|
6416
6439
|
* @see `documentationUrl` for more details
|
|
6417
6440
|
* @private within the commands folder
|
|
@@ -6561,7 +6584,7 @@ var foreachCommandParser = {
|
|
|
6561
6584
|
},
|
|
6562
6585
|
};
|
|
6563
6586
|
/**
|
|
6564
|
-
* TODO: [🍭] Make .
|
|
6587
|
+
* TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
|
|
6565
6588
|
*/
|
|
6566
6589
|
|
|
6567
6590
|
/**
|
|
@@ -7195,7 +7218,7 @@ var bookVersionCommandParser = {
|
|
|
7195
7218
|
/**
|
|
7196
7219
|
* Description of the BOOK_VERSION command
|
|
7197
7220
|
*/
|
|
7198
|
-
description: "Which version of the Book language is the .
|
|
7221
|
+
description: "Which version of the Book language is the .book.md using",
|
|
7199
7222
|
/**
|
|
7200
7223
|
* Link to documentation
|
|
7201
7224
|
*/
|
|
@@ -7209,19 +7232,19 @@ var bookVersionCommandParser = {
|
|
|
7209
7232
|
*/
|
|
7210
7233
|
parse: function (input) {
|
|
7211
7234
|
var args = input.args;
|
|
7212
|
-
var
|
|
7213
|
-
if (
|
|
7235
|
+
var bookVersion = args.pop();
|
|
7236
|
+
if (bookVersion === undefined) {
|
|
7214
7237
|
throw new ParseError("Version is required");
|
|
7215
7238
|
}
|
|
7216
|
-
if (!isValidPromptbookVersion(
|
|
7217
|
-
throw new ParseError("Invalid Promptbook version \"".concat(
|
|
7239
|
+
if (!isValidPromptbookVersion(bookVersion)) {
|
|
7240
|
+
throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
|
|
7218
7241
|
}
|
|
7219
7242
|
if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
|
|
7220
7243
|
throw new ParseError("Can not have more than one Promptbook version");
|
|
7221
7244
|
}
|
|
7222
7245
|
return {
|
|
7223
7246
|
type: 'BOOK_VERSION',
|
|
7224
|
-
|
|
7247
|
+
bookVersion: bookVersion,
|
|
7225
7248
|
};
|
|
7226
7249
|
},
|
|
7227
7250
|
/**
|
|
@@ -7231,7 +7254,7 @@ var bookVersionCommandParser = {
|
|
|
7231
7254
|
*/
|
|
7232
7255
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7233
7256
|
// TODO: Warn if the version is overridden
|
|
7234
|
-
$pipelineJson.
|
|
7257
|
+
$pipelineJson.bookVersion = command.bookVersion;
|
|
7235
7258
|
},
|
|
7236
7259
|
/**
|
|
7237
7260
|
* Converts the BOOK_VERSION command back to string
|
|
@@ -7284,9 +7307,9 @@ var urlCommandParser = {
|
|
|
7284
7307
|
* Example usages of the URL command
|
|
7285
7308
|
*/
|
|
7286
7309
|
examples: [
|
|
7287
|
-
'PIPELINE URL https://promptbook.studio/library/write-cv.
|
|
7288
|
-
'URL https://promptbook.studio/library/write-cv.
|
|
7289
|
-
'https://promptbook.studio/library/write-cv.
|
|
7310
|
+
'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
|
|
7311
|
+
'URL https://promptbook.studio/library/write-cv.book.md',
|
|
7312
|
+
'https://promptbook.studio/library/write-cv.book.md',
|
|
7290
7313
|
],
|
|
7291
7314
|
/**
|
|
7292
7315
|
* Parses the URL command
|
|
@@ -7487,7 +7510,7 @@ var instrumentCommandParser = {
|
|
|
7487
7510
|
/**
|
|
7488
7511
|
* Parses the boilerplate command
|
|
7489
7512
|
*
|
|
7490
|
-
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.
|
|
7513
|
+
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
|
|
7491
7514
|
*
|
|
7492
7515
|
* @see `documentationUrl` for more details
|
|
7493
7516
|
* @private within the commands folder
|
|
@@ -7541,7 +7564,7 @@ var boilerplateCommandParser = {
|
|
|
7541
7564
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7542
7565
|
*/
|
|
7543
7566
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7544
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .
|
|
7567
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
7545
7568
|
},
|
|
7546
7569
|
/**
|
|
7547
7570
|
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
@@ -7549,7 +7572,7 @@ var boilerplateCommandParser = {
|
|
|
7549
7572
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
7550
7573
|
*/
|
|
7551
7574
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
7552
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .
|
|
7575
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
7553
7576
|
},
|
|
7554
7577
|
/**
|
|
7555
7578
|
* Converts the BOILERPLATE command back to string
|
|
@@ -7565,7 +7588,7 @@ var boilerplateCommandParser = {
|
|
|
7565
7588
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7566
7589
|
*/
|
|
7567
7590
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7568
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .
|
|
7591
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
7569
7592
|
},
|
|
7570
7593
|
/**
|
|
7571
7594
|
* Reads the BOILERPLATE command from the `TemplateJson`
|
|
@@ -7573,7 +7596,7 @@ var boilerplateCommandParser = {
|
|
|
7573
7596
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7574
7597
|
*/
|
|
7575
7598
|
takeFromTemplateJson: function ($templateJson) {
|
|
7576
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .
|
|
7599
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
7577
7600
|
},
|
|
7578
7601
|
};
|
|
7579
7602
|
|
|
@@ -7902,7 +7925,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
7902
7925
|
return;
|
|
7903
7926
|
}
|
|
7904
7927
|
if (!section.startsWith('#')) {
|
|
7905
|
-
section = "#
|
|
7928
|
+
section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
|
|
7906
7929
|
}
|
|
7907
7930
|
sections.push(section);
|
|
7908
7931
|
buffer = [];
|
|
@@ -7966,7 +7989,7 @@ function flattenMarkdown(markdown) {
|
|
|
7966
7989
|
var e_1, _a;
|
|
7967
7990
|
var sections = splitMarkdownIntoSections(markdown);
|
|
7968
7991
|
if (sections.length === 0) {
|
|
7969
|
-
return
|
|
7992
|
+
return "# ".concat(DEFAULT_TITLE);
|
|
7970
7993
|
}
|
|
7971
7994
|
var flattenedMarkdown = '';
|
|
7972
7995
|
var parsedSections = sections.map(parseMarkdownSection);
|
|
@@ -7977,7 +8000,7 @@ function flattenMarkdown(markdown) {
|
|
|
7977
8000
|
}
|
|
7978
8001
|
else {
|
|
7979
8002
|
parsedSections.unshift(firstSection);
|
|
7980
|
-
flattenedMarkdown += "#
|
|
8003
|
+
flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
|
|
7981
8004
|
}
|
|
7982
8005
|
try {
|
|
7983
8006
|
for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
|
|
@@ -8049,17 +8072,17 @@ function titleToName(value) {
|
|
|
8049
8072
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
8050
8073
|
* Note: This function acts as compilation process
|
|
8051
8074
|
*
|
|
8052
|
-
* @param pipelineString {Promptbook} in string markdown format (.
|
|
8053
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
8075
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
8076
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
8054
8077
|
* @throws {ParseError} if the promptbook string is not valid
|
|
8055
8078
|
* @public exported from `@promptbook/core`
|
|
8056
8079
|
*/
|
|
8057
8080
|
function pipelineStringToJsonSync(pipelineString) {
|
|
8058
|
-
var e_1, _a, e_2, _b;
|
|
8081
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
8059
8082
|
var $pipelineJson = {
|
|
8060
8083
|
title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
|
|
8061
8084
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
8062
|
-
|
|
8085
|
+
bookVersion: undefined /* <- Note: By default no explicit version */,
|
|
8063
8086
|
description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
|
|
8064
8087
|
parameters: [],
|
|
8065
8088
|
templates: [],
|
|
@@ -8083,7 +8106,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8083
8106
|
// =============================================================
|
|
8084
8107
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
8085
8108
|
if (pipelineString.startsWith('#!')) {
|
|
8086
|
-
var
|
|
8109
|
+
var _e = __read(pipelineString.split('\n')), shebangLine_1 = _e[0], restLines = _e.slice(1);
|
|
8087
8110
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
8088
8111
|
throw new ParseError(spaceTrim$1(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
8089
8112
|
}
|
|
@@ -8093,7 +8116,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8093
8116
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
8094
8117
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
8095
8118
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
8096
|
-
var
|
|
8119
|
+
var _f = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _f[0], pipelineSections = _f.slice(1); /* <- Note: [🥞] */
|
|
8097
8120
|
if (pipelineHead === undefined) {
|
|
8098
8121
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8099
8122
|
}
|
|
@@ -8121,6 +8144,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8121
8144
|
if (parameterDescription) {
|
|
8122
8145
|
existingParameter.description = parameterDescription;
|
|
8123
8146
|
}
|
|
8147
|
+
existingParameter.isInput = existingParameter.isInput || isInput;
|
|
8148
|
+
existingParameter.isOutput = existingParameter.isOutput || isOutput;
|
|
8124
8149
|
}
|
|
8125
8150
|
else {
|
|
8126
8151
|
$pipelineJson.parameters.push({
|
|
@@ -8183,10 +8208,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8183
8208
|
finally { if (e_1) throw e_1.error; }
|
|
8184
8209
|
}
|
|
8185
8210
|
var _loop_2 = function (section) {
|
|
8186
|
-
var
|
|
8211
|
+
var e_5, _l, e_6, _m;
|
|
8187
8212
|
// TODO: Parse template description (the content out of the codeblock and lists)
|
|
8188
8213
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
8189
|
-
var
|
|
8214
|
+
var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
|
|
8190
8215
|
// TODO: [🎾][1] DRY description
|
|
8191
8216
|
var description_1 = section.content;
|
|
8192
8217
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -8227,7 +8252,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8227
8252
|
}) === false) {
|
|
8228
8253
|
templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
|
|
8229
8254
|
}
|
|
8230
|
-
var
|
|
8255
|
+
var _loop_4 = function (listItem, command) {
|
|
8231
8256
|
var commandParser = getParserForCommand(command);
|
|
8232
8257
|
if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
|
|
8233
8258
|
throw new ParseError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " is not allowed in the template of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
@@ -8250,17 +8275,17 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8250
8275
|
};
|
|
8251
8276
|
try {
|
|
8252
8277
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
8253
|
-
for (var commands_1 = (
|
|
8254
|
-
var
|
|
8255
|
-
|
|
8278
|
+
for (var commands_1 = (e_5 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
8279
|
+
var _p = commands_1_1.value, listItem = _p.listItem, command = _p.command;
|
|
8280
|
+
_loop_4(listItem, command);
|
|
8256
8281
|
}
|
|
8257
8282
|
}
|
|
8258
|
-
catch (
|
|
8283
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
8259
8284
|
finally {
|
|
8260
8285
|
try {
|
|
8261
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
8286
|
+
if (commands_1_1 && !commands_1_1.done && (_l = commands_1.return)) _l.call(commands_1);
|
|
8262
8287
|
}
|
|
8263
|
-
finally { if (
|
|
8288
|
+
finally { if (e_5) throw e_5.error; }
|
|
8264
8289
|
}
|
|
8265
8290
|
// TODO: [🍧] Should be done in TEMPLATE command
|
|
8266
8291
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
@@ -8274,6 +8299,26 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8274
8299
|
language;
|
|
8275
8300
|
}
|
|
8276
8301
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
8302
|
+
try {
|
|
8303
|
+
for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
8304
|
+
var parameterName = _r.value;
|
|
8305
|
+
// TODO: [🧠] This definition should be made first in the template
|
|
8306
|
+
defineParam({
|
|
8307
|
+
parameterName: parameterName,
|
|
8308
|
+
parameterDescription: null,
|
|
8309
|
+
isInput: false,
|
|
8310
|
+
isOutput: false,
|
|
8311
|
+
// <- Note: In this case null+false+false means that we do not know yet if it is input or output and we will set it later
|
|
8312
|
+
});
|
|
8313
|
+
}
|
|
8314
|
+
}
|
|
8315
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
8316
|
+
finally {
|
|
8317
|
+
try {
|
|
8318
|
+
if (_r && !_r.done && (_m = _q.return)) _m.call(_q);
|
|
8319
|
+
}
|
|
8320
|
+
finally { if (e_6) throw e_6.error; }
|
|
8321
|
+
}
|
|
8277
8322
|
/*
|
|
8278
8323
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
8279
8324
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
@@ -8315,9 +8360,51 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8315
8360
|
finally { if (e_2) throw e_2.error; }
|
|
8316
8361
|
}
|
|
8317
8362
|
// =============================================================
|
|
8318
|
-
// Note: 5️⃣
|
|
8363
|
+
// Note: 5️⃣ Mark parameters as INPUT if not explicitly set
|
|
8364
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
8365
|
+
var _loop_3 = function (parameter) {
|
|
8366
|
+
var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
|
|
8367
|
+
if (!isThisParameterResulting) {
|
|
8368
|
+
parameter.isInput = true;
|
|
8369
|
+
}
|
|
8370
|
+
};
|
|
8371
|
+
try {
|
|
8372
|
+
for (var _g = __values($pipelineJson.parameters), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
8373
|
+
var parameter = _h.value;
|
|
8374
|
+
_loop_3(parameter);
|
|
8375
|
+
}
|
|
8376
|
+
}
|
|
8377
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
8378
|
+
finally {
|
|
8379
|
+
try {
|
|
8380
|
+
if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
|
|
8381
|
+
}
|
|
8382
|
+
finally { if (e_3) throw e_3.error; }
|
|
8383
|
+
}
|
|
8384
|
+
}
|
|
8385
|
+
// =============================================================
|
|
8386
|
+
// Note: 6️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
8387
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
8388
|
+
try {
|
|
8389
|
+
for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
8390
|
+
var parameter = _k.value;
|
|
8391
|
+
if (!parameter.isInput) {
|
|
8392
|
+
parameter.isOutput = true;
|
|
8393
|
+
}
|
|
8394
|
+
}
|
|
8395
|
+
}
|
|
8396
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
8397
|
+
finally {
|
|
8398
|
+
try {
|
|
8399
|
+
if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
|
|
8400
|
+
}
|
|
8401
|
+
finally { if (e_4) throw e_4.error; }
|
|
8402
|
+
}
|
|
8403
|
+
}
|
|
8404
|
+
// =============================================================
|
|
8405
|
+
// Note: 7️⃣ Cleanup of undefined values
|
|
8319
8406
|
$pipelineJson.templates.forEach(function (templates) {
|
|
8320
|
-
var
|
|
8407
|
+
var e_7, _a;
|
|
8321
8408
|
try {
|
|
8322
8409
|
for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8323
8410
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8326,16 +8413,16 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8326
8413
|
}
|
|
8327
8414
|
}
|
|
8328
8415
|
}
|
|
8329
|
-
catch (
|
|
8416
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
8330
8417
|
finally {
|
|
8331
8418
|
try {
|
|
8332
8419
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8333
8420
|
}
|
|
8334
|
-
finally { if (
|
|
8421
|
+
finally { if (e_7) throw e_7.error; }
|
|
8335
8422
|
}
|
|
8336
8423
|
});
|
|
8337
8424
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
8338
|
-
var
|
|
8425
|
+
var e_8, _a;
|
|
8339
8426
|
try {
|
|
8340
8427
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8341
8428
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8344,12 +8431,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8344
8431
|
}
|
|
8345
8432
|
}
|
|
8346
8433
|
}
|
|
8347
|
-
catch (
|
|
8434
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
8348
8435
|
finally {
|
|
8349
8436
|
try {
|
|
8350
8437
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8351
8438
|
}
|
|
8352
|
-
finally { if (
|
|
8439
|
+
finally { if (e_8) throw e_8.error; }
|
|
8353
8440
|
}
|
|
8354
8441
|
});
|
|
8355
8442
|
// =============================================================
|
|
@@ -8378,10 +8465,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8378
8465
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
8379
8466
|
* Note: This function acts as compilation process
|
|
8380
8467
|
*
|
|
8381
|
-
* @param pipelineString {Promptbook} in string markdown format (.
|
|
8468
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
8382
8469
|
* @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
|
|
8383
8470
|
* @param options - Options and tools for the compilation
|
|
8384
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
8471
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
8385
8472
|
* @throws {ParseError} if the promptbook string is not valid
|
|
8386
8473
|
* @public exported from `@promptbook/core`
|
|
8387
8474
|
*/
|
|
@@ -8597,7 +8684,7 @@ function stringifyPipelineJson(pipeline) {
|
|
|
8597
8684
|
return pipelineJsonStringified;
|
|
8598
8685
|
}
|
|
8599
8686
|
/**
|
|
8600
|
-
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.
|
|
8687
|
+
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
|
|
8601
8688
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
8602
8689
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
8603
8690
|
* TODO: [🍙] Make some standard order of json properties
|
|
@@ -8871,7 +8958,7 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
8871
8958
|
*/
|
|
8872
8959
|
|
|
8873
8960
|
/**
|
|
8874
|
-
* Stores
|
|
8961
|
+
* Stores data in memory (HEAP)
|
|
8875
8962
|
*
|
|
8876
8963
|
* @public exported from `@promptbook/core`
|
|
8877
8964
|
*/
|
|
@@ -9001,13 +9088,18 @@ function cacheLlmTools(llmTools, options) {
|
|
|
9001
9088
|
promptResult = _c.sent();
|
|
9002
9089
|
return [3 /*break*/, 11];
|
|
9003
9090
|
case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
|
|
9004
|
-
case 11:
|
|
9091
|
+
case 11:
|
|
9092
|
+
// TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
|
|
9093
|
+
// promptResult.timing: FromtoItems
|
|
9094
|
+
return [4 /*yield*/, storage.setItem(key, {
|
|
9005
9095
|
date: $currentDate(),
|
|
9006
9096
|
promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
9007
9097
|
prompt: prompt,
|
|
9008
9098
|
promptResult: promptResult,
|
|
9009
9099
|
})];
|
|
9010
9100
|
case 12:
|
|
9101
|
+
// TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
|
|
9102
|
+
// promptResult.timing: FromtoItems
|
|
9011
9103
|
_c.sent();
|
|
9012
9104
|
return [2 /*return*/, promptResult];
|
|
9013
9105
|
}
|
|
@@ -9383,6 +9475,54 @@ var websiteScraperMetadata = $deepFreeze({
|
|
|
9383
9475
|
*/
|
|
9384
9476
|
var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
|
|
9385
9477
|
|
|
9478
|
+
/**
|
|
9479
|
+
* Behaves like a storage but forgets everything you put in it
|
|
9480
|
+
*
|
|
9481
|
+
* @public exported from `@promptbook/core`
|
|
9482
|
+
*/
|
|
9483
|
+
var BlackholeStorage = /** @class */ (function () {
|
|
9484
|
+
function BlackholeStorage() {
|
|
9485
|
+
}
|
|
9486
|
+
Object.defineProperty(BlackholeStorage.prototype, "length", {
|
|
9487
|
+
/**
|
|
9488
|
+
* Returns the number of key/value pairs currently present in the list associated with the object.
|
|
9489
|
+
*/
|
|
9490
|
+
get: function () {
|
|
9491
|
+
return 0;
|
|
9492
|
+
},
|
|
9493
|
+
enumerable: false,
|
|
9494
|
+
configurable: true
|
|
9495
|
+
});
|
|
9496
|
+
/**
|
|
9497
|
+
* Empties the list associated with the object of all key/value pairs, if there are any.
|
|
9498
|
+
*/
|
|
9499
|
+
BlackholeStorage.prototype.clear = function () { };
|
|
9500
|
+
/**
|
|
9501
|
+
* Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
|
|
9502
|
+
* @param key
|
|
9503
|
+
*/
|
|
9504
|
+
BlackholeStorage.prototype.getItem = function (key) {
|
|
9505
|
+
return null;
|
|
9506
|
+
};
|
|
9507
|
+
/**
|
|
9508
|
+
* Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
|
|
9509
|
+
*/
|
|
9510
|
+
BlackholeStorage.prototype.key = function (index) {
|
|
9511
|
+
return null;
|
|
9512
|
+
};
|
|
9513
|
+
/**
|
|
9514
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
9515
|
+
*/
|
|
9516
|
+
BlackholeStorage.prototype.setItem = function (key, value) {
|
|
9517
|
+
};
|
|
9518
|
+
/**
|
|
9519
|
+
* Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
|
|
9520
|
+
*/
|
|
9521
|
+
BlackholeStorage.prototype.removeItem = function (key) {
|
|
9522
|
+
};
|
|
9523
|
+
return BlackholeStorage;
|
|
9524
|
+
}());
|
|
9525
|
+
|
|
9386
9526
|
/**
|
|
9387
9527
|
* This class behaves like LocalStorage but separates keys by prefix
|
|
9388
9528
|
*
|
|
@@ -9733,5 +9873,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
9733
9873
|
* TODO: [🧠] Should be in generated file GENERATOR_WARNING
|
|
9734
9874
|
*/
|
|
9735
9875
|
|
|
9736
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
9876
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
9737
9877
|
//# sourceMappingURL=index.es.js.map
|