@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/umd/index.umd.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-
|
|
27
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
*/
|
|
@@ -221,13 +221,13 @@
|
|
|
221
221
|
/**
|
|
222
222
|
* Converts promptbook in JSON format to string format
|
|
223
223
|
*
|
|
224
|
-
* @param pipelineJson Promptbook in JSON format (.
|
|
225
|
-
* @returns Promptbook in string format (.
|
|
224
|
+
* @param pipelineJson Promptbook in JSON format (.book.json)
|
|
225
|
+
* @returns Promptbook in string format (.book.md)
|
|
226
226
|
* @public exported from `@promptbook/core`
|
|
227
227
|
*/
|
|
228
228
|
function pipelineJsonToString(pipelineJson) {
|
|
229
229
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
230
|
-
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl,
|
|
230
|
+
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
|
|
231
231
|
var pipelineString = "# ".concat(title);
|
|
232
232
|
if (description) {
|
|
233
233
|
pipelineString += '\n\n';
|
|
@@ -237,8 +237,10 @@
|
|
|
237
237
|
if (pipelineUrl) {
|
|
238
238
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
239
239
|
}
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
if (bookVersion !== "undefined") {
|
|
241
|
+
commands.push("BOOK VERSION ".concat(bookVersion));
|
|
242
|
+
}
|
|
243
|
+
// TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
|
|
242
244
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
243
245
|
try {
|
|
244
246
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -418,7 +420,7 @@
|
|
|
418
420
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
419
421
|
* TODO: [🏛] Maybe make some markdown builder
|
|
420
422
|
* TODO: [🏛] Escape all
|
|
421
|
-
* TODO: [🧠] Should be in generated .
|
|
423
|
+
* TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
422
424
|
*/
|
|
423
425
|
|
|
424
426
|
/**
|
|
@@ -648,6 +650,13 @@
|
|
|
648
650
|
* @public exported from `@promptbook/core`
|
|
649
651
|
*/
|
|
650
652
|
var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
|
|
653
|
+
// <- TODO: [🐊] Pick the best claim
|
|
654
|
+
/**
|
|
655
|
+
* When the title is not provided, the default title is used
|
|
656
|
+
*
|
|
657
|
+
* @public exported from `@promptbook/core`
|
|
658
|
+
*/
|
|
659
|
+
var DEFAULT_TITLE = "Untitled";
|
|
651
660
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
652
661
|
/**
|
|
653
662
|
* The maximum number of iterations for a loops
|
|
@@ -987,7 +996,7 @@
|
|
|
987
996
|
if (!url.startsWith('https://')) {
|
|
988
997
|
return false;
|
|
989
998
|
}
|
|
990
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.
|
|
999
|
+
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
991
1000
|
return false;
|
|
992
1001
|
}
|
|
993
1002
|
if (url.includes('#')) {
|
|
@@ -1056,9 +1065,9 @@
|
|
|
1056
1065
|
// <- Note: [🚲]
|
|
1057
1066
|
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1058
1067
|
}
|
|
1059
|
-
if (pipeline.
|
|
1068
|
+
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
1060
1069
|
// <- Note: [🚲]
|
|
1061
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.
|
|
1070
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1062
1071
|
}
|
|
1063
1072
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
1064
1073
|
if (!Array.isArray(pipeline.parameters)) {
|
|
@@ -2305,7 +2314,7 @@
|
|
|
2305
2314
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2306
2315
|
*/
|
|
2307
2316
|
|
|
2308
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
2317
|
+
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"}];
|
|
2309
2318
|
|
|
2310
2319
|
/**
|
|
2311
2320
|
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
@@ -3308,28 +3317,42 @@
|
|
|
3308
3317
|
return text.length;
|
|
3309
3318
|
}
|
|
3310
3319
|
|
|
3320
|
+
/**
|
|
3321
|
+
* Number of characters per standard line with 11pt Arial font size.
|
|
3322
|
+
*
|
|
3323
|
+
* @public exported from `@promptbook/utils`
|
|
3324
|
+
*/
|
|
3325
|
+
var CHARACTERS_PER_STANDARD_LINE = 63;
|
|
3326
|
+
/**
|
|
3327
|
+
* Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
|
|
3328
|
+
*
|
|
3329
|
+
* @public exported from `@promptbook/utils`
|
|
3330
|
+
*/
|
|
3331
|
+
var LINES_PER_STANDARD_PAGE = 44;
|
|
3332
|
+
|
|
3311
3333
|
/**
|
|
3312
3334
|
* Counts number of lines in the text
|
|
3313
3335
|
*
|
|
3336
|
+
* Note: This does not check only for the presence of newlines, but also for the length of the standard line.
|
|
3337
|
+
*
|
|
3314
3338
|
* @public exported from `@promptbook/utils`
|
|
3315
3339
|
*/
|
|
3316
3340
|
function countLines(text) {
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
return
|
|
3341
|
+
text = text.replace('\r\n', '\n');
|
|
3342
|
+
text = text.replace('\r', '\n');
|
|
3343
|
+
var lines = text.split('\n');
|
|
3344
|
+
return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
|
|
3321
3345
|
}
|
|
3322
3346
|
|
|
3323
3347
|
/**
|
|
3324
3348
|
* Counts number of pages in the text
|
|
3325
3349
|
*
|
|
3350
|
+
* 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.
|
|
3351
|
+
*
|
|
3326
3352
|
* @public exported from `@promptbook/utils`
|
|
3327
3353
|
*/
|
|
3328
3354
|
function countPages(text) {
|
|
3329
|
-
|
|
3330
|
-
var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
3331
|
-
var pageCount = Math.ceil(sentences.length / sentencesPerPage);
|
|
3332
|
-
return pageCount;
|
|
3355
|
+
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
3333
3356
|
}
|
|
3334
3357
|
|
|
3335
3358
|
/**
|
|
@@ -3892,7 +3915,7 @@
|
|
|
3892
3915
|
promptTitle: template.title,
|
|
3893
3916
|
promptMessage: replaceParameters(template.description || '', parameters),
|
|
3894
3917
|
defaultValue: replaceParameters(preparedContent, parameters),
|
|
3895
|
-
// TODO: [🧠] !! Figure out how to define placeholder in .
|
|
3918
|
+
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
3896
3919
|
placeholder: undefined,
|
|
3897
3920
|
priority: priority,
|
|
3898
3921
|
}))];
|
|
@@ -4458,7 +4481,7 @@
|
|
|
4458
4481
|
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
4459
4482
|
title: preparedPipeline.title,
|
|
4460
4483
|
promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
4461
|
-
promptbookRequestedVersion: preparedPipeline.
|
|
4484
|
+
promptbookRequestedVersion: preparedPipeline.bookVersion,
|
|
4462
4485
|
description: preparedPipeline.description,
|
|
4463
4486
|
promptExecutions: [],
|
|
4464
4487
|
};
|
|
@@ -4807,7 +4830,7 @@
|
|
|
4807
4830
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
4808
4831
|
_b = createPipelineExecutor;
|
|
4809
4832
|
_c = {};
|
|
4810
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.
|
|
4833
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
|
|
4811
4834
|
case 1:
|
|
4812
4835
|
preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
|
|
4813
4836
|
_c.tools = tools,
|
|
@@ -5564,13 +5587,14 @@
|
|
|
5564
5587
|
*/
|
|
5565
5588
|
function clonePipeline(pipeline) {
|
|
5566
5589
|
// Note: Not using spread operator (...) because @@@
|
|
5567
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title,
|
|
5590
|
+
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;
|
|
5568
5591
|
return {
|
|
5569
5592
|
pipelineUrl: pipelineUrl,
|
|
5570
5593
|
sourceFile: sourceFile,
|
|
5571
5594
|
title: title,
|
|
5572
|
-
|
|
5595
|
+
bookVersion: bookVersion,
|
|
5573
5596
|
description: description,
|
|
5597
|
+
formfactorName: formfactorName,
|
|
5574
5598
|
parameters: parameters,
|
|
5575
5599
|
templates: templates,
|
|
5576
5600
|
knowledgeSources: knowledgeSources,
|
|
@@ -5781,7 +5805,7 @@
|
|
|
5781
5805
|
throw new ParseError("Source not valid");
|
|
5782
5806
|
}
|
|
5783
5807
|
if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
|
|
5784
|
-
throw new ParseError("Source cannot be outside of the .
|
|
5808
|
+
throw new ParseError("Source cannot be outside of the .book.md folder");
|
|
5785
5809
|
}
|
|
5786
5810
|
return {
|
|
5787
5811
|
type: 'KNOWLEDGE',
|
|
@@ -6001,6 +6025,175 @@
|
|
|
6001
6025
|
* ```
|
|
6002
6026
|
*/
|
|
6003
6027
|
|
|
6028
|
+
/**
|
|
6029
|
+
* Parses the boilerplate command
|
|
6030
|
+
*
|
|
6031
|
+
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
|
|
6032
|
+
*
|
|
6033
|
+
* @see `documentationUrl` for more details
|
|
6034
|
+
* @private within the commands folder
|
|
6035
|
+
*/
|
|
6036
|
+
var boilerplateCommandParser = {
|
|
6037
|
+
/**
|
|
6038
|
+
* Name of the command
|
|
6039
|
+
*/
|
|
6040
|
+
name: 'BOILERPLATE',
|
|
6041
|
+
/**
|
|
6042
|
+
* Aliases for the BOILERPLATE command
|
|
6043
|
+
*/
|
|
6044
|
+
aliasNames: ['BP'],
|
|
6045
|
+
/**
|
|
6046
|
+
* BOILERPLATE command can be used in:
|
|
6047
|
+
*/
|
|
6048
|
+
isUsedInPipelineHead: true,
|
|
6049
|
+
isUsedInPipelineTemplate: true,
|
|
6050
|
+
/**
|
|
6051
|
+
* Description of the BOILERPLATE command
|
|
6052
|
+
*/
|
|
6053
|
+
description: "@@",
|
|
6054
|
+
/**
|
|
6055
|
+
* Link to documentation
|
|
6056
|
+
*/
|
|
6057
|
+
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
6058
|
+
/**
|
|
6059
|
+
* Example usages of the BOILERPLATE command
|
|
6060
|
+
*/
|
|
6061
|
+
examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
|
|
6062
|
+
/**
|
|
6063
|
+
* Parses the BOILERPLATE command
|
|
6064
|
+
*/
|
|
6065
|
+
parse: function (input) {
|
|
6066
|
+
var args = input.args;
|
|
6067
|
+
if (args.length !== 1) {
|
|
6068
|
+
throw new ParseError("BOILERPLATE command requires exactly one argument");
|
|
6069
|
+
}
|
|
6070
|
+
var value = args[0].toLowerCase();
|
|
6071
|
+
if (value.includes('brr')) {
|
|
6072
|
+
throw new ParseError("BOILERPLATE value can not contain brr");
|
|
6073
|
+
}
|
|
6074
|
+
return {
|
|
6075
|
+
type: 'BOILERPLATE',
|
|
6076
|
+
value: value,
|
|
6077
|
+
};
|
|
6078
|
+
},
|
|
6079
|
+
/**
|
|
6080
|
+
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
6081
|
+
*
|
|
6082
|
+
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
6083
|
+
*/
|
|
6084
|
+
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6085
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
6086
|
+
},
|
|
6087
|
+
/**
|
|
6088
|
+
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
6089
|
+
*
|
|
6090
|
+
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
6091
|
+
*/
|
|
6092
|
+
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
6093
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
6094
|
+
},
|
|
6095
|
+
/**
|
|
6096
|
+
* Converts the BOILERPLATE command back to string
|
|
6097
|
+
*
|
|
6098
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6099
|
+
*/
|
|
6100
|
+
stringify: function (command) {
|
|
6101
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
6102
|
+
},
|
|
6103
|
+
/**
|
|
6104
|
+
* Reads the BOILERPLATE command from the `PipelineJson`
|
|
6105
|
+
*
|
|
6106
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6107
|
+
*/
|
|
6108
|
+
takeFromPipelineJson: function (pipelineJson) {
|
|
6109
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
6110
|
+
},
|
|
6111
|
+
/**
|
|
6112
|
+
* Reads the BOILERPLATE command from the `TemplateJson`
|
|
6113
|
+
*
|
|
6114
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6115
|
+
*/
|
|
6116
|
+
takeFromTemplateJson: function ($templateJson) {
|
|
6117
|
+
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
|
|
6118
|
+
},
|
|
6119
|
+
};
|
|
6120
|
+
|
|
6121
|
+
/**
|
|
6122
|
+
* Parses the BOOK_VERSION command
|
|
6123
|
+
*
|
|
6124
|
+
* @see `documentationUrl` for more details
|
|
6125
|
+
* @private within the commands folder
|
|
6126
|
+
*/
|
|
6127
|
+
var bookVersionCommandParser = {
|
|
6128
|
+
/**
|
|
6129
|
+
* Name of the command
|
|
6130
|
+
*/
|
|
6131
|
+
name: 'BOOK_VERSION',
|
|
6132
|
+
aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
|
|
6133
|
+
/**
|
|
6134
|
+
* BOILERPLATE command can be used in:
|
|
6135
|
+
*/
|
|
6136
|
+
isUsedInPipelineHead: true,
|
|
6137
|
+
isUsedInPipelineTemplate: false,
|
|
6138
|
+
/**
|
|
6139
|
+
* Description of the BOOK_VERSION command
|
|
6140
|
+
*/
|
|
6141
|
+
description: "Which version of the Book language is the .book.md using",
|
|
6142
|
+
/**
|
|
6143
|
+
* Link to documentation
|
|
6144
|
+
*/
|
|
6145
|
+
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
|
|
6146
|
+
/**
|
|
6147
|
+
* Example usages of the BOOK_VERSION command
|
|
6148
|
+
*/
|
|
6149
|
+
examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
|
|
6150
|
+
/**
|
|
6151
|
+
* Parses the BOOK_VERSION command
|
|
6152
|
+
*/
|
|
6153
|
+
parse: function (input) {
|
|
6154
|
+
var args = input.args;
|
|
6155
|
+
var bookVersion = args.pop();
|
|
6156
|
+
if (bookVersion === undefined) {
|
|
6157
|
+
throw new ParseError("Version is required");
|
|
6158
|
+
}
|
|
6159
|
+
if (!isValidPromptbookVersion(bookVersion)) {
|
|
6160
|
+
throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
|
|
6161
|
+
}
|
|
6162
|
+
if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
|
|
6163
|
+
throw new ParseError("Can not have more than one Promptbook version");
|
|
6164
|
+
}
|
|
6165
|
+
return {
|
|
6166
|
+
type: 'BOOK_VERSION',
|
|
6167
|
+
bookVersion: bookVersion,
|
|
6168
|
+
};
|
|
6169
|
+
},
|
|
6170
|
+
/**
|
|
6171
|
+
* Apply the BOOK_VERSION command to the `pipelineJson`
|
|
6172
|
+
*
|
|
6173
|
+
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
6174
|
+
*/
|
|
6175
|
+
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6176
|
+
// TODO: Warn if the version is overridden
|
|
6177
|
+
$pipelineJson.bookVersion = command.bookVersion;
|
|
6178
|
+
},
|
|
6179
|
+
/**
|
|
6180
|
+
* Converts the BOOK_VERSION command back to string
|
|
6181
|
+
*
|
|
6182
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6183
|
+
*/
|
|
6184
|
+
stringify: function (command) {
|
|
6185
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
6186
|
+
},
|
|
6187
|
+
/**
|
|
6188
|
+
* Reads the BOOK_VERSION command from the `PipelineJson`
|
|
6189
|
+
*
|
|
6190
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6191
|
+
*/
|
|
6192
|
+
takeFromPipelineJson: function (pipelineJson) {
|
|
6193
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6194
|
+
},
|
|
6195
|
+
};
|
|
6196
|
+
|
|
6004
6197
|
/**
|
|
6005
6198
|
* Units of text measurement
|
|
6006
6199
|
*
|
|
@@ -6413,7 +6606,7 @@
|
|
|
6413
6606
|
/**
|
|
6414
6607
|
* Parses the foreach command
|
|
6415
6608
|
*
|
|
6416
|
-
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.
|
|
6609
|
+
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
|
|
6417
6610
|
*
|
|
6418
6611
|
* @see `documentationUrl` for more details
|
|
6419
6612
|
* @private within the commands folder
|
|
@@ -6563,7 +6756,7 @@
|
|
|
6563
6756
|
},
|
|
6564
6757
|
};
|
|
6565
6758
|
/**
|
|
6566
|
-
* TODO: [🍭] Make .
|
|
6759
|
+
* TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
|
|
6567
6760
|
*/
|
|
6568
6761
|
|
|
6569
6762
|
/**
|
|
@@ -6638,6 +6831,120 @@
|
|
|
6638
6831
|
},
|
|
6639
6832
|
};
|
|
6640
6833
|
|
|
6834
|
+
/**
|
|
6835
|
+
* @@@
|
|
6836
|
+
*
|
|
6837
|
+
* @public exported from `@promptbook/core`
|
|
6838
|
+
*/
|
|
6839
|
+
var ChatFormfactorDefinition = {
|
|
6840
|
+
name: 'CHAT',
|
|
6841
|
+
description: "@@@",
|
|
6842
|
+
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
|
|
6843
|
+
};
|
|
6844
|
+
|
|
6845
|
+
/**
|
|
6846
|
+
* @@@
|
|
6847
|
+
*
|
|
6848
|
+
* @public exported from `@promptbook/core`
|
|
6849
|
+
*/
|
|
6850
|
+
var GenericFormfactorDefinition = {
|
|
6851
|
+
name: 'GENERIC',
|
|
6852
|
+
description: "@@@",
|
|
6853
|
+
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
|
|
6854
|
+
};
|
|
6855
|
+
|
|
6856
|
+
/**
|
|
6857
|
+
* All available formfactor definitions
|
|
6858
|
+
*
|
|
6859
|
+
* @public exported from `@promptbook/core`
|
|
6860
|
+
*/
|
|
6861
|
+
var FORMFACTOR_DEFINITIONS = [GenericFormfactorDefinition, ChatFormfactorDefinition];
|
|
6862
|
+
|
|
6863
|
+
/**
|
|
6864
|
+
* Parses the formfactor command
|
|
6865
|
+
*
|
|
6866
|
+
* Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
|
|
6867
|
+
*
|
|
6868
|
+
* @see `documentationUrl` for more details
|
|
6869
|
+
* @private within the commands folder
|
|
6870
|
+
*/
|
|
6871
|
+
var formfactorCommandParser = {
|
|
6872
|
+
/**
|
|
6873
|
+
* Name of the command
|
|
6874
|
+
*/
|
|
6875
|
+
name: 'FORMFACTOR',
|
|
6876
|
+
/**
|
|
6877
|
+
* Aliases for the FORMFACTOR command
|
|
6878
|
+
*/
|
|
6879
|
+
aliasNames: ['FORM', 'FF'],
|
|
6880
|
+
/**
|
|
6881
|
+
* FORMFACTOR command can be used in:
|
|
6882
|
+
*/
|
|
6883
|
+
isUsedInPipelineHead: true,
|
|
6884
|
+
isUsedInPipelineTemplate: false,
|
|
6885
|
+
/**
|
|
6886
|
+
* Description of the FORMFACTOR command
|
|
6887
|
+
*/
|
|
6888
|
+
description: "@@",
|
|
6889
|
+
/**
|
|
6890
|
+
* Link to documentation
|
|
6891
|
+
*/
|
|
6892
|
+
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/168',
|
|
6893
|
+
/**
|
|
6894
|
+
* Example usages of the FORMFACTOR command
|
|
6895
|
+
*/
|
|
6896
|
+
examples: ['FORMFACTOR Chat', 'FORMFACTOR Generic'],
|
|
6897
|
+
/**
|
|
6898
|
+
* Parses the FORMFACTOR command
|
|
6899
|
+
*/
|
|
6900
|
+
parse: function (input) {
|
|
6901
|
+
var args = input.args;
|
|
6902
|
+
if (args.length !== 1) {
|
|
6903
|
+
throw new ParseError("FORMFACTOR command requires exactly one argument");
|
|
6904
|
+
}
|
|
6905
|
+
var formfactorName = args[0].toUpperCase();
|
|
6906
|
+
if (!FORMFACTOR_DEFINITIONS.some(function (definition) { return definition.name === formfactorName; })) {
|
|
6907
|
+
throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown formfactor name \"".concat(formfactorName, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
|
|
6908
|
+
var name = _a.name;
|
|
6909
|
+
return "- ".concat(name);
|
|
6910
|
+
}).join('\n')), "\n "); }));
|
|
6911
|
+
}
|
|
6912
|
+
return {
|
|
6913
|
+
type: 'FORMFACTOR',
|
|
6914
|
+
formfactorName: formfactorName,
|
|
6915
|
+
};
|
|
6916
|
+
},
|
|
6917
|
+
/**
|
|
6918
|
+
* Apply the FORMFACTOR command to the `pipelineJson`
|
|
6919
|
+
*
|
|
6920
|
+
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
6921
|
+
*/
|
|
6922
|
+
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6923
|
+
$pipelineJson.formfactorName = command.formfactorName;
|
|
6924
|
+
},
|
|
6925
|
+
/**
|
|
6926
|
+
* Converts the FORMFACTOR command back to string
|
|
6927
|
+
*
|
|
6928
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6929
|
+
*/
|
|
6930
|
+
stringify: function (command) {
|
|
6931
|
+
return "FORMFACTOR ".concat(command.formfactorName);
|
|
6932
|
+
},
|
|
6933
|
+
/**
|
|
6934
|
+
* Reads the FORMFACTOR command from the `PipelineJson`
|
|
6935
|
+
*
|
|
6936
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
6937
|
+
*/
|
|
6938
|
+
takeFromPipelineJson: function (pipelineJson) {
|
|
6939
|
+
return [
|
|
6940
|
+
{
|
|
6941
|
+
type: 'FORMFACTOR',
|
|
6942
|
+
formfactorName: pipelineJson.formfactorName,
|
|
6943
|
+
},
|
|
6944
|
+
];
|
|
6945
|
+
},
|
|
6946
|
+
};
|
|
6947
|
+
|
|
6641
6948
|
/**
|
|
6642
6949
|
* Parses the joker command
|
|
6643
6950
|
*
|
|
@@ -7178,88 +7485,12 @@
|
|
|
7178
7485
|
};
|
|
7179
7486
|
|
|
7180
7487
|
/**
|
|
7181
|
-
* Parses the
|
|
7488
|
+
* Parses the url command
|
|
7182
7489
|
*
|
|
7183
7490
|
* @see `documentationUrl` for more details
|
|
7184
7491
|
* @private within the commands folder
|
|
7185
7492
|
*/
|
|
7186
|
-
var
|
|
7187
|
-
/**
|
|
7188
|
-
* Name of the command
|
|
7189
|
-
*/
|
|
7190
|
-
name: 'BOOK_VERSION',
|
|
7191
|
-
aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
|
|
7192
|
-
/**
|
|
7193
|
-
* BOILERPLATE command can be used in:
|
|
7194
|
-
*/
|
|
7195
|
-
isUsedInPipelineHead: true,
|
|
7196
|
-
isUsedInPipelineTemplate: false,
|
|
7197
|
-
/**
|
|
7198
|
-
* Description of the BOOK_VERSION command
|
|
7199
|
-
*/
|
|
7200
|
-
description: "Which version of the Book language is the .ptbk.md using",
|
|
7201
|
-
/**
|
|
7202
|
-
* Link to documentation
|
|
7203
|
-
*/
|
|
7204
|
-
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
|
|
7205
|
-
/**
|
|
7206
|
-
* Example usages of the BOOK_VERSION command
|
|
7207
|
-
*/
|
|
7208
|
-
examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
|
|
7209
|
-
/**
|
|
7210
|
-
* Parses the BOOK_VERSION command
|
|
7211
|
-
*/
|
|
7212
|
-
parse: function (input) {
|
|
7213
|
-
var args = input.args;
|
|
7214
|
-
var promptbookVersion = args.pop();
|
|
7215
|
-
if (promptbookVersion === undefined) {
|
|
7216
|
-
throw new ParseError("Version is required");
|
|
7217
|
-
}
|
|
7218
|
-
if (!isValidPromptbookVersion(promptbookVersion)) {
|
|
7219
|
-
throw new ParseError("Invalid Promptbook version \"".concat(promptbookVersion, "\""));
|
|
7220
|
-
}
|
|
7221
|
-
if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
|
|
7222
|
-
throw new ParseError("Can not have more than one Promptbook version");
|
|
7223
|
-
}
|
|
7224
|
-
return {
|
|
7225
|
-
type: 'BOOK_VERSION',
|
|
7226
|
-
promptbookVersion: promptbookVersion,
|
|
7227
|
-
};
|
|
7228
|
-
},
|
|
7229
|
-
/**
|
|
7230
|
-
* Apply the BOOK_VERSION command to the `pipelineJson`
|
|
7231
|
-
*
|
|
7232
|
-
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7233
|
-
*/
|
|
7234
|
-
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7235
|
-
// TODO: Warn if the version is overridden
|
|
7236
|
-
$pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
7237
|
-
},
|
|
7238
|
-
/**
|
|
7239
|
-
* Converts the BOOK_VERSION command back to string
|
|
7240
|
-
*
|
|
7241
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7242
|
-
*/
|
|
7243
|
-
stringify: function (command) {
|
|
7244
|
-
return "---"; // <- TODO: [🛋] Implement
|
|
7245
|
-
},
|
|
7246
|
-
/**
|
|
7247
|
-
* Reads the BOOK_VERSION command from the `PipelineJson`
|
|
7248
|
-
*
|
|
7249
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7250
|
-
*/
|
|
7251
|
-
takeFromPipelineJson: function (pipelineJson) {
|
|
7252
|
-
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7253
|
-
},
|
|
7254
|
-
};
|
|
7255
|
-
|
|
7256
|
-
/**
|
|
7257
|
-
* Parses the url command
|
|
7258
|
-
*
|
|
7259
|
-
* @see `documentationUrl` for more details
|
|
7260
|
-
* @private within the commands folder
|
|
7261
|
-
*/
|
|
7262
|
-
var urlCommandParser = {
|
|
7493
|
+
var urlCommandParser = {
|
|
7263
7494
|
/**
|
|
7264
7495
|
* Name of the command
|
|
7265
7496
|
*/
|
|
@@ -7286,9 +7517,9 @@
|
|
|
7286
7517
|
* Example usages of the URL command
|
|
7287
7518
|
*/
|
|
7288
7519
|
examples: [
|
|
7289
|
-
'PIPELINE URL https://promptbook.studio/library/write-cv.
|
|
7290
|
-
'URL https://promptbook.studio/library/write-cv.
|
|
7291
|
-
'https://promptbook.studio/library/write-cv.
|
|
7520
|
+
'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
|
|
7521
|
+
'URL https://promptbook.studio/library/write-cv.book.md',
|
|
7522
|
+
'https://promptbook.studio/library/write-cv.book.md',
|
|
7292
7523
|
],
|
|
7293
7524
|
/**
|
|
7294
7525
|
* Parses the URL command
|
|
@@ -7486,99 +7717,6 @@
|
|
|
7486
7717
|
* Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
|
|
7487
7718
|
*/
|
|
7488
7719
|
|
|
7489
|
-
/**
|
|
7490
|
-
* Parses the boilerplate command
|
|
7491
|
-
*
|
|
7492
|
-
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.ptbk.md` file
|
|
7493
|
-
*
|
|
7494
|
-
* @see `documentationUrl` for more details
|
|
7495
|
-
* @private within the commands folder
|
|
7496
|
-
*/
|
|
7497
|
-
var boilerplateCommandParser = {
|
|
7498
|
-
/**
|
|
7499
|
-
* Name of the command
|
|
7500
|
-
*/
|
|
7501
|
-
name: 'BOILERPLATE',
|
|
7502
|
-
/**
|
|
7503
|
-
* Aliases for the BOILERPLATE command
|
|
7504
|
-
*/
|
|
7505
|
-
aliasNames: ['BP'],
|
|
7506
|
-
/**
|
|
7507
|
-
* BOILERPLATE command can be used in:
|
|
7508
|
-
*/
|
|
7509
|
-
isUsedInPipelineHead: true,
|
|
7510
|
-
isUsedInPipelineTemplate: true,
|
|
7511
|
-
/**
|
|
7512
|
-
* Description of the BOILERPLATE command
|
|
7513
|
-
*/
|
|
7514
|
-
description: "@@",
|
|
7515
|
-
/**
|
|
7516
|
-
* Link to documentation
|
|
7517
|
-
*/
|
|
7518
|
-
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
7519
|
-
/**
|
|
7520
|
-
* Example usages of the BOILERPLATE command
|
|
7521
|
-
*/
|
|
7522
|
-
examples: ['BOILERPLATE foo', 'BOILERPLATE bar', 'BP foo', 'BP bar'],
|
|
7523
|
-
/**
|
|
7524
|
-
* Parses the BOILERPLATE command
|
|
7525
|
-
*/
|
|
7526
|
-
parse: function (input) {
|
|
7527
|
-
var args = input.args;
|
|
7528
|
-
if (args.length !== 1) {
|
|
7529
|
-
throw new ParseError("BOILERPLATE command requires exactly one argument");
|
|
7530
|
-
}
|
|
7531
|
-
var value = args[0].toLowerCase();
|
|
7532
|
-
if (value.includes('brr')) {
|
|
7533
|
-
throw new ParseError("BOILERPLATE value can not contain brr");
|
|
7534
|
-
}
|
|
7535
|
-
return {
|
|
7536
|
-
type: 'BOILERPLATE',
|
|
7537
|
-
value: value,
|
|
7538
|
-
};
|
|
7539
|
-
},
|
|
7540
|
-
/**
|
|
7541
|
-
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
7542
|
-
*
|
|
7543
|
-
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7544
|
-
*/
|
|
7545
|
-
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7546
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7547
|
-
},
|
|
7548
|
-
/**
|
|
7549
|
-
* Apply the BOILERPLATE command to the `pipelineJson`
|
|
7550
|
-
*
|
|
7551
|
-
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
7552
|
-
*/
|
|
7553
|
-
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
7554
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7555
|
-
},
|
|
7556
|
-
/**
|
|
7557
|
-
* Converts the BOILERPLATE command back to string
|
|
7558
|
-
*
|
|
7559
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7560
|
-
*/
|
|
7561
|
-
stringify: function (command) {
|
|
7562
|
-
return "---"; // <- TODO: [🛋] Implement
|
|
7563
|
-
},
|
|
7564
|
-
/**
|
|
7565
|
-
* Reads the BOILERPLATE command from the `PipelineJson`
|
|
7566
|
-
*
|
|
7567
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7568
|
-
*/
|
|
7569
|
-
takeFromPipelineJson: function (pipelineJson) {
|
|
7570
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7571
|
-
},
|
|
7572
|
-
/**
|
|
7573
|
-
* Reads the BOILERPLATE command from the `TemplateJson`
|
|
7574
|
-
*
|
|
7575
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
7576
|
-
*/
|
|
7577
|
-
takeFromTemplateJson: function ($templateJson) {
|
|
7578
|
-
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7579
|
-
},
|
|
7580
|
-
};
|
|
7581
|
-
|
|
7582
7720
|
/**
|
|
7583
7721
|
* All available command parsers
|
|
7584
7722
|
*
|
|
@@ -7593,6 +7731,7 @@
|
|
|
7593
7731
|
parameterCommandParser,
|
|
7594
7732
|
postprocessCommandParser,
|
|
7595
7733
|
bookVersionCommandParser,
|
|
7734
|
+
formfactorCommandParser,
|
|
7596
7735
|
urlCommandParser,
|
|
7597
7736
|
knowledgeCommandParser,
|
|
7598
7737
|
actionCommandParser,
|
|
@@ -7904,7 +8043,7 @@
|
|
|
7904
8043
|
return;
|
|
7905
8044
|
}
|
|
7906
8045
|
if (!section.startsWith('#')) {
|
|
7907
|
-
section = "#
|
|
8046
|
+
section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
|
|
7908
8047
|
}
|
|
7909
8048
|
sections.push(section);
|
|
7910
8049
|
buffer = [];
|
|
@@ -7968,7 +8107,7 @@
|
|
|
7968
8107
|
var e_1, _a;
|
|
7969
8108
|
var sections = splitMarkdownIntoSections(markdown);
|
|
7970
8109
|
if (sections.length === 0) {
|
|
7971
|
-
return
|
|
8110
|
+
return "# ".concat(DEFAULT_TITLE);
|
|
7972
8111
|
}
|
|
7973
8112
|
var flattenedMarkdown = '';
|
|
7974
8113
|
var parsedSections = sections.map(parseMarkdownSection);
|
|
@@ -7979,7 +8118,7 @@
|
|
|
7979
8118
|
}
|
|
7980
8119
|
else {
|
|
7981
8120
|
parsedSections.unshift(firstSection);
|
|
7982
|
-
flattenedMarkdown += "#
|
|
8121
|
+
flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
|
|
7983
8122
|
}
|
|
7984
8123
|
try {
|
|
7985
8124
|
for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
|
|
@@ -8051,18 +8190,19 @@
|
|
|
8051
8190
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
8052
8191
|
* Note: This function acts as compilation process
|
|
8053
8192
|
*
|
|
8054
|
-
* @param pipelineString {Promptbook} in string markdown format (.
|
|
8055
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
8193
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
8194
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
8056
8195
|
* @throws {ParseError} if the promptbook string is not valid
|
|
8057
8196
|
* @public exported from `@promptbook/core`
|
|
8058
8197
|
*/
|
|
8059
8198
|
function pipelineStringToJsonSync(pipelineString) {
|
|
8060
|
-
var e_1, _a, e_2, _b;
|
|
8199
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
8061
8200
|
var $pipelineJson = {
|
|
8062
8201
|
title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
|
|
8063
8202
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
8064
|
-
|
|
8203
|
+
bookVersion: undefined /* <- Note: By default no explicit version */,
|
|
8065
8204
|
description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
|
|
8205
|
+
formfactorName: 'GENERIC',
|
|
8066
8206
|
parameters: [],
|
|
8067
8207
|
templates: [],
|
|
8068
8208
|
knowledgeSources: [],
|
|
@@ -8085,7 +8225,7 @@
|
|
|
8085
8225
|
// =============================================================
|
|
8086
8226
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
8087
8227
|
if (pipelineString.startsWith('#!')) {
|
|
8088
|
-
var
|
|
8228
|
+
var _e = __read(pipelineString.split('\n')), shebangLine_1 = _e[0], restLines = _e.slice(1);
|
|
8089
8229
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
8090
8230
|
throw new ParseError(spaceTrim.spaceTrim(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 "); }));
|
|
8091
8231
|
}
|
|
@@ -8095,7 +8235,7 @@
|
|
|
8095
8235
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
8096
8236
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
8097
8237
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
8098
|
-
var
|
|
8238
|
+
var _f = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _f[0], pipelineSections = _f.slice(1); /* <- Note: [🥞] */
|
|
8099
8239
|
if (pipelineHead === undefined) {
|
|
8100
8240
|
throw new UnexpectedError(spaceTrim.spaceTrim(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 "); }));
|
|
8101
8241
|
}
|
|
@@ -8123,6 +8263,8 @@
|
|
|
8123
8263
|
if (parameterDescription) {
|
|
8124
8264
|
existingParameter.description = parameterDescription;
|
|
8125
8265
|
}
|
|
8266
|
+
existingParameter.isInput = existingParameter.isInput || isInput;
|
|
8267
|
+
existingParameter.isOutput = existingParameter.isOutput || isOutput;
|
|
8126
8268
|
}
|
|
8127
8269
|
else {
|
|
8128
8270
|
$pipelineJson.parameters.push({
|
|
@@ -8185,10 +8327,10 @@
|
|
|
8185
8327
|
finally { if (e_1) throw e_1.error; }
|
|
8186
8328
|
}
|
|
8187
8329
|
var _loop_2 = function (section) {
|
|
8188
|
-
var
|
|
8330
|
+
var e_5, _l, e_6, _m;
|
|
8189
8331
|
// TODO: Parse template description (the content out of the codeblock and lists)
|
|
8190
8332
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
8191
|
-
var
|
|
8333
|
+
var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
|
|
8192
8334
|
// TODO: [🎾][1] DRY description
|
|
8193
8335
|
var description_1 = section.content;
|
|
8194
8336
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -8229,7 +8371,7 @@
|
|
|
8229
8371
|
}) === false) {
|
|
8230
8372
|
templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
|
|
8231
8373
|
}
|
|
8232
|
-
var
|
|
8374
|
+
var _loop_4 = function (listItem, command) {
|
|
8233
8375
|
var commandParser = getParserForCommand(command);
|
|
8234
8376
|
if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
|
|
8235
8377
|
throw new ParseError(spaceTrim.spaceTrim(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: [🚞]
|
|
@@ -8252,17 +8394,17 @@
|
|
|
8252
8394
|
};
|
|
8253
8395
|
try {
|
|
8254
8396
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
8255
|
-
for (var commands_1 = (
|
|
8256
|
-
var
|
|
8257
|
-
|
|
8397
|
+
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()) {
|
|
8398
|
+
var _p = commands_1_1.value, listItem = _p.listItem, command = _p.command;
|
|
8399
|
+
_loop_4(listItem, command);
|
|
8258
8400
|
}
|
|
8259
8401
|
}
|
|
8260
|
-
catch (
|
|
8402
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
8261
8403
|
finally {
|
|
8262
8404
|
try {
|
|
8263
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
8405
|
+
if (commands_1_1 && !commands_1_1.done && (_l = commands_1.return)) _l.call(commands_1);
|
|
8264
8406
|
}
|
|
8265
|
-
finally { if (
|
|
8407
|
+
finally { if (e_5) throw e_5.error; }
|
|
8266
8408
|
}
|
|
8267
8409
|
// TODO: [🍧] Should be done in TEMPLATE command
|
|
8268
8410
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
@@ -8276,6 +8418,26 @@
|
|
|
8276
8418
|
language;
|
|
8277
8419
|
}
|
|
8278
8420
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
8421
|
+
try {
|
|
8422
|
+
for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
8423
|
+
var parameterName = _r.value;
|
|
8424
|
+
// TODO: [🧠] This definition should be made first in the template
|
|
8425
|
+
defineParam({
|
|
8426
|
+
parameterName: parameterName,
|
|
8427
|
+
parameterDescription: null,
|
|
8428
|
+
isInput: false,
|
|
8429
|
+
isOutput: false,
|
|
8430
|
+
// <- 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
|
|
8431
|
+
});
|
|
8432
|
+
}
|
|
8433
|
+
}
|
|
8434
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
8435
|
+
finally {
|
|
8436
|
+
try {
|
|
8437
|
+
if (_r && !_r.done && (_m = _q.return)) _m.call(_q);
|
|
8438
|
+
}
|
|
8439
|
+
finally { if (e_6) throw e_6.error; }
|
|
8440
|
+
}
|
|
8279
8441
|
/*
|
|
8280
8442
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
8281
8443
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
@@ -8317,9 +8479,51 @@
|
|
|
8317
8479
|
finally { if (e_2) throw e_2.error; }
|
|
8318
8480
|
}
|
|
8319
8481
|
// =============================================================
|
|
8320
|
-
// Note: 5️⃣
|
|
8482
|
+
// Note: 5️⃣ Mark parameters as INPUT if not explicitly set
|
|
8483
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
8484
|
+
var _loop_3 = function (parameter) {
|
|
8485
|
+
var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
|
|
8486
|
+
if (!isThisParameterResulting) {
|
|
8487
|
+
parameter.isInput = true;
|
|
8488
|
+
}
|
|
8489
|
+
};
|
|
8490
|
+
try {
|
|
8491
|
+
for (var _g = __values($pipelineJson.parameters), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
8492
|
+
var parameter = _h.value;
|
|
8493
|
+
_loop_3(parameter);
|
|
8494
|
+
}
|
|
8495
|
+
}
|
|
8496
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
8497
|
+
finally {
|
|
8498
|
+
try {
|
|
8499
|
+
if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
|
|
8500
|
+
}
|
|
8501
|
+
finally { if (e_3) throw e_3.error; }
|
|
8502
|
+
}
|
|
8503
|
+
}
|
|
8504
|
+
// =============================================================
|
|
8505
|
+
// Note: 6️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
8506
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
8507
|
+
try {
|
|
8508
|
+
for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
8509
|
+
var parameter = _k.value;
|
|
8510
|
+
if (!parameter.isInput) {
|
|
8511
|
+
parameter.isOutput = true;
|
|
8512
|
+
}
|
|
8513
|
+
}
|
|
8514
|
+
}
|
|
8515
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
8516
|
+
finally {
|
|
8517
|
+
try {
|
|
8518
|
+
if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
|
|
8519
|
+
}
|
|
8520
|
+
finally { if (e_4) throw e_4.error; }
|
|
8521
|
+
}
|
|
8522
|
+
}
|
|
8523
|
+
// =============================================================
|
|
8524
|
+
// Note: 7️⃣ Cleanup of undefined values
|
|
8321
8525
|
$pipelineJson.templates.forEach(function (templates) {
|
|
8322
|
-
var
|
|
8526
|
+
var e_7, _a;
|
|
8323
8527
|
try {
|
|
8324
8528
|
for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8325
8529
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8328,16 +8532,16 @@
|
|
|
8328
8532
|
}
|
|
8329
8533
|
}
|
|
8330
8534
|
}
|
|
8331
|
-
catch (
|
|
8535
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
8332
8536
|
finally {
|
|
8333
8537
|
try {
|
|
8334
8538
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8335
8539
|
}
|
|
8336
|
-
finally { if (
|
|
8540
|
+
finally { if (e_7) throw e_7.error; }
|
|
8337
8541
|
}
|
|
8338
8542
|
});
|
|
8339
8543
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
8340
|
-
var
|
|
8544
|
+
var e_8, _a;
|
|
8341
8545
|
try {
|
|
8342
8546
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8343
8547
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8346,12 +8550,12 @@
|
|
|
8346
8550
|
}
|
|
8347
8551
|
}
|
|
8348
8552
|
}
|
|
8349
|
-
catch (
|
|
8553
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
8350
8554
|
finally {
|
|
8351
8555
|
try {
|
|
8352
8556
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8353
8557
|
}
|
|
8354
|
-
finally { if (
|
|
8558
|
+
finally { if (e_8) throw e_8.error; }
|
|
8355
8559
|
}
|
|
8356
8560
|
});
|
|
8357
8561
|
// =============================================================
|
|
@@ -8380,10 +8584,10 @@
|
|
|
8380
8584
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
8381
8585
|
* Note: This function acts as compilation process
|
|
8382
8586
|
*
|
|
8383
|
-
* @param pipelineString {Promptbook} in string markdown format (.
|
|
8587
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
8384
8588
|
* @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
|
|
8385
8589
|
* @param options - Options and tools for the compilation
|
|
8386
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
8590
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
8387
8591
|
* @throws {ParseError} if the promptbook string is not valid
|
|
8388
8592
|
* @public exported from `@promptbook/core`
|
|
8389
8593
|
*/
|
|
@@ -8599,7 +8803,7 @@
|
|
|
8599
8803
|
return pipelineJsonStringified;
|
|
8600
8804
|
}
|
|
8601
8805
|
/**
|
|
8602
|
-
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.
|
|
8806
|
+
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
|
|
8603
8807
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
8604
8808
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
8605
8809
|
* TODO: [🍙] Make some standard order of json properties
|
|
@@ -8873,7 +9077,7 @@
|
|
|
8873
9077
|
*/
|
|
8874
9078
|
|
|
8875
9079
|
/**
|
|
8876
|
-
* Stores
|
|
9080
|
+
* Stores data in memory (HEAP)
|
|
8877
9081
|
*
|
|
8878
9082
|
* @public exported from `@promptbook/core`
|
|
8879
9083
|
*/
|
|
@@ -9003,13 +9207,18 @@
|
|
|
9003
9207
|
promptResult = _c.sent();
|
|
9004
9208
|
return [3 /*break*/, 11];
|
|
9005
9209
|
case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
|
|
9006
|
-
case 11:
|
|
9210
|
+
case 11:
|
|
9211
|
+
// TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
|
|
9212
|
+
// promptResult.timing: FromtoItems
|
|
9213
|
+
return [4 /*yield*/, storage.setItem(key, {
|
|
9007
9214
|
date: $currentDate(),
|
|
9008
9215
|
promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
9009
9216
|
prompt: prompt,
|
|
9010
9217
|
promptResult: promptResult,
|
|
9011
9218
|
})];
|
|
9012
9219
|
case 12:
|
|
9220
|
+
// TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
|
|
9221
|
+
// promptResult.timing: FromtoItems
|
|
9013
9222
|
_c.sent();
|
|
9014
9223
|
return [2 /*return*/, promptResult];
|
|
9015
9224
|
}
|
|
@@ -9261,6 +9470,83 @@
|
|
|
9261
9470
|
},
|
|
9262
9471
|
});
|
|
9263
9472
|
|
|
9473
|
+
/**
|
|
9474
|
+
* @@@
|
|
9475
|
+
*
|
|
9476
|
+
* @public exported from `@promptbook/core`
|
|
9477
|
+
*/
|
|
9478
|
+
function getPipelineInterface(pipeline) {
|
|
9479
|
+
var e_1, _a, e_2, _b;
|
|
9480
|
+
var pipelineInterface = {
|
|
9481
|
+
inputParameterNames: [],
|
|
9482
|
+
outputParameterNames: [],
|
|
9483
|
+
};
|
|
9484
|
+
try {
|
|
9485
|
+
for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
9486
|
+
var parameter = _d.value;
|
|
9487
|
+
var name_1 = parameter.name, isInput = parameter.isInput, isOutput = parameter.isOutput;
|
|
9488
|
+
if (isInput) {
|
|
9489
|
+
pipelineInterface.inputParameterNames.push(name_1);
|
|
9490
|
+
}
|
|
9491
|
+
if (isOutput) {
|
|
9492
|
+
pipelineInterface.outputParameterNames.push(name_1);
|
|
9493
|
+
}
|
|
9494
|
+
}
|
|
9495
|
+
}
|
|
9496
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
9497
|
+
finally {
|
|
9498
|
+
try {
|
|
9499
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
9500
|
+
}
|
|
9501
|
+
finally { if (e_1) throw e_1.error; }
|
|
9502
|
+
}
|
|
9503
|
+
try {
|
|
9504
|
+
for (var _e = __values(['inputParameterNames', 'outputParameterNames']), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
9505
|
+
var key = _f.value;
|
|
9506
|
+
pipelineInterface[key].sort(function (a, b) { return a.localeCompare(b); });
|
|
9507
|
+
}
|
|
9508
|
+
}
|
|
9509
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
9510
|
+
finally {
|
|
9511
|
+
try {
|
|
9512
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
9513
|
+
}
|
|
9514
|
+
finally { if (e_2) throw e_2.error; }
|
|
9515
|
+
}
|
|
9516
|
+
return Object.freeze(pipelineInterface);
|
|
9517
|
+
}
|
|
9518
|
+
/**
|
|
9519
|
+
* TODO: !!!!!! Write unit test
|
|
9520
|
+
*/
|
|
9521
|
+
|
|
9522
|
+
/**
|
|
9523
|
+
* @@@
|
|
9524
|
+
*
|
|
9525
|
+
* @public exported from `@promptbook/core`
|
|
9526
|
+
*/
|
|
9527
|
+
function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
|
|
9528
|
+
// TODO: [🧠] !!! Implement better
|
|
9529
|
+
return JSON.stringify(pipelineInterface1) === JSON.stringify(pipelineInterface2);
|
|
9530
|
+
}
|
|
9531
|
+
/**
|
|
9532
|
+
* TODO: [🧠] !!! Return more states than true/false - 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
|
|
9533
|
+
* TODO: !!! Write unit test
|
|
9534
|
+
*/
|
|
9535
|
+
|
|
9536
|
+
/**
|
|
9537
|
+
* @@@
|
|
9538
|
+
*
|
|
9539
|
+
* @public exported from `@promptbook/core`
|
|
9540
|
+
*/
|
|
9541
|
+
function isPipelineImplementingInterface(options) {
|
|
9542
|
+
var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
|
|
9543
|
+
return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
|
|
9544
|
+
}
|
|
9545
|
+
/**
|
|
9546
|
+
* TODO: !!!!!! Test real implementing NOT equality
|
|
9547
|
+
* TODO: !!!!!! Write unit test
|
|
9548
|
+
*/
|
|
9549
|
+
|
|
9264
9550
|
/**
|
|
9265
9551
|
* Metadata of the scraper
|
|
9266
9552
|
*
|
|
@@ -9385,6 +9671,54 @@
|
|
|
9385
9671
|
*/
|
|
9386
9672
|
var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
|
|
9387
9673
|
|
|
9674
|
+
/**
|
|
9675
|
+
* Behaves like a storage but forgets everything you put in it
|
|
9676
|
+
*
|
|
9677
|
+
* @public exported from `@promptbook/core`
|
|
9678
|
+
*/
|
|
9679
|
+
var BlackholeStorage = /** @class */ (function () {
|
|
9680
|
+
function BlackholeStorage() {
|
|
9681
|
+
}
|
|
9682
|
+
Object.defineProperty(BlackholeStorage.prototype, "length", {
|
|
9683
|
+
/**
|
|
9684
|
+
* Returns the number of key/value pairs currently present in the list associated with the object.
|
|
9685
|
+
*/
|
|
9686
|
+
get: function () {
|
|
9687
|
+
return 0;
|
|
9688
|
+
},
|
|
9689
|
+
enumerable: false,
|
|
9690
|
+
configurable: true
|
|
9691
|
+
});
|
|
9692
|
+
/**
|
|
9693
|
+
* Empties the list associated with the object of all key/value pairs, if there are any.
|
|
9694
|
+
*/
|
|
9695
|
+
BlackholeStorage.prototype.clear = function () { };
|
|
9696
|
+
/**
|
|
9697
|
+
* 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.
|
|
9698
|
+
* @param key
|
|
9699
|
+
*/
|
|
9700
|
+
BlackholeStorage.prototype.getItem = function (key) {
|
|
9701
|
+
return null;
|
|
9702
|
+
};
|
|
9703
|
+
/**
|
|
9704
|
+
* 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.
|
|
9705
|
+
*/
|
|
9706
|
+
BlackholeStorage.prototype.key = function (index) {
|
|
9707
|
+
return null;
|
|
9708
|
+
};
|
|
9709
|
+
/**
|
|
9710
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
9711
|
+
*/
|
|
9712
|
+
BlackholeStorage.prototype.setItem = function (key, value) {
|
|
9713
|
+
};
|
|
9714
|
+
/**
|
|
9715
|
+
* 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.
|
|
9716
|
+
*/
|
|
9717
|
+
BlackholeStorage.prototype.removeItem = function (key) {
|
|
9718
|
+
};
|
|
9719
|
+
return BlackholeStorage;
|
|
9720
|
+
}());
|
|
9721
|
+
|
|
9388
9722
|
/**
|
|
9389
9723
|
* This class behaves like LocalStorage but separates keys by prefix
|
|
9390
9724
|
*
|
|
@@ -9741,8 +10075,10 @@
|
|
|
9741
10075
|
exports.$scrapersRegister = $scrapersRegister;
|
|
9742
10076
|
exports.AbstractFormatError = AbstractFormatError;
|
|
9743
10077
|
exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
|
|
10078
|
+
exports.BlackholeStorage = BlackholeStorage;
|
|
9744
10079
|
exports.CLAIM = CLAIM;
|
|
9745
10080
|
exports.CallbackInterfaceTools = CallbackInterfaceTools;
|
|
10081
|
+
exports.ChatFormfactorDefinition = ChatFormfactorDefinition;
|
|
9746
10082
|
exports.CollectionError = CollectionError;
|
|
9747
10083
|
exports.CsvFormatDefinition = CsvFormatDefinition;
|
|
9748
10084
|
exports.CsvFormatError = CsvFormatError;
|
|
@@ -9759,11 +10095,14 @@
|
|
|
9759
10095
|
exports.DEFAULT_REMOTE_URL = DEFAULT_REMOTE_URL;
|
|
9760
10096
|
exports.DEFAULT_REMOTE_URL_PATH = DEFAULT_REMOTE_URL_PATH;
|
|
9761
10097
|
exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
|
|
10098
|
+
exports.DEFAULT_TITLE = DEFAULT_TITLE;
|
|
9762
10099
|
exports.ERRORS = ERRORS;
|
|
9763
10100
|
exports.EXPECTATION_UNITS = EXPECTATION_UNITS;
|
|
9764
10101
|
exports.EnvironmentMismatchError = EnvironmentMismatchError;
|
|
9765
10102
|
exports.ExecutionReportStringOptionsDefaults = ExecutionReportStringOptionsDefaults;
|
|
9766
10103
|
exports.ExpectError = ExpectError;
|
|
10104
|
+
exports.FORMFACTOR_DEFINITIONS = FORMFACTOR_DEFINITIONS;
|
|
10105
|
+
exports.GenericFormfactorDefinition = GenericFormfactorDefinition;
|
|
9767
10106
|
exports.KnowledgeScrapeError = KnowledgeScrapeError;
|
|
9768
10107
|
exports.LimitReachedError = LimitReachedError;
|
|
9769
10108
|
exports.MANDATORY_CSV_SETTINGS = MANDATORY_CSV_SETTINGS;
|
|
@@ -9808,7 +10147,10 @@
|
|
|
9808
10147
|
exports.createSubcollection = createSubcollection;
|
|
9809
10148
|
exports.embeddingVectorToString = embeddingVectorToString;
|
|
9810
10149
|
exports.executionReportJsonToString = executionReportJsonToString;
|
|
10150
|
+
exports.getPipelineInterface = getPipelineInterface;
|
|
9811
10151
|
exports.isPassingExpectations = isPassingExpectations;
|
|
10152
|
+
exports.isPipelineImplementingInterface = isPipelineImplementingInterface;
|
|
10153
|
+
exports.isPipelineInterfacesEqual = isPipelineInterfacesEqual;
|
|
9812
10154
|
exports.isPipelinePrepared = isPipelinePrepared;
|
|
9813
10155
|
exports.joinLlmExecutionTools = joinLlmExecutionTools;
|
|
9814
10156
|
exports.limitTotalUsage = limitTotalUsage;
|