@promptbook/core 0.74.0-7 → 0.75.0-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 +2 -11
- package/esm/index.es.js +566 -232
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +3 -0
- package/esm/typings/src/_packages/core.index.d.ts +17 -1
- package/esm/typings/src/_packages/types.index.d.ts +10 -0
- 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/FORMFACTOR/FormfactorCommand.d.ts +11 -0
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +11 -0
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -0
- package/esm/typings/src/commands/index.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/formfactors/_common/AbstractFormfactorDefinition.d.ts +29 -0
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +5 -0
- package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +5 -0
- package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +10 -0
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +10 -0
- package/esm/typings/src/formfactors/index.d.ts +14 -0
- package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +22 -0
- package/esm/typings/src/pipeline/pipeline-interface/getPipelineInterface.d.ts +11 -0
- package/esm/typings/src/pipeline/pipeline-interface/isPipelineImplementingInterface.d.ts +25 -0
- package/esm/typings/src/pipeline/pipeline-interface/isPipelineInterfacesEqual.d.ts +11 -0
- 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 +11 -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 +573 -231
- 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",formfactorName:"GENERIC",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",formfactorName:"GENERIC",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",formfactorName:"GENERIC",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",formfactorName:"GENERIC",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,13 +5585,14 @@ 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, formfactorName = pipeline.formfactorName, 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,
|
|
5595
|
+
formfactorName: formfactorName,
|
|
5572
5596
|
parameters: parameters,
|
|
5573
5597
|
templates: templates,
|
|
5574
5598
|
knowledgeSources: knowledgeSources,
|
|
@@ -5779,7 +5803,7 @@ var knowledgeCommandParser = {
|
|
|
5779
5803
|
throw new ParseError("Source not valid");
|
|
5780
5804
|
}
|
|
5781
5805
|
if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
|
|
5782
|
-
throw new ParseError("Source cannot be outside of the .
|
|
5806
|
+
throw new ParseError("Source cannot be outside of the .book.md folder");
|
|
5783
5807
|
}
|
|
5784
5808
|
return {
|
|
5785
5809
|
type: 'KNOWLEDGE',
|
|
@@ -5999,6 +6023,175 @@ var templateCommandParser = {
|
|
|
5999
6023
|
* ```
|
|
6000
6024
|
*/
|
|
6001
6025
|
|
|
6026
|
+
/**
|
|
6027
|
+
* Parses the boilerplate command
|
|
6028
|
+
*
|
|
6029
|
+
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
|
|
6030
|
+
*
|
|
6031
|
+
* @see `documentationUrl` for more details
|
|
6032
|
+
* @private within the commands folder
|
|
6033
|
+
*/
|
|
6034
|
+
var boilerplateCommandParser = {
|
|
6035
|
+
/**
|
|
6036
|
+
* Name of the command
|
|
6037
|
+
*/
|
|
6038
|
+
name: 'BOILERPLATE',
|
|
6039
|
+
/**
|
|
6040
|
+
* Aliases for the BOILERPLATE command
|
|
6041
|
+
*/
|
|
6042
|
+
aliasNames: ['BP'],
|
|
6043
|
+
/**
|
|
6044
|
+
* BOILERPLATE command can be used in:
|
|
6045
|
+
*/
|
|
6046
|
+
isUsedInPipelineHead: true,
|
|
6047
|
+
isUsedInPipelineTemplate: true,
|
|
6048
|
+
/**
|
|
6049
|
+
* Description of the BOILERPLATE command
|
|
6050
|
+
*/
|
|
6051
|
+
description: "@@",
|
|
6052
|
+
/**
|
|
6053
|
+
* Link to documentation
|
|
6054
|
+
*/
|
|
6055
|
+
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
6056
|
+
/**
|
|
6057
|
+
* Example usages of the BOILERPLATE command
|
|
6058
|
+
*/
|
|
6059
|
+
examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
|
|
6060
|
+
/**
|
|
6061
|
+
* Parses the BOILERPLATE command
|
|
6062
|
+
*/
|
|
6063
|
+
parse: function (input) {
|
|
6064
|
+
var args = input.args;
|
|
6065
|
+
if (args.length !== 1) {
|
|
6066
|
+
throw new ParseError("BOILERPLATE command requires exactly one argument");
|
|
6067
|
+
}
|
|
6068
|
+
var value = args[0].toLowerCase();
|
|
6069
|
+
if (value.includes('brr')) {
|
|
6070
|
+
throw new ParseError("BOILERPLATE value can not contain brr");
|
|
6071
|
+
}
|
|
6072
|
+
return {
|
|
6073
|
+
type: 'BOILERPLATE',
|
|
6074
|
+
value: value,
|
|
6075
|
+
};
|
|
6076
|
+
},
|
|
6077
|
+
/**
|
|
6078
|
+
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
6079
|
+
*
|
|
6080
|
+
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
6081
|
+
*/
|
|
6082
|
+
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6083
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
6084
|
+
},
|
|
6085
|
+
/**
|
|
6086
|
+
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
6087
|
+
*
|
|
6088
|
+
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
6089
|
+
*/
|
|
6090
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
6091
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
6092
|
+
},
|
|
6093
|
+
/**
|
|
6094
|
+
* Converts the BOILERPLATE command back to string
|
|
6095
|
+
*
|
|
6096
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6097
|
+
*/
|
|
6098
|
+
stringify: function (command) {
|
|
6099
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
6100
|
+
},
|
|
6101
|
+
/**
|
|
6102
|
+
* Reads the BOILERPLATE command from the `PipelineJson`
|
|
6103
|
+
*
|
|
6104
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6105
|
+
*/
|
|
6106
|
+
takeFromPipelineJson: function (pipelineJson) {
|
|
6107
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
6108
|
+
},
|
|
6109
|
+
/**
|
|
6110
|
+
* Reads the BOILERPLATE command from the `TemplateJson`
|
|
6111
|
+
*
|
|
6112
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6113
|
+
*/
|
|
6114
|
+
takeFromTemplateJson: function ($templateJson) {
|
|
6115
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
6116
|
+
},
|
|
6117
|
+
};
|
|
6118
|
+
|
|
6119
|
+
/**
|
|
6120
|
+
* Parses the BOOK_VERSION command
|
|
6121
|
+
*
|
|
6122
|
+
* @see `documentationUrl` for more details
|
|
6123
|
+
* @private within the commands folder
|
|
6124
|
+
*/
|
|
6125
|
+
var bookVersionCommandParser = {
|
|
6126
|
+
/**
|
|
6127
|
+
* Name of the command
|
|
6128
|
+
*/
|
|
6129
|
+
name: 'BOOK_VERSION',
|
|
6130
|
+
aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
|
|
6131
|
+
/**
|
|
6132
|
+
* BOILERPLATE command can be used in:
|
|
6133
|
+
*/
|
|
6134
|
+
isUsedInPipelineHead: true,
|
|
6135
|
+
isUsedInPipelineTemplate: false,
|
|
6136
|
+
/**
|
|
6137
|
+
* Description of the BOOK_VERSION command
|
|
6138
|
+
*/
|
|
6139
|
+
description: "Which version of the Book language is the .book.md using",
|
|
6140
|
+
/**
|
|
6141
|
+
* Link to documentation
|
|
6142
|
+
*/
|
|
6143
|
+
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
|
|
6144
|
+
/**
|
|
6145
|
+
* Example usages of the BOOK_VERSION command
|
|
6146
|
+
*/
|
|
6147
|
+
examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
|
|
6148
|
+
/**
|
|
6149
|
+
* Parses the BOOK_VERSION command
|
|
6150
|
+
*/
|
|
6151
|
+
parse: function (input) {
|
|
6152
|
+
var args = input.args;
|
|
6153
|
+
var bookVersion = args.pop();
|
|
6154
|
+
if (bookVersion === undefined) {
|
|
6155
|
+
throw new ParseError("Version is required");
|
|
6156
|
+
}
|
|
6157
|
+
if (!isValidPromptbookVersion(bookVersion)) {
|
|
6158
|
+
throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
|
|
6159
|
+
}
|
|
6160
|
+
if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
|
|
6161
|
+
throw new ParseError("Can not have more than one Promptbook version");
|
|
6162
|
+
}
|
|
6163
|
+
return {
|
|
6164
|
+
type: 'BOOK_VERSION',
|
|
6165
|
+
bookVersion: bookVersion,
|
|
6166
|
+
};
|
|
6167
|
+
},
|
|
6168
|
+
/**
|
|
6169
|
+
* Apply the BOOK_VERSION command to the `pipelineJson`
|
|
6170
|
+
*
|
|
6171
|
+
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
6172
|
+
*/
|
|
6173
|
+
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6174
|
+
// TODO: Warn if the version is overridden
|
|
6175
|
+
$pipelineJson.bookVersion = command.bookVersion;
|
|
6176
|
+
},
|
|
6177
|
+
/**
|
|
6178
|
+
* Converts the BOOK_VERSION command back to string
|
|
6179
|
+
*
|
|
6180
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6181
|
+
*/
|
|
6182
|
+
stringify: function (command) {
|
|
6183
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
6184
|
+
},
|
|
6185
|
+
/**
|
|
6186
|
+
* Reads the BOOK_VERSION command from the `PipelineJson`
|
|
6187
|
+
*
|
|
6188
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6189
|
+
*/
|
|
6190
|
+
takeFromPipelineJson: function (pipelineJson) {
|
|
6191
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6192
|
+
},
|
|
6193
|
+
};
|
|
6194
|
+
|
|
6002
6195
|
/**
|
|
6003
6196
|
* Units of text measurement
|
|
6004
6197
|
*
|
|
@@ -6411,7 +6604,7 @@ function validateParameterName(parameterName) {
|
|
|
6411
6604
|
/**
|
|
6412
6605
|
* Parses the foreach command
|
|
6413
6606
|
*
|
|
6414
|
-
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.
|
|
6607
|
+
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
|
|
6415
6608
|
*
|
|
6416
6609
|
* @see `documentationUrl` for more details
|
|
6417
6610
|
* @private within the commands folder
|
|
@@ -6561,7 +6754,7 @@ var foreachCommandParser = {
|
|
|
6561
6754
|
},
|
|
6562
6755
|
};
|
|
6563
6756
|
/**
|
|
6564
|
-
* TODO: [🍭] Make .
|
|
6757
|
+
* TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
|
|
6565
6758
|
*/
|
|
6566
6759
|
|
|
6567
6760
|
/**
|
|
@@ -6636,6 +6829,120 @@ var formatCommandParser = {
|
|
|
6636
6829
|
},
|
|
6637
6830
|
};
|
|
6638
6831
|
|
|
6832
|
+
/**
|
|
6833
|
+
* @@@
|
|
6834
|
+
*
|
|
6835
|
+
* @public exported from `@promptbook/core`
|
|
6836
|
+
*/
|
|
6837
|
+
var ChatFormfactorDefinition = {
|
|
6838
|
+
name: 'CHAT',
|
|
6839
|
+
description: "@@@",
|
|
6840
|
+
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
|
|
6841
|
+
};
|
|
6842
|
+
|
|
6843
|
+
/**
|
|
6844
|
+
* @@@
|
|
6845
|
+
*
|
|
6846
|
+
* @public exported from `@promptbook/core`
|
|
6847
|
+
*/
|
|
6848
|
+
var GenericFormfactorDefinition = {
|
|
6849
|
+
name: 'GENERIC',
|
|
6850
|
+
description: "@@@",
|
|
6851
|
+
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
|
|
6852
|
+
};
|
|
6853
|
+
|
|
6854
|
+
/**
|
|
6855
|
+
* All available formfactor definitions
|
|
6856
|
+
*
|
|
6857
|
+
* @public exported from `@promptbook/core`
|
|
6858
|
+
*/
|
|
6859
|
+
var FORMFACTOR_DEFINITIONS = [GenericFormfactorDefinition, ChatFormfactorDefinition];
|
|
6860
|
+
|
|
6861
|
+
/**
|
|
6862
|
+
* Parses the formfactor command
|
|
6863
|
+
*
|
|
6864
|
+
* Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
|
|
6865
|
+
*
|
|
6866
|
+
* @see `documentationUrl` for more details
|
|
6867
|
+
* @private within the commands folder
|
|
6868
|
+
*/
|
|
6869
|
+
var formfactorCommandParser = {
|
|
6870
|
+
/**
|
|
6871
|
+
* Name of the command
|
|
6872
|
+
*/
|
|
6873
|
+
name: 'FORMFACTOR',
|
|
6874
|
+
/**
|
|
6875
|
+
* Aliases for the FORMFACTOR command
|
|
6876
|
+
*/
|
|
6877
|
+
aliasNames: ['FORM', 'FF'],
|
|
6878
|
+
/**
|
|
6879
|
+
* FORMFACTOR command can be used in:
|
|
6880
|
+
*/
|
|
6881
|
+
isUsedInPipelineHead: true,
|
|
6882
|
+
isUsedInPipelineTemplate: false,
|
|
6883
|
+
/**
|
|
6884
|
+
* Description of the FORMFACTOR command
|
|
6885
|
+
*/
|
|
6886
|
+
description: "@@",
|
|
6887
|
+
/**
|
|
6888
|
+
* Link to documentation
|
|
6889
|
+
*/
|
|
6890
|
+
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/168',
|
|
6891
|
+
/**
|
|
6892
|
+
* Example usages of the FORMFACTOR command
|
|
6893
|
+
*/
|
|
6894
|
+
examples: ['FORMFACTOR Chat', 'FORMFACTOR Generic'],
|
|
6895
|
+
/**
|
|
6896
|
+
* Parses the FORMFACTOR command
|
|
6897
|
+
*/
|
|
6898
|
+
parse: function (input) {
|
|
6899
|
+
var args = input.args;
|
|
6900
|
+
if (args.length !== 1) {
|
|
6901
|
+
throw new ParseError("FORMFACTOR command requires exactly one argument");
|
|
6902
|
+
}
|
|
6903
|
+
var formfactorName = args[0].toUpperCase();
|
|
6904
|
+
if (!FORMFACTOR_DEFINITIONS.some(function (definition) { return definition.name === formfactorName; })) {
|
|
6905
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Unknown formfactor name \"".concat(formfactorName, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
|
|
6906
|
+
var name = _a.name;
|
|
6907
|
+
return "- ".concat(name);
|
|
6908
|
+
}).join('\n')), "\n "); }));
|
|
6909
|
+
}
|
|
6910
|
+
return {
|
|
6911
|
+
type: 'FORMFACTOR',
|
|
6912
|
+
formfactorName: formfactorName,
|
|
6913
|
+
};
|
|
6914
|
+
},
|
|
6915
|
+
/**
|
|
6916
|
+
* Apply the FORMFACTOR command to the `pipelineJson`
|
|
6917
|
+
*
|
|
6918
|
+
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
6919
|
+
*/
|
|
6920
|
+
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6921
|
+
$pipelineJson.formfactorName = command.formfactorName;
|
|
6922
|
+
},
|
|
6923
|
+
/**
|
|
6924
|
+
* Converts the FORMFACTOR command back to string
|
|
6925
|
+
*
|
|
6926
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6927
|
+
*/
|
|
6928
|
+
stringify: function (command) {
|
|
6929
|
+
return "FORMFACTOR ".concat(command.formfactorName);
|
|
6930
|
+
},
|
|
6931
|
+
/**
|
|
6932
|
+
* Reads the FORMFACTOR command from the `PipelineJson`
|
|
6933
|
+
*
|
|
6934
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6935
|
+
*/
|
|
6936
|
+
takeFromPipelineJson: function (pipelineJson) {
|
|
6937
|
+
return [
|
|
6938
|
+
{
|
|
6939
|
+
type: 'FORMFACTOR',
|
|
6940
|
+
formfactorName: pipelineJson.formfactorName,
|
|
6941
|
+
},
|
|
6942
|
+
];
|
|
6943
|
+
},
|
|
6944
|
+
};
|
|
6945
|
+
|
|
6639
6946
|
/**
|
|
6640
6947
|
* Parses the joker command
|
|
6641
6948
|
*
|
|
@@ -7176,88 +7483,12 @@ var postprocessCommandParser = {
|
|
|
7176
7483
|
};
|
|
7177
7484
|
|
|
7178
7485
|
/**
|
|
7179
|
-
* Parses the
|
|
7486
|
+
* Parses the url command
|
|
7180
7487
|
*
|
|
7181
7488
|
* @see `documentationUrl` for more details
|
|
7182
7489
|
* @private within the commands folder
|
|
7183
7490
|
*/
|
|
7184
|
-
var
|
|
7185
|
-
/**
|
|
7186
|
-
* Name of the command
|
|
7187
|
-
*/
|
|
7188
|
-
name: 'BOOK_VERSION',
|
|
7189
|
-
aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
|
|
7190
|
-
/**
|
|
7191
|
-
* BOILERPLATE command can be used in:
|
|
7192
|
-
*/
|
|
7193
|
-
isUsedInPipelineHead: true,
|
|
7194
|
-
isUsedInPipelineTemplate: false,
|
|
7195
|
-
/**
|
|
7196
|
-
* Description of the BOOK_VERSION command
|
|
7197
|
-
*/
|
|
7198
|
-
description: "Which version of the Book language is the .ptbk.md using",
|
|
7199
|
-
/**
|
|
7200
|
-
* Link to documentation
|
|
7201
|
-
*/
|
|
7202
|
-
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
|
|
7203
|
-
/**
|
|
7204
|
-
* Example usages of the BOOK_VERSION command
|
|
7205
|
-
*/
|
|
7206
|
-
examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
|
|
7207
|
-
/**
|
|
7208
|
-
* Parses the BOOK_VERSION command
|
|
7209
|
-
*/
|
|
7210
|
-
parse: function (input) {
|
|
7211
|
-
var args = input.args;
|
|
7212
|
-
var promptbookVersion = args.pop();
|
|
7213
|
-
if (promptbookVersion === undefined) {
|
|
7214
|
-
throw new ParseError("Version is required");
|
|
7215
|
-
}
|
|
7216
|
-
if (!isValidPromptbookVersion(promptbookVersion)) {
|
|
7217
|
-
throw new ParseError("Invalid Promptbook version \"".concat(promptbookVersion, "\""));
|
|
7218
|
-
}
|
|
7219
|
-
if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
|
|
7220
|
-
throw new ParseError("Can not have more than one Promptbook version");
|
|
7221
|
-
}
|
|
7222
|
-
return {
|
|
7223
|
-
type: 'BOOK_VERSION',
|
|
7224
|
-
promptbookVersion: promptbookVersion,
|
|
7225
|
-
};
|
|
7226
|
-
},
|
|
7227
|
-
/**
|
|
7228
|
-
* Apply the BOOK_VERSION command to the `pipelineJson`
|
|
7229
|
-
*
|
|
7230
|
-
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7231
|
-
*/
|
|
7232
|
-
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7233
|
-
// TODO: Warn if the version is overridden
|
|
7234
|
-
$pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
7235
|
-
},
|
|
7236
|
-
/**
|
|
7237
|
-
* Converts the BOOK_VERSION command back to string
|
|
7238
|
-
*
|
|
7239
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7240
|
-
*/
|
|
7241
|
-
stringify: function (command) {
|
|
7242
|
-
return "---"; // <- TODO: [🛋] Implement
|
|
7243
|
-
},
|
|
7244
|
-
/**
|
|
7245
|
-
* Reads the BOOK_VERSION command from the `PipelineJson`
|
|
7246
|
-
*
|
|
7247
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7248
|
-
*/
|
|
7249
|
-
takeFromPipelineJson: function (pipelineJson) {
|
|
7250
|
-
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7251
|
-
},
|
|
7252
|
-
};
|
|
7253
|
-
|
|
7254
|
-
/**
|
|
7255
|
-
* Parses the url command
|
|
7256
|
-
*
|
|
7257
|
-
* @see `documentationUrl` for more details
|
|
7258
|
-
* @private within the commands folder
|
|
7259
|
-
*/
|
|
7260
|
-
var urlCommandParser = {
|
|
7491
|
+
var urlCommandParser = {
|
|
7261
7492
|
/**
|
|
7262
7493
|
* Name of the command
|
|
7263
7494
|
*/
|
|
@@ -7284,9 +7515,9 @@ var urlCommandParser = {
|
|
|
7284
7515
|
* Example usages of the URL command
|
|
7285
7516
|
*/
|
|
7286
7517
|
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.
|
|
7518
|
+
'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
|
|
7519
|
+
'URL https://promptbook.studio/library/write-cv.book.md',
|
|
7520
|
+
'https://promptbook.studio/library/write-cv.book.md',
|
|
7290
7521
|
],
|
|
7291
7522
|
/**
|
|
7292
7523
|
* Parses the URL command
|
|
@@ -7484,99 +7715,6 @@ var instrumentCommandParser = {
|
|
|
7484
7715
|
* Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
|
|
7485
7716
|
*/
|
|
7486
7717
|
|
|
7487
|
-
/**
|
|
7488
|
-
* Parses the boilerplate command
|
|
7489
|
-
*
|
|
7490
|
-
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.ptbk.md` file
|
|
7491
|
-
*
|
|
7492
|
-
* @see `documentationUrl` for more details
|
|
7493
|
-
* @private within the commands folder
|
|
7494
|
-
*/
|
|
7495
|
-
var boilerplateCommandParser = {
|
|
7496
|
-
/**
|
|
7497
|
-
* Name of the command
|
|
7498
|
-
*/
|
|
7499
|
-
name: 'BOILERPLATE',
|
|
7500
|
-
/**
|
|
7501
|
-
* Aliases for the BOILERPLATE command
|
|
7502
|
-
*/
|
|
7503
|
-
aliasNames: ['BP'],
|
|
7504
|
-
/**
|
|
7505
|
-
* BOILERPLATE command can be used in:
|
|
7506
|
-
*/
|
|
7507
|
-
isUsedInPipelineHead: true,
|
|
7508
|
-
isUsedInPipelineTemplate: true,
|
|
7509
|
-
/**
|
|
7510
|
-
* Description of the BOILERPLATE command
|
|
7511
|
-
*/
|
|
7512
|
-
description: "@@",
|
|
7513
|
-
/**
|
|
7514
|
-
* Link to documentation
|
|
7515
|
-
*/
|
|
7516
|
-
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
7517
|
-
/**
|
|
7518
|
-
* Example usages of the BOILERPLATE command
|
|
7519
|
-
*/
|
|
7520
|
-
examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
|
|
7521
|
-
/**
|
|
7522
|
-
* Parses the BOILERPLATE command
|
|
7523
|
-
*/
|
|
7524
|
-
parse: function (input) {
|
|
7525
|
-
var args = input.args;
|
|
7526
|
-
if (args.length !== 1) {
|
|
7527
|
-
throw new ParseError("BOILERPLATE command requires exactly one argument");
|
|
7528
|
-
}
|
|
7529
|
-
var value = args[0].toLowerCase();
|
|
7530
|
-
if (value.includes('brr')) {
|
|
7531
|
-
throw new ParseError("BOILERPLATE value can not contain brr");
|
|
7532
|
-
}
|
|
7533
|
-
return {
|
|
7534
|
-
type: 'BOILERPLATE',
|
|
7535
|
-
value: value,
|
|
7536
|
-
};
|
|
7537
|
-
},
|
|
7538
|
-
/**
|
|
7539
|
-
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
7540
|
-
*
|
|
7541
|
-
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7542
|
-
*/
|
|
7543
|
-
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7544
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7545
|
-
},
|
|
7546
|
-
/**
|
|
7547
|
-
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
7548
|
-
*
|
|
7549
|
-
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
7550
|
-
*/
|
|
7551
|
-
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
7552
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7553
|
-
},
|
|
7554
|
-
/**
|
|
7555
|
-
* Converts the BOILERPLATE command back to string
|
|
7556
|
-
*
|
|
7557
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7558
|
-
*/
|
|
7559
|
-
stringify: function (command) {
|
|
7560
|
-
return "---"; // <- TODO: [🛋] Implement
|
|
7561
|
-
},
|
|
7562
|
-
/**
|
|
7563
|
-
* Reads the BOILERPLATE command from the `PipelineJson`
|
|
7564
|
-
*
|
|
7565
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7566
|
-
*/
|
|
7567
|
-
takeFromPipelineJson: function (pipelineJson) {
|
|
7568
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7569
|
-
},
|
|
7570
|
-
/**
|
|
7571
|
-
* Reads the BOILERPLATE command from the `TemplateJson`
|
|
7572
|
-
*
|
|
7573
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7574
|
-
*/
|
|
7575
|
-
takeFromTemplateJson: function ($templateJson) {
|
|
7576
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7577
|
-
},
|
|
7578
|
-
};
|
|
7579
|
-
|
|
7580
7718
|
/**
|
|
7581
7719
|
* All available command parsers
|
|
7582
7720
|
*
|
|
@@ -7591,6 +7729,7 @@ var COMMANDS = [
|
|
|
7591
7729
|
parameterCommandParser,
|
|
7592
7730
|
postprocessCommandParser,
|
|
7593
7731
|
bookVersionCommandParser,
|
|
7732
|
+
formfactorCommandParser,
|
|
7594
7733
|
urlCommandParser,
|
|
7595
7734
|
knowledgeCommandParser,
|
|
7596
7735
|
actionCommandParser,
|
|
@@ -7902,7 +8041,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
7902
8041
|
return;
|
|
7903
8042
|
}
|
|
7904
8043
|
if (!section.startsWith('#')) {
|
|
7905
|
-
section = "#
|
|
8044
|
+
section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
|
|
7906
8045
|
}
|
|
7907
8046
|
sections.push(section);
|
|
7908
8047
|
buffer = [];
|
|
@@ -7966,7 +8105,7 @@ function flattenMarkdown(markdown) {
|
|
|
7966
8105
|
var e_1, _a;
|
|
7967
8106
|
var sections = splitMarkdownIntoSections(markdown);
|
|
7968
8107
|
if (sections.length === 0) {
|
|
7969
|
-
return
|
|
8108
|
+
return "# ".concat(DEFAULT_TITLE);
|
|
7970
8109
|
}
|
|
7971
8110
|
var flattenedMarkdown = '';
|
|
7972
8111
|
var parsedSections = sections.map(parseMarkdownSection);
|
|
@@ -7977,7 +8116,7 @@ function flattenMarkdown(markdown) {
|
|
|
7977
8116
|
}
|
|
7978
8117
|
else {
|
|
7979
8118
|
parsedSections.unshift(firstSection);
|
|
7980
|
-
flattenedMarkdown += "#
|
|
8119
|
+
flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
|
|
7981
8120
|
}
|
|
7982
8121
|
try {
|
|
7983
8122
|
for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
|
|
@@ -8049,18 +8188,19 @@ function titleToName(value) {
|
|
|
8049
8188
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
8050
8189
|
* Note: This function acts as compilation process
|
|
8051
8190
|
*
|
|
8052
|
-
* @param pipelineString {Promptbook} in string markdown format (.
|
|
8053
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
8191
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
8192
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
8054
8193
|
* @throws {ParseError} if the promptbook string is not valid
|
|
8055
8194
|
* @public exported from `@promptbook/core`
|
|
8056
8195
|
*/
|
|
8057
8196
|
function pipelineStringToJsonSync(pipelineString) {
|
|
8058
|
-
var e_1, _a, e_2, _b;
|
|
8197
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
8059
8198
|
var $pipelineJson = {
|
|
8060
8199
|
title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
|
|
8061
8200
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
8062
|
-
|
|
8201
|
+
bookVersion: undefined /* <- Note: By default no explicit version */,
|
|
8063
8202
|
description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
|
|
8203
|
+
formfactorName: 'GENERIC',
|
|
8064
8204
|
parameters: [],
|
|
8065
8205
|
templates: [],
|
|
8066
8206
|
knowledgeSources: [],
|
|
@@ -8083,7 +8223,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8083
8223
|
// =============================================================
|
|
8084
8224
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
8085
8225
|
if (pipelineString.startsWith('#!')) {
|
|
8086
|
-
var
|
|
8226
|
+
var _e = __read(pipelineString.split('\n')), shebangLine_1 = _e[0], restLines = _e.slice(1);
|
|
8087
8227
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
8088
8228
|
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
8229
|
}
|
|
@@ -8093,7 +8233,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8093
8233
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
8094
8234
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
8095
8235
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
8096
|
-
var
|
|
8236
|
+
var _f = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _f[0], pipelineSections = _f.slice(1); /* <- Note: [🥞] */
|
|
8097
8237
|
if (pipelineHead === undefined) {
|
|
8098
8238
|
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
8239
|
}
|
|
@@ -8121,6 +8261,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8121
8261
|
if (parameterDescription) {
|
|
8122
8262
|
existingParameter.description = parameterDescription;
|
|
8123
8263
|
}
|
|
8264
|
+
existingParameter.isInput = existingParameter.isInput || isInput;
|
|
8265
|
+
existingParameter.isOutput = existingParameter.isOutput || isOutput;
|
|
8124
8266
|
}
|
|
8125
8267
|
else {
|
|
8126
8268
|
$pipelineJson.parameters.push({
|
|
@@ -8183,10 +8325,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8183
8325
|
finally { if (e_1) throw e_1.error; }
|
|
8184
8326
|
}
|
|
8185
8327
|
var _loop_2 = function (section) {
|
|
8186
|
-
var
|
|
8328
|
+
var e_5, _l, e_6, _m;
|
|
8187
8329
|
// TODO: Parse template description (the content out of the codeblock and lists)
|
|
8188
8330
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
8189
|
-
var
|
|
8331
|
+
var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
|
|
8190
8332
|
// TODO: [🎾][1] DRY description
|
|
8191
8333
|
var description_1 = section.content;
|
|
8192
8334
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -8227,7 +8369,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8227
8369
|
}) === false) {
|
|
8228
8370
|
templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
|
|
8229
8371
|
}
|
|
8230
|
-
var
|
|
8372
|
+
var _loop_4 = function (listItem, command) {
|
|
8231
8373
|
var commandParser = getParserForCommand(command);
|
|
8232
8374
|
if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
|
|
8233
8375
|
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 +8392,17 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8250
8392
|
};
|
|
8251
8393
|
try {
|
|
8252
8394
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
8253
|
-
for (var commands_1 = (
|
|
8254
|
-
var
|
|
8255
|
-
|
|
8395
|
+
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()) {
|
|
8396
|
+
var _p = commands_1_1.value, listItem = _p.listItem, command = _p.command;
|
|
8397
|
+
_loop_4(listItem, command);
|
|
8256
8398
|
}
|
|
8257
8399
|
}
|
|
8258
|
-
catch (
|
|
8400
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
8259
8401
|
finally {
|
|
8260
8402
|
try {
|
|
8261
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
8403
|
+
if (commands_1_1 && !commands_1_1.done && (_l = commands_1.return)) _l.call(commands_1);
|
|
8262
8404
|
}
|
|
8263
|
-
finally { if (
|
|
8405
|
+
finally { if (e_5) throw e_5.error; }
|
|
8264
8406
|
}
|
|
8265
8407
|
// TODO: [🍧] Should be done in TEMPLATE command
|
|
8266
8408
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
@@ -8274,6 +8416,26 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8274
8416
|
language;
|
|
8275
8417
|
}
|
|
8276
8418
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
8419
|
+
try {
|
|
8420
|
+
for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
8421
|
+
var parameterName = _r.value;
|
|
8422
|
+
// TODO: [🧠] This definition should be made first in the template
|
|
8423
|
+
defineParam({
|
|
8424
|
+
parameterName: parameterName,
|
|
8425
|
+
parameterDescription: null,
|
|
8426
|
+
isInput: false,
|
|
8427
|
+
isOutput: false,
|
|
8428
|
+
// <- 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
|
|
8429
|
+
});
|
|
8430
|
+
}
|
|
8431
|
+
}
|
|
8432
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
8433
|
+
finally {
|
|
8434
|
+
try {
|
|
8435
|
+
if (_r && !_r.done && (_m = _q.return)) _m.call(_q);
|
|
8436
|
+
}
|
|
8437
|
+
finally { if (e_6) throw e_6.error; }
|
|
8438
|
+
}
|
|
8277
8439
|
/*
|
|
8278
8440
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
8279
8441
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
@@ -8315,9 +8477,51 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8315
8477
|
finally { if (e_2) throw e_2.error; }
|
|
8316
8478
|
}
|
|
8317
8479
|
// =============================================================
|
|
8318
|
-
// Note: 5️⃣
|
|
8480
|
+
// Note: 5️⃣ Mark parameters as INPUT if not explicitly set
|
|
8481
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
8482
|
+
var _loop_3 = function (parameter) {
|
|
8483
|
+
var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
|
|
8484
|
+
if (!isThisParameterResulting) {
|
|
8485
|
+
parameter.isInput = true;
|
|
8486
|
+
}
|
|
8487
|
+
};
|
|
8488
|
+
try {
|
|
8489
|
+
for (var _g = __values($pipelineJson.parameters), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
8490
|
+
var parameter = _h.value;
|
|
8491
|
+
_loop_3(parameter);
|
|
8492
|
+
}
|
|
8493
|
+
}
|
|
8494
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
8495
|
+
finally {
|
|
8496
|
+
try {
|
|
8497
|
+
if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
|
|
8498
|
+
}
|
|
8499
|
+
finally { if (e_3) throw e_3.error; }
|
|
8500
|
+
}
|
|
8501
|
+
}
|
|
8502
|
+
// =============================================================
|
|
8503
|
+
// Note: 6️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
8504
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
8505
|
+
try {
|
|
8506
|
+
for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
8507
|
+
var parameter = _k.value;
|
|
8508
|
+
if (!parameter.isInput) {
|
|
8509
|
+
parameter.isOutput = true;
|
|
8510
|
+
}
|
|
8511
|
+
}
|
|
8512
|
+
}
|
|
8513
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
8514
|
+
finally {
|
|
8515
|
+
try {
|
|
8516
|
+
if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
|
|
8517
|
+
}
|
|
8518
|
+
finally { if (e_4) throw e_4.error; }
|
|
8519
|
+
}
|
|
8520
|
+
}
|
|
8521
|
+
// =============================================================
|
|
8522
|
+
// Note: 7️⃣ Cleanup of undefined values
|
|
8319
8523
|
$pipelineJson.templates.forEach(function (templates) {
|
|
8320
|
-
var
|
|
8524
|
+
var e_7, _a;
|
|
8321
8525
|
try {
|
|
8322
8526
|
for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8323
8527
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8326,16 +8530,16 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8326
8530
|
}
|
|
8327
8531
|
}
|
|
8328
8532
|
}
|
|
8329
|
-
catch (
|
|
8533
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
8330
8534
|
finally {
|
|
8331
8535
|
try {
|
|
8332
8536
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8333
8537
|
}
|
|
8334
|
-
finally { if (
|
|
8538
|
+
finally { if (e_7) throw e_7.error; }
|
|
8335
8539
|
}
|
|
8336
8540
|
});
|
|
8337
8541
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
8338
|
-
var
|
|
8542
|
+
var e_8, _a;
|
|
8339
8543
|
try {
|
|
8340
8544
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8341
8545
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8344,12 +8548,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8344
8548
|
}
|
|
8345
8549
|
}
|
|
8346
8550
|
}
|
|
8347
|
-
catch (
|
|
8551
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
8348
8552
|
finally {
|
|
8349
8553
|
try {
|
|
8350
8554
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8351
8555
|
}
|
|
8352
|
-
finally { if (
|
|
8556
|
+
finally { if (e_8) throw e_8.error; }
|
|
8353
8557
|
}
|
|
8354
8558
|
});
|
|
8355
8559
|
// =============================================================
|
|
@@ -8378,10 +8582,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8378
8582
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
8379
8583
|
* Note: This function acts as compilation process
|
|
8380
8584
|
*
|
|
8381
|
-
* @param pipelineString {Promptbook} in string markdown format (.
|
|
8585
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
8382
8586
|
* @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
|
|
8383
8587
|
* @param options - Options and tools for the compilation
|
|
8384
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
8588
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
8385
8589
|
* @throws {ParseError} if the promptbook string is not valid
|
|
8386
8590
|
* @public exported from `@promptbook/core`
|
|
8387
8591
|
*/
|
|
@@ -8597,7 +8801,7 @@ function stringifyPipelineJson(pipeline) {
|
|
|
8597
8801
|
return pipelineJsonStringified;
|
|
8598
8802
|
}
|
|
8599
8803
|
/**
|
|
8600
|
-
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.
|
|
8804
|
+
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
|
|
8601
8805
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
8602
8806
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
8603
8807
|
* TODO: [🍙] Make some standard order of json properties
|
|
@@ -8871,7 +9075,7 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
8871
9075
|
*/
|
|
8872
9076
|
|
|
8873
9077
|
/**
|
|
8874
|
-
* Stores
|
|
9078
|
+
* Stores data in memory (HEAP)
|
|
8875
9079
|
*
|
|
8876
9080
|
* @public exported from `@promptbook/core`
|
|
8877
9081
|
*/
|
|
@@ -9001,13 +9205,18 @@ function cacheLlmTools(llmTools, options) {
|
|
|
9001
9205
|
promptResult = _c.sent();
|
|
9002
9206
|
return [3 /*break*/, 11];
|
|
9003
9207
|
case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
|
|
9004
|
-
case 11:
|
|
9208
|
+
case 11:
|
|
9209
|
+
// TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
|
|
9210
|
+
// promptResult.timing: FromtoItems
|
|
9211
|
+
return [4 /*yield*/, storage.setItem(key, {
|
|
9005
9212
|
date: $currentDate(),
|
|
9006
9213
|
promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
9007
9214
|
prompt: prompt,
|
|
9008
9215
|
promptResult: promptResult,
|
|
9009
9216
|
})];
|
|
9010
9217
|
case 12:
|
|
9218
|
+
// TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
|
|
9219
|
+
// promptResult.timing: FromtoItems
|
|
9011
9220
|
_c.sent();
|
|
9012
9221
|
return [2 /*return*/, promptResult];
|
|
9013
9222
|
}
|
|
@@ -9259,6 +9468,83 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
9259
9468
|
},
|
|
9260
9469
|
});
|
|
9261
9470
|
|
|
9471
|
+
/**
|
|
9472
|
+
* @@@
|
|
9473
|
+
*
|
|
9474
|
+
* @public exported from `@promptbook/core`
|
|
9475
|
+
*/
|
|
9476
|
+
function getPipelineInterface(pipeline) {
|
|
9477
|
+
var e_1, _a, e_2, _b;
|
|
9478
|
+
var pipelineInterface = {
|
|
9479
|
+
inputParameterNames: [],
|
|
9480
|
+
outputParameterNames: [],
|
|
9481
|
+
};
|
|
9482
|
+
try {
|
|
9483
|
+
for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
9484
|
+
var parameter = _d.value;
|
|
9485
|
+
var name_1 = parameter.name, isInput = parameter.isInput, isOutput = parameter.isOutput;
|
|
9486
|
+
if (isInput) {
|
|
9487
|
+
pipelineInterface.inputParameterNames.push(name_1);
|
|
9488
|
+
}
|
|
9489
|
+
if (isOutput) {
|
|
9490
|
+
pipelineInterface.outputParameterNames.push(name_1);
|
|
9491
|
+
}
|
|
9492
|
+
}
|
|
9493
|
+
}
|
|
9494
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
9495
|
+
finally {
|
|
9496
|
+
try {
|
|
9497
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
9498
|
+
}
|
|
9499
|
+
finally { if (e_1) throw e_1.error; }
|
|
9500
|
+
}
|
|
9501
|
+
try {
|
|
9502
|
+
for (var _e = __values(['inputParameterNames', 'outputParameterNames']), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
9503
|
+
var key = _f.value;
|
|
9504
|
+
pipelineInterface[key].sort(function (a, b) { return a.localeCompare(b); });
|
|
9505
|
+
}
|
|
9506
|
+
}
|
|
9507
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
9508
|
+
finally {
|
|
9509
|
+
try {
|
|
9510
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
9511
|
+
}
|
|
9512
|
+
finally { if (e_2) throw e_2.error; }
|
|
9513
|
+
}
|
|
9514
|
+
return Object.freeze(pipelineInterface);
|
|
9515
|
+
}
|
|
9516
|
+
/**
|
|
9517
|
+
* TODO: !!!!!! Write unit test
|
|
9518
|
+
*/
|
|
9519
|
+
|
|
9520
|
+
/**
|
|
9521
|
+
* @@@
|
|
9522
|
+
*
|
|
9523
|
+
* @public exported from `@promptbook/core`
|
|
9524
|
+
*/
|
|
9525
|
+
function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
|
|
9526
|
+
// TODO: [🧠] !!! Implement better
|
|
9527
|
+
return JSON.stringify(pipelineInterface1) === JSON.stringify(pipelineInterface2);
|
|
9528
|
+
}
|
|
9529
|
+
/**
|
|
9530
|
+
* TODO: [🧠] !!! Return more states than true/false - 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
|
|
9531
|
+
* TODO: !!! Write unit test
|
|
9532
|
+
*/
|
|
9533
|
+
|
|
9534
|
+
/**
|
|
9535
|
+
* @@@
|
|
9536
|
+
*
|
|
9537
|
+
* @public exported from `@promptbook/core`
|
|
9538
|
+
*/
|
|
9539
|
+
function isPipelineImplementingInterface(options) {
|
|
9540
|
+
var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
|
|
9541
|
+
return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
|
|
9542
|
+
}
|
|
9543
|
+
/**
|
|
9544
|
+
* TODO: !!!!!! Test real implementing NOT equality
|
|
9545
|
+
* TODO: !!!!!! Write unit test
|
|
9546
|
+
*/
|
|
9547
|
+
|
|
9262
9548
|
/**
|
|
9263
9549
|
* Metadata of the scraper
|
|
9264
9550
|
*
|
|
@@ -9383,6 +9669,54 @@ var websiteScraperMetadata = $deepFreeze({
|
|
|
9383
9669
|
*/
|
|
9384
9670
|
var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
|
|
9385
9671
|
|
|
9672
|
+
/**
|
|
9673
|
+
* Behaves like a storage but forgets everything you put in it
|
|
9674
|
+
*
|
|
9675
|
+
* @public exported from `@promptbook/core`
|
|
9676
|
+
*/
|
|
9677
|
+
var BlackholeStorage = /** @class */ (function () {
|
|
9678
|
+
function BlackholeStorage() {
|
|
9679
|
+
}
|
|
9680
|
+
Object.defineProperty(BlackholeStorage.prototype, "length", {
|
|
9681
|
+
/**
|
|
9682
|
+
* Returns the number of key/value pairs currently present in the list associated with the object.
|
|
9683
|
+
*/
|
|
9684
|
+
get: function () {
|
|
9685
|
+
return 0;
|
|
9686
|
+
},
|
|
9687
|
+
enumerable: false,
|
|
9688
|
+
configurable: true
|
|
9689
|
+
});
|
|
9690
|
+
/**
|
|
9691
|
+
* Empties the list associated with the object of all key/value pairs, if there are any.
|
|
9692
|
+
*/
|
|
9693
|
+
BlackholeStorage.prototype.clear = function () { };
|
|
9694
|
+
/**
|
|
9695
|
+
* 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.
|
|
9696
|
+
* @param key
|
|
9697
|
+
*/
|
|
9698
|
+
BlackholeStorage.prototype.getItem = function (key) {
|
|
9699
|
+
return null;
|
|
9700
|
+
};
|
|
9701
|
+
/**
|
|
9702
|
+
* 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.
|
|
9703
|
+
*/
|
|
9704
|
+
BlackholeStorage.prototype.key = function (index) {
|
|
9705
|
+
return null;
|
|
9706
|
+
};
|
|
9707
|
+
/**
|
|
9708
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
9709
|
+
*/
|
|
9710
|
+
BlackholeStorage.prototype.setItem = function (key, value) {
|
|
9711
|
+
};
|
|
9712
|
+
/**
|
|
9713
|
+
* 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.
|
|
9714
|
+
*/
|
|
9715
|
+
BlackholeStorage.prototype.removeItem = function (key) {
|
|
9716
|
+
};
|
|
9717
|
+
return BlackholeStorage;
|
|
9718
|
+
}());
|
|
9719
|
+
|
|
9386
9720
|
/**
|
|
9387
9721
|
* This class behaves like LocalStorage but separates keys by prefix
|
|
9388
9722
|
*
|
|
@@ -9733,5 +10067,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
9733
10067
|
* TODO: [🧠] Should be in generated file GENERATOR_WARNING
|
|
9734
10068
|
*/
|
|
9735
10069
|
|
|
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 };
|
|
10070
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, CLAIM, CallbackInterfaceTools, ChatFormfactorDefinition, 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, FORMFACTOR_DEFINITIONS, GenericFormfactorDefinition, 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, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
9737
10071
|
//# sourceMappingURL=index.es.js.map
|