@promptbook/core 0.78.3 → 0.79.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 -2
- package/esm/index.es.js +227 -165
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -2
- package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +6 -1
- package/esm/typings/src/formfactors/index.d.ts +12 -2
- package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +6 -1
- package/package.json +1 -1
- package/umd/index.umd.js +227 -165
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# ❄ Promptbook
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## ❄ New Features
|
|
18
18
|
|
|
19
19
|
- 💙 Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
|
|
20
20
|
- 🖤 Run books from CLI - `npx ptbk run path/to/your/book`
|
package/esm/index.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.78.
|
|
26
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.78.4';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1247,6 +1247,9 @@ function extractParameterNames(template) {
|
|
|
1247
1247
|
*/
|
|
1248
1248
|
function $deepFreeze(objectValue) {
|
|
1249
1249
|
var e_1, _a;
|
|
1250
|
+
if (Array.isArray(objectValue)) {
|
|
1251
|
+
return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
|
|
1252
|
+
}
|
|
1250
1253
|
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1251
1254
|
try {
|
|
1252
1255
|
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
@@ -5948,6 +5951,133 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
5948
5951
|
* @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
|
|
5949
5952
|
*/
|
|
5950
5953
|
|
|
5954
|
+
/**
|
|
5955
|
+
* @@@
|
|
5956
|
+
*
|
|
5957
|
+
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
5958
|
+
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
5959
|
+
*
|
|
5960
|
+
* @public exported from `@promptbook/core`
|
|
5961
|
+
*/
|
|
5962
|
+
function getPipelineInterface(pipeline) {
|
|
5963
|
+
var e_1, _a, e_2, _b;
|
|
5964
|
+
var pipelineInterface = {
|
|
5965
|
+
inputParameters: [],
|
|
5966
|
+
outputParameters: [],
|
|
5967
|
+
};
|
|
5968
|
+
try {
|
|
5969
|
+
for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
5970
|
+
var parameter = _d.value;
|
|
5971
|
+
var isInput = parameter.isInput, isOutput = parameter.isOutput;
|
|
5972
|
+
if (isInput) {
|
|
5973
|
+
pipelineInterface.inputParameters.push(deepClone(parameter));
|
|
5974
|
+
}
|
|
5975
|
+
if (isOutput) {
|
|
5976
|
+
pipelineInterface.outputParameters.push(deepClone(parameter));
|
|
5977
|
+
}
|
|
5978
|
+
}
|
|
5979
|
+
}
|
|
5980
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5981
|
+
finally {
|
|
5982
|
+
try {
|
|
5983
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
5984
|
+
}
|
|
5985
|
+
finally { if (e_1) throw e_1.error; }
|
|
5986
|
+
}
|
|
5987
|
+
try {
|
|
5988
|
+
for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
5989
|
+
var key = _f.value;
|
|
5990
|
+
pipelineInterface[key].sort(function (_a, _b) {
|
|
5991
|
+
var name1 = _a.name;
|
|
5992
|
+
var name2 = _b.name;
|
|
5993
|
+
return name1.localeCompare(name2);
|
|
5994
|
+
});
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
5998
|
+
finally {
|
|
5999
|
+
try {
|
|
6000
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
6001
|
+
}
|
|
6002
|
+
finally { if (e_2) throw e_2.error; }
|
|
6003
|
+
}
|
|
6004
|
+
return $deepFreeze(pipelineInterface);
|
|
6005
|
+
}
|
|
6006
|
+
|
|
6007
|
+
/**
|
|
6008
|
+
* @@@
|
|
6009
|
+
*
|
|
6010
|
+
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
6011
|
+
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
6012
|
+
*
|
|
6013
|
+
* @public exported from `@promptbook/core`
|
|
6014
|
+
*/
|
|
6015
|
+
function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
|
|
6016
|
+
var e_1, _a, e_2, _b;
|
|
6017
|
+
try {
|
|
6018
|
+
for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
6019
|
+
var whichParameters = _d.value;
|
|
6020
|
+
var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
|
|
6021
|
+
var parameters2 = pipelineInterface2[whichParameters];
|
|
6022
|
+
if (parameters1.length !== parameters2.length) {
|
|
6023
|
+
return false;
|
|
6024
|
+
}
|
|
6025
|
+
var _loop_1 = function (parameter) {
|
|
6026
|
+
var matchingParameter = parameters2.find(function (_a) {
|
|
6027
|
+
var name = _a.name;
|
|
6028
|
+
return name === parameter.name;
|
|
6029
|
+
});
|
|
6030
|
+
if (!matchingParameter) {
|
|
6031
|
+
return { value: false };
|
|
6032
|
+
}
|
|
6033
|
+
// Note: Do not compare description, it is not relevant for compatibility
|
|
6034
|
+
if (matchingParameter.isInput !== parameter.isInput) {
|
|
6035
|
+
return { value: false };
|
|
6036
|
+
}
|
|
6037
|
+
if (matchingParameter.isOutput !== parameter.isOutput) {
|
|
6038
|
+
return { value: false };
|
|
6039
|
+
}
|
|
6040
|
+
};
|
|
6041
|
+
try {
|
|
6042
|
+
for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
|
|
6043
|
+
var parameter = parameters1_1_1.value;
|
|
6044
|
+
var state_1 = _loop_1(parameter);
|
|
6045
|
+
if (typeof state_1 === "object")
|
|
6046
|
+
return state_1.value;
|
|
6047
|
+
}
|
|
6048
|
+
}
|
|
6049
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
6050
|
+
finally {
|
|
6051
|
+
try {
|
|
6052
|
+
if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
|
|
6053
|
+
}
|
|
6054
|
+
finally { if (e_2) throw e_2.error; }
|
|
6055
|
+
}
|
|
6056
|
+
}
|
|
6057
|
+
}
|
|
6058
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6059
|
+
finally {
|
|
6060
|
+
try {
|
|
6061
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
6062
|
+
}
|
|
6063
|
+
finally { if (e_1) throw e_1.error; }
|
|
6064
|
+
}
|
|
6065
|
+
return true;
|
|
6066
|
+
}
|
|
6067
|
+
|
|
6068
|
+
/**
|
|
6069
|
+
* @@@
|
|
6070
|
+
*
|
|
6071
|
+
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
6072
|
+
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
6073
|
+
*
|
|
6074
|
+
* @public exported from `@promptbook/core`
|
|
6075
|
+
*/
|
|
6076
|
+
function isPipelineImplementingInterface(options) {
|
|
6077
|
+
var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
|
|
6078
|
+
return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
|
|
6079
|
+
}
|
|
6080
|
+
|
|
5951
6081
|
/**
|
|
5952
6082
|
* All available task types
|
|
5953
6083
|
*
|
|
@@ -7107,7 +7237,13 @@ var GeneratorFormfactorDefinition = {
|
|
|
7107
7237
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
|
|
7108
7238
|
pipelineInterface: {
|
|
7109
7239
|
inputParameters: [
|
|
7110
|
-
|
|
7240
|
+
/* @@@ */
|
|
7241
|
+
{
|
|
7242
|
+
name: 'nonce',
|
|
7243
|
+
description: 'Just to prevent GENERATOR to be set as implicit formfactor',
|
|
7244
|
+
isInput: true,
|
|
7245
|
+
isOutput: false,
|
|
7246
|
+
},
|
|
7111
7247
|
],
|
|
7112
7248
|
outputParameters: [
|
|
7113
7249
|
/* @@@ */
|
|
@@ -7153,7 +7289,13 @@ var MatcherFormfactorDefinition = {
|
|
|
7153
7289
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
|
|
7154
7290
|
pipelineInterface: {
|
|
7155
7291
|
inputParameters: [
|
|
7156
|
-
|
|
7292
|
+
/* @@@ */
|
|
7293
|
+
{
|
|
7294
|
+
name: 'nonce',
|
|
7295
|
+
description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
|
|
7296
|
+
isInput: true,
|
|
7297
|
+
isOutput: false,
|
|
7298
|
+
},
|
|
7157
7299
|
],
|
|
7158
7300
|
outputParameters: [
|
|
7159
7301
|
/* @@@ */
|
|
@@ -7302,6 +7444,9 @@ var formfactorCommandParser = {
|
|
|
7302
7444
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7303
7445
|
*/
|
|
7304
7446
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7447
|
+
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
7448
|
+
throw new ParseError(spaceTrim("\n Redefinition of `FORMFACTOR` in the pipeline head\n\n You have used:\n 1) FORMFACTOR `".concat($pipelineJson.formfactorName, "`\n 2) FORMFACTOR `").concat(command.formfactorName, "`\n ")));
|
|
7449
|
+
}
|
|
7305
7450
|
$pipelineJson.formfactorName = command.formfactorName;
|
|
7306
7451
|
},
|
|
7307
7452
|
/**
|
|
@@ -7489,7 +7634,7 @@ var modelCommandParser = {
|
|
|
7489
7634
|
// <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
|
|
7490
7635
|
}
|
|
7491
7636
|
else {
|
|
7492
|
-
throw new ParseError(spaceTrim("\n Redefinition of MODEL
|
|
7637
|
+
throw new ParseError(spaceTrim("\n Redefinition of `MODEL ".concat(command.key, "` in the pipeline head\n\n You have used:\n 1) `MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "`\n 2) `MODEL ").concat(command.key, " ").concat(command.value, "`\n ")));
|
|
7493
7638
|
}
|
|
7494
7639
|
}
|
|
7495
7640
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
@@ -8582,20 +8727,15 @@ function titleToName(value) {
|
|
|
8582
8727
|
* @public exported from `@promptbook/core`
|
|
8583
8728
|
*/
|
|
8584
8729
|
function pipelineStringToJsonSync(pipelineString) {
|
|
8585
|
-
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
|
|
8730
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
8586
8731
|
var $pipelineJson = {
|
|
8587
|
-
title:
|
|
8588
|
-
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
8589
|
-
bookVersion: undefined /* <- Note: By default no explicit version */,
|
|
8590
|
-
description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
|
|
8591
|
-
formfactorName: 'GENERIC',
|
|
8732
|
+
title: DEFAULT_TITLE,
|
|
8592
8733
|
parameters: [],
|
|
8593
8734
|
tasks: [],
|
|
8594
8735
|
knowledgeSources: [],
|
|
8595
8736
|
knowledgePieces: [],
|
|
8596
8737
|
personas: [],
|
|
8597
8738
|
preparations: [],
|
|
8598
|
-
// <- TODO: [🍙] Some standard order of properties
|
|
8599
8739
|
};
|
|
8600
8740
|
function getPipelineIdentification() {
|
|
8601
8741
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -8611,7 +8751,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8611
8751
|
// =============================================================
|
|
8612
8752
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
8613
8753
|
if (pipelineString.startsWith('#!')) {
|
|
8614
|
-
var
|
|
8754
|
+
var _g = __read(pipelineString.split('\n')), shebangLine_1 = _g[0], restLines = _g.slice(1);
|
|
8615
8755
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
8616
8756
|
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 "); }));
|
|
8617
8757
|
}
|
|
@@ -8621,7 +8761,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8621
8761
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
8622
8762
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
8623
8763
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
8624
|
-
var
|
|
8764
|
+
var _h = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _h[0], pipelineSections = _h.slice(1); /* <- Note: [🥞] */
|
|
8625
8765
|
if (pipelineHead === undefined) {
|
|
8626
8766
|
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 "); }));
|
|
8627
8767
|
}
|
|
@@ -8743,10 +8883,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8743
8883
|
return nameWithSuffix;
|
|
8744
8884
|
};
|
|
8745
8885
|
var _loop_2 = function (section) {
|
|
8746
|
-
var
|
|
8886
|
+
var e_7, _o, e_8, _p;
|
|
8747
8887
|
// TODO: Parse section's description (the content out of the codeblock and lists)
|
|
8748
8888
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
8749
|
-
var
|
|
8889
|
+
var _q = extractOneBlockFromMarkdown(section.content), language = _q.language, content = _q.content;
|
|
8750
8890
|
// TODO: [🎾][1] DRY description
|
|
8751
8891
|
var description_1 = section.content;
|
|
8752
8892
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -8810,17 +8950,17 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8810
8950
|
};
|
|
8811
8951
|
try {
|
|
8812
8952
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
8813
|
-
for (var commands_1 = (
|
|
8814
|
-
var
|
|
8953
|
+
for (var commands_1 = (e_7 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
8954
|
+
var _r = commands_1_1.value, listItem = _r.listItem, command = _r.command;
|
|
8815
8955
|
_loop_4(listItem, command);
|
|
8816
8956
|
}
|
|
8817
8957
|
}
|
|
8818
|
-
catch (
|
|
8958
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
8819
8959
|
finally {
|
|
8820
8960
|
try {
|
|
8821
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
8961
|
+
if (commands_1_1 && !commands_1_1.done && (_o = commands_1.return)) _o.call(commands_1);
|
|
8822
8962
|
}
|
|
8823
|
-
finally { if (
|
|
8963
|
+
finally { if (e_7) throw e_7.error; }
|
|
8824
8964
|
}
|
|
8825
8965
|
// TODO: [🍧] Should be done in SECTION command
|
|
8826
8966
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
@@ -8834,8 +8974,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8834
8974
|
}
|
|
8835
8975
|
$taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
|
|
8836
8976
|
try {
|
|
8837
|
-
for (var
|
|
8838
|
-
var parameterName =
|
|
8977
|
+
for (var _s = (e_8 = void 0, __values($taskJson.dependentParameterNames)), _t = _s.next(); !_t.done; _t = _s.next()) {
|
|
8978
|
+
var parameterName = _t.value;
|
|
8839
8979
|
// TODO: [🧠] This definition should be made first in the task
|
|
8840
8980
|
defineParam({
|
|
8841
8981
|
parameterName: parameterName,
|
|
@@ -8846,12 +8986,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8846
8986
|
});
|
|
8847
8987
|
}
|
|
8848
8988
|
}
|
|
8849
|
-
catch (
|
|
8989
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
8850
8990
|
finally {
|
|
8851
8991
|
try {
|
|
8852
|
-
if (
|
|
8992
|
+
if (_t && !_t.done && (_p = _s.return)) _p.call(_s);
|
|
8853
8993
|
}
|
|
8854
|
-
finally { if (
|
|
8994
|
+
finally { if (e_8) throw e_8.error; }
|
|
8855
8995
|
}
|
|
8856
8996
|
/*
|
|
8857
8997
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
@@ -8900,18 +9040,22 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8900
9040
|
var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
|
|
8901
9041
|
if (!isThisParameterResulting) {
|
|
8902
9042
|
parameter.isInput = true;
|
|
9043
|
+
// <- TODO: [💔] Why this is making typescript error in vscode but not in cli
|
|
9044
|
+
// > Type 'true' is not assignable to type 'false'.ts(2322)
|
|
9045
|
+
// > (property) isInput: false
|
|
9046
|
+
// > The parameter is input of the pipeline The parameter is NOT input of the pipeline
|
|
8903
9047
|
}
|
|
8904
9048
|
};
|
|
8905
9049
|
try {
|
|
8906
|
-
for (var
|
|
8907
|
-
var parameter =
|
|
9050
|
+
for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
9051
|
+
var parameter = _k.value;
|
|
8908
9052
|
_loop_3(parameter);
|
|
8909
9053
|
}
|
|
8910
9054
|
}
|
|
8911
9055
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
8912
9056
|
finally {
|
|
8913
9057
|
try {
|
|
8914
|
-
if (
|
|
9058
|
+
if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
|
|
8915
9059
|
}
|
|
8916
9060
|
finally { if (e_4) throw e_4.error; }
|
|
8917
9061
|
}
|
|
@@ -8920,17 +9064,18 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8920
9064
|
// Note: 7️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
8921
9065
|
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
8922
9066
|
try {
|
|
8923
|
-
for (var
|
|
8924
|
-
var parameter =
|
|
9067
|
+
for (var _l = __values($pipelineJson.parameters), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
9068
|
+
var parameter = _m.value;
|
|
8925
9069
|
if (!parameter.isInput) {
|
|
8926
9070
|
parameter.isOutput = true;
|
|
9071
|
+
// <- TODO: [💔]
|
|
8927
9072
|
}
|
|
8928
9073
|
}
|
|
8929
9074
|
}
|
|
8930
9075
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
8931
9076
|
finally {
|
|
8932
9077
|
try {
|
|
8933
|
-
if (
|
|
9078
|
+
if (_m && !_m.done && (_e = _l.return)) _e.call(_l);
|
|
8934
9079
|
}
|
|
8935
9080
|
finally { if (e_5) throw e_5.error; }
|
|
8936
9081
|
}
|
|
@@ -8938,7 +9083,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8938
9083
|
// =============================================================
|
|
8939
9084
|
// Note: 8️⃣ Cleanup of undefined values
|
|
8940
9085
|
$pipelineJson.tasks.forEach(function (tasks) {
|
|
8941
|
-
var
|
|
9086
|
+
var e_9, _a;
|
|
8942
9087
|
try {
|
|
8943
9088
|
for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8944
9089
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8947,16 +9092,16 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8947
9092
|
}
|
|
8948
9093
|
}
|
|
8949
9094
|
}
|
|
8950
|
-
catch (
|
|
9095
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
8951
9096
|
finally {
|
|
8952
9097
|
try {
|
|
8953
9098
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8954
9099
|
}
|
|
8955
|
-
finally { if (
|
|
9100
|
+
finally { if (e_9) throw e_9.error; }
|
|
8956
9101
|
}
|
|
8957
9102
|
});
|
|
8958
9103
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
8959
|
-
var
|
|
9104
|
+
var e_10, _a;
|
|
8960
9105
|
try {
|
|
8961
9106
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8962
9107
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8965,17 +9110,61 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8965
9110
|
}
|
|
8966
9111
|
}
|
|
8967
9112
|
}
|
|
8968
|
-
catch (
|
|
9113
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
8969
9114
|
finally {
|
|
8970
9115
|
try {
|
|
8971
9116
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8972
9117
|
}
|
|
8973
|
-
finally { if (
|
|
9118
|
+
finally { if (e_10) throw e_10.error; }
|
|
8974
9119
|
}
|
|
8975
9120
|
});
|
|
9121
|
+
try {
|
|
9122
|
+
// =============================================================
|
|
9123
|
+
// Note: 9️⃣ Implicit and default formfactor
|
|
9124
|
+
for (var FORMFACTOR_DEFINITIONS_1 = __values(FORMFACTOR_DEFINITIONS), FORMFACTOR_DEFINITIONS_1_1 = FORMFACTOR_DEFINITIONS_1.next(); !FORMFACTOR_DEFINITIONS_1_1.done; FORMFACTOR_DEFINITIONS_1_1 = FORMFACTOR_DEFINITIONS_1.next()) {
|
|
9125
|
+
var formfactorDefinition = FORMFACTOR_DEFINITIONS_1_1.value;
|
|
9126
|
+
// <- Note: [♓️][💩] This is the order of the formfactors, make some explicit priority
|
|
9127
|
+
var name_2 = formfactorDefinition.name, pipelineInterface = formfactorDefinition.pipelineInterface;
|
|
9128
|
+
// Note: Skip GENERIC formfactor, it will be used as a fallback if no other formfactor is compatible
|
|
9129
|
+
if (name_2 === 'GENERIC') {
|
|
9130
|
+
continue;
|
|
9131
|
+
}
|
|
9132
|
+
var isCompatible = isPipelineImplementingInterface({
|
|
9133
|
+
pipeline: __assign({ formfactorName: name_2 }, $pipelineJson),
|
|
9134
|
+
pipelineInterface: pipelineInterface,
|
|
9135
|
+
});
|
|
9136
|
+
/*/
|
|
9137
|
+
console.log({
|
|
9138
|
+
subject: `${$pipelineJson.title} implements ${name}`,
|
|
9139
|
+
pipelineTitle: $pipelineJson.title,
|
|
9140
|
+
formfactorName: name,
|
|
9141
|
+
isCompatible,
|
|
9142
|
+
formfactorInterface: pipelineInterface,
|
|
9143
|
+
pipelineInterface: getPipelineInterface($pipelineJson as PipelineJson),
|
|
9144
|
+
});
|
|
9145
|
+
/**/
|
|
9146
|
+
if (isCompatible) {
|
|
9147
|
+
$pipelineJson.formfactorName = name_2;
|
|
9148
|
+
break;
|
|
9149
|
+
}
|
|
9150
|
+
}
|
|
9151
|
+
}
|
|
9152
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
9153
|
+
finally {
|
|
9154
|
+
try {
|
|
9155
|
+
if (FORMFACTOR_DEFINITIONS_1_1 && !FORMFACTOR_DEFINITIONS_1_1.done && (_f = FORMFACTOR_DEFINITIONS_1.return)) _f.call(FORMFACTOR_DEFINITIONS_1);
|
|
9156
|
+
}
|
|
9157
|
+
finally { if (e_6) throw e_6.error; }
|
|
9158
|
+
}
|
|
9159
|
+
// Note: [🔆] If formfactor is still not set, set it to 'GENERIC'
|
|
9160
|
+
if ($pipelineJson.formfactorName === undefined) {
|
|
9161
|
+
$pipelineJson.formfactorName = 'GENERIC';
|
|
9162
|
+
}
|
|
8976
9163
|
// =============================================================
|
|
8977
9164
|
// TODO: [🍙] Maybe do reorder of `$pipelineJson` here
|
|
8978
|
-
return $asDeeplyFrozenSerializableJson('pipelineJson',
|
|
9165
|
+
return $asDeeplyFrozenSerializableJson('pipelineJson', __assign({ title: DEFAULT_TITLE, pipelineUrl: undefined, bookVersion: undefined, description: undefined, formfactorName: 'GENERIC',
|
|
9166
|
+
// <- Note: [🔆] Setting `formfactorName` is redundant to satisfy the typescript
|
|
9167
|
+
parameters: [], tasks: [], knowledgeSources: [], knowledgePieces: [], personas: [], preparations: [] }, $pipelineJson));
|
|
8979
9168
|
}
|
|
8980
9169
|
/**
|
|
8981
9170
|
* TODO: [main] !!!! Warn if used only sync version
|
|
@@ -10494,133 +10683,6 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
10494
10683
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
10495
10684
|
*/
|
|
10496
10685
|
|
|
10497
|
-
/**
|
|
10498
|
-
* @@@
|
|
10499
|
-
*
|
|
10500
|
-
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
10501
|
-
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
10502
|
-
*
|
|
10503
|
-
* @public exported from `@promptbook/core`
|
|
10504
|
-
*/
|
|
10505
|
-
function getPipelineInterface(pipeline) {
|
|
10506
|
-
var e_1, _a, e_2, _b;
|
|
10507
|
-
var pipelineInterface = {
|
|
10508
|
-
inputParameters: [],
|
|
10509
|
-
outputParameters: [],
|
|
10510
|
-
};
|
|
10511
|
-
try {
|
|
10512
|
-
for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
10513
|
-
var parameter = _d.value;
|
|
10514
|
-
var isInput = parameter.isInput, isOutput = parameter.isOutput;
|
|
10515
|
-
if (isInput) {
|
|
10516
|
-
pipelineInterface.inputParameters.push(parameter);
|
|
10517
|
-
}
|
|
10518
|
-
if (isOutput) {
|
|
10519
|
-
pipelineInterface.outputParameters.push(parameter);
|
|
10520
|
-
}
|
|
10521
|
-
}
|
|
10522
|
-
}
|
|
10523
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
10524
|
-
finally {
|
|
10525
|
-
try {
|
|
10526
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
10527
|
-
}
|
|
10528
|
-
finally { if (e_1) throw e_1.error; }
|
|
10529
|
-
}
|
|
10530
|
-
try {
|
|
10531
|
-
for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
10532
|
-
var key = _f.value;
|
|
10533
|
-
pipelineInterface[key].sort(function (_a, _b) {
|
|
10534
|
-
var name1 = _a.name;
|
|
10535
|
-
var name2 = _b.name;
|
|
10536
|
-
return name1.localeCompare(name2);
|
|
10537
|
-
});
|
|
10538
|
-
}
|
|
10539
|
-
}
|
|
10540
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
10541
|
-
finally {
|
|
10542
|
-
try {
|
|
10543
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
10544
|
-
}
|
|
10545
|
-
finally { if (e_2) throw e_2.error; }
|
|
10546
|
-
}
|
|
10547
|
-
return $deepFreeze(pipelineInterface);
|
|
10548
|
-
}
|
|
10549
|
-
|
|
10550
|
-
/**
|
|
10551
|
-
* @@@
|
|
10552
|
-
*
|
|
10553
|
-
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
10554
|
-
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
10555
|
-
*
|
|
10556
|
-
* @public exported from `@promptbook/core`
|
|
10557
|
-
*/
|
|
10558
|
-
function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
|
|
10559
|
-
var e_1, _a, e_2, _b;
|
|
10560
|
-
try {
|
|
10561
|
-
for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
10562
|
-
var whichParameters = _d.value;
|
|
10563
|
-
var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
|
|
10564
|
-
var parameters2 = pipelineInterface2[whichParameters];
|
|
10565
|
-
if (parameters1.length !== parameters2.length) {
|
|
10566
|
-
return false;
|
|
10567
|
-
}
|
|
10568
|
-
var _loop_1 = function (parameter) {
|
|
10569
|
-
var matchingParameter = parameters2.find(function (_a) {
|
|
10570
|
-
var name = _a.name;
|
|
10571
|
-
return name === parameter.name;
|
|
10572
|
-
});
|
|
10573
|
-
if (!matchingParameter) {
|
|
10574
|
-
return { value: false };
|
|
10575
|
-
}
|
|
10576
|
-
// Note: Do not compare description, it is not relevant for compatibility
|
|
10577
|
-
if (matchingParameter.isInput !== parameter.isInput) {
|
|
10578
|
-
return { value: false };
|
|
10579
|
-
}
|
|
10580
|
-
if (matchingParameter.isOutput !== parameter.isOutput) {
|
|
10581
|
-
return { value: false };
|
|
10582
|
-
}
|
|
10583
|
-
};
|
|
10584
|
-
try {
|
|
10585
|
-
for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
|
|
10586
|
-
var parameter = parameters1_1_1.value;
|
|
10587
|
-
var state_1 = _loop_1(parameter);
|
|
10588
|
-
if (typeof state_1 === "object")
|
|
10589
|
-
return state_1.value;
|
|
10590
|
-
}
|
|
10591
|
-
}
|
|
10592
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
10593
|
-
finally {
|
|
10594
|
-
try {
|
|
10595
|
-
if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
|
|
10596
|
-
}
|
|
10597
|
-
finally { if (e_2) throw e_2.error; }
|
|
10598
|
-
}
|
|
10599
|
-
}
|
|
10600
|
-
}
|
|
10601
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
10602
|
-
finally {
|
|
10603
|
-
try {
|
|
10604
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
10605
|
-
}
|
|
10606
|
-
finally { if (e_1) throw e_1.error; }
|
|
10607
|
-
}
|
|
10608
|
-
return true;
|
|
10609
|
-
}
|
|
10610
|
-
|
|
10611
|
-
/**
|
|
10612
|
-
* @@@
|
|
10613
|
-
*
|
|
10614
|
-
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
10615
|
-
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
10616
|
-
*
|
|
10617
|
-
* @public exported from `@promptbook/core`
|
|
10618
|
-
*/
|
|
10619
|
-
function isPipelineImplementingInterface(options) {
|
|
10620
|
-
var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
|
|
10621
|
-
return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
|
|
10622
|
-
}
|
|
10623
|
-
|
|
10624
10686
|
/**
|
|
10625
10687
|
* Metadata of the scraper
|
|
10626
10688
|
*
|