@promptbook/cli 0.77.0-6 → 0.77.1
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 +1 -5
- package/esm/index.es.js +129 -69
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/errors/0-index.d.ts +46 -1
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +2 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +0 -4
- package/package.json +1 -1
- package/umd/index.umd.js +129 -69
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
<blockquote style="color: #ff8811">
|
|
27
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
-
</blockquote>
|
|
29
|
-
|
|
30
26
|
## 📦 Package `@promptbook/cli`
|
|
31
27
|
|
|
32
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -96,7 +92,7 @@ There is also a javascript and json format available.
|
|
|
96
92
|
## Prettify
|
|
97
93
|
|
|
98
94
|
```bash
|
|
99
|
-
npx ptbk prettify promptbook/**/*.book.md
|
|
95
|
+
npx ptbk prettify 'promptbook/**/*.book.md'
|
|
100
96
|
```
|
|
101
97
|
|
|
102
98
|
This will prettify all promptbooks in `promptbook` directory and adds Mermaid graphs to them.
|
package/esm/index.es.js
CHANGED
|
@@ -37,7 +37,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
37
37
|
*
|
|
38
38
|
* @see https://github.com/webgptorg/promptbook
|
|
39
39
|
*/
|
|
40
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.0
|
|
40
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.0';
|
|
41
41
|
/**
|
|
42
42
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
43
43
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1978,7 +1978,14 @@ var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
|
|
|
1978
1978
|
*/
|
|
1979
1979
|
function $registeredLlmToolsMessage() {
|
|
1980
1980
|
var e_1, _a, e_2, _b;
|
|
1981
|
-
var env
|
|
1981
|
+
var env;
|
|
1982
|
+
if ($isRunningInNode()) {
|
|
1983
|
+
env = process.env;
|
|
1984
|
+
// <- TODO: [⚛] Some DRY way how to get to `process.env` and pass it into functions - ACRY search for `env`
|
|
1985
|
+
}
|
|
1986
|
+
else {
|
|
1987
|
+
env = {};
|
|
1988
|
+
}
|
|
1982
1989
|
/**
|
|
1983
1990
|
* Mixes registered LLM tools from $llmToolsMetadataRegister and $llmToolsRegister
|
|
1984
1991
|
*/
|
|
@@ -3616,7 +3623,7 @@ var LimitReachedError = /** @class */ (function (_super) {
|
|
|
3616
3623
|
*
|
|
3617
3624
|
* @public exported from `@promptbook/core`
|
|
3618
3625
|
*/
|
|
3619
|
-
var
|
|
3626
|
+
var PROMPTBOOK_ERRORS = {
|
|
3620
3627
|
AbstractFormatError: AbstractFormatError,
|
|
3621
3628
|
CsvFormatError: CsvFormatError,
|
|
3622
3629
|
CollectionError: CollectionError,
|
|
@@ -3634,6 +3641,35 @@ var ERRORS = {
|
|
|
3634
3641
|
UnexpectedError: UnexpectedError,
|
|
3635
3642
|
// TODO: [🪑]> VersionMismatchError,
|
|
3636
3643
|
};
|
|
3644
|
+
/**
|
|
3645
|
+
* Index of all javascript errors
|
|
3646
|
+
*
|
|
3647
|
+
* @private for internal usage
|
|
3648
|
+
*/
|
|
3649
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
3650
|
+
Error: Error,
|
|
3651
|
+
EvalError: EvalError,
|
|
3652
|
+
RangeError: RangeError,
|
|
3653
|
+
ReferenceError: ReferenceError,
|
|
3654
|
+
SyntaxError: SyntaxError,
|
|
3655
|
+
TypeError: TypeError,
|
|
3656
|
+
URIError: URIError,
|
|
3657
|
+
AggregateError: AggregateError,
|
|
3658
|
+
/*
|
|
3659
|
+
Note: Not widely supported
|
|
3660
|
+
> InternalError,
|
|
3661
|
+
> ModuleError,
|
|
3662
|
+
> HeapError,
|
|
3663
|
+
> WebAssemblyCompileError,
|
|
3664
|
+
> WebAssemblyRuntimeError,
|
|
3665
|
+
*/
|
|
3666
|
+
};
|
|
3667
|
+
/**
|
|
3668
|
+
* Index of all errors
|
|
3669
|
+
*
|
|
3670
|
+
* @private for internal usage
|
|
3671
|
+
*/
|
|
3672
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
3637
3673
|
/**
|
|
3638
3674
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3639
3675
|
*/
|
|
@@ -3644,11 +3680,11 @@ var ERRORS = {
|
|
|
3644
3680
|
* @public exported from `@promptbook/utils`
|
|
3645
3681
|
*/
|
|
3646
3682
|
function deserializeError(error) {
|
|
3647
|
-
|
|
3648
|
-
|
|
3683
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
3684
|
+
if (ErrorClass === undefined) {
|
|
3685
|
+
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
3649
3686
|
}
|
|
3650
|
-
|
|
3651
|
-
return new CustomError(error.message);
|
|
3687
|
+
return new ErrorClass(error.message);
|
|
3652
3688
|
}
|
|
3653
3689
|
|
|
3654
3690
|
/**
|
|
@@ -3722,8 +3758,8 @@ function isPipelinePrepared(pipeline) {
|
|
|
3722
3758
|
*/
|
|
3723
3759
|
function serializeError(error) {
|
|
3724
3760
|
var name = error.name, message = error.message, stack = error.stack;
|
|
3725
|
-
if (!
|
|
3726
|
-
|
|
3761
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3762
|
+
console.error(spaceTrim$1(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
3727
3763
|
}
|
|
3728
3764
|
return {
|
|
3729
3765
|
name: name,
|
|
@@ -9036,7 +9072,7 @@ function removeContentComments(content) {
|
|
|
9036
9072
|
* @public exported from `@promptbook/core`
|
|
9037
9073
|
*/
|
|
9038
9074
|
function pipelineStringToJsonSync(pipelineString) {
|
|
9039
|
-
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
9075
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
|
|
9040
9076
|
var $pipelineJson = {
|
|
9041
9077
|
title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
|
|
9042
9078
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
@@ -9065,7 +9101,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9065
9101
|
// =============================================================
|
|
9066
9102
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
9067
9103
|
if (pipelineString.startsWith('#!')) {
|
|
9068
|
-
var
|
|
9104
|
+
var _f = __read(pipelineString.split('\n')), shebangLine_1 = _f[0], restLines = _f.slice(1);
|
|
9069
9105
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
9070
9106
|
throw new ParseError(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 "); }));
|
|
9071
9107
|
}
|
|
@@ -9075,7 +9111,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9075
9111
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
9076
9112
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
9077
9113
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
9078
|
-
var
|
|
9114
|
+
var _g = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _g[0], pipelineSections = _g.slice(1); /* <- Note: [🥞] */
|
|
9079
9115
|
if (pipelineHead === undefined) {
|
|
9080
9116
|
throw new UnexpectedError(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 "); }));
|
|
9081
9117
|
}
|
|
@@ -9166,11 +9202,41 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9166
9202
|
}
|
|
9167
9203
|
finally { if (e_1) throw e_1.error; }
|
|
9168
9204
|
}
|
|
9205
|
+
// =============================================================
|
|
9206
|
+
// Note: 4️⃣ Prepare unique section names with indexes when needed
|
|
9207
|
+
var sectionCounts = {};
|
|
9208
|
+
try {
|
|
9209
|
+
for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
|
|
9210
|
+
var section = pipelineSections_1_1.value;
|
|
9211
|
+
var name_1 = titleToName(section.title);
|
|
9212
|
+
if (sectionCounts[name_1] === undefined) {
|
|
9213
|
+
sectionCounts[name_1] = { count: 0, currentIndex: 0 };
|
|
9214
|
+
}
|
|
9215
|
+
sectionCounts[name_1].count++;
|
|
9216
|
+
}
|
|
9217
|
+
}
|
|
9218
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
9219
|
+
finally {
|
|
9220
|
+
try {
|
|
9221
|
+
if (pipelineSections_1_1 && !pipelineSections_1_1.done && (_b = pipelineSections_1.return)) _b.call(pipelineSections_1);
|
|
9222
|
+
}
|
|
9223
|
+
finally { if (e_2) throw e_2.error; }
|
|
9224
|
+
}
|
|
9225
|
+
var getUniqueSectionName = function (title) {
|
|
9226
|
+
var name = titleToName(title);
|
|
9227
|
+
var count = sectionCounts[name];
|
|
9228
|
+
if (count.count === 1) {
|
|
9229
|
+
return name;
|
|
9230
|
+
}
|
|
9231
|
+
var nameWithSuffix = "".concat(name, "-").concat(count.currentIndex);
|
|
9232
|
+
count.currentIndex++;
|
|
9233
|
+
return nameWithSuffix;
|
|
9234
|
+
};
|
|
9169
9235
|
var _loop_2 = function (section) {
|
|
9170
|
-
var
|
|
9236
|
+
var e_6, _m, e_7, _o;
|
|
9171
9237
|
// TODO: Parse section's description (the content out of the codeblock and lists)
|
|
9172
9238
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
9173
|
-
var
|
|
9239
|
+
var _p = extractOneBlockFromMarkdown(section.content), language = _p.language, content = _p.content;
|
|
9174
9240
|
// TODO: [🎾][1] DRY description
|
|
9175
9241
|
var description_1 = section.content;
|
|
9176
9242
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -9186,7 +9252,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9186
9252
|
isSectionTypeSet: false,
|
|
9187
9253
|
isTask: true,
|
|
9188
9254
|
taskType: undefined /* <- Note: [🍙] Putting here placeholder to keep `taskType` on top at final JSON */,
|
|
9189
|
-
name:
|
|
9255
|
+
name: getUniqueSectionName(section.title),
|
|
9190
9256
|
title: section.title,
|
|
9191
9257
|
description: description_1,
|
|
9192
9258
|
content: content,
|
|
@@ -9234,17 +9300,17 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9234
9300
|
};
|
|
9235
9301
|
try {
|
|
9236
9302
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
9237
|
-
for (var commands_1 = (
|
|
9238
|
-
var
|
|
9303
|
+
for (var commands_1 = (e_6 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
9304
|
+
var _q = commands_1_1.value, listItem = _q.listItem, command = _q.command;
|
|
9239
9305
|
_loop_4(listItem, command);
|
|
9240
9306
|
}
|
|
9241
9307
|
}
|
|
9242
|
-
catch (
|
|
9308
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
9243
9309
|
finally {
|
|
9244
9310
|
try {
|
|
9245
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
9311
|
+
if (commands_1_1 && !commands_1_1.done && (_m = commands_1.return)) _m.call(commands_1);
|
|
9246
9312
|
}
|
|
9247
|
-
finally { if (
|
|
9313
|
+
finally { if (e_6) throw e_6.error; }
|
|
9248
9314
|
}
|
|
9249
9315
|
// TODO: [🍧] Should be done in SECTION command
|
|
9250
9316
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
@@ -9258,8 +9324,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9258
9324
|
}
|
|
9259
9325
|
$taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
|
|
9260
9326
|
try {
|
|
9261
|
-
for (var
|
|
9262
|
-
var parameterName =
|
|
9327
|
+
for (var _r = (e_7 = void 0, __values($taskJson.dependentParameterNames)), _s = _r.next(); !_s.done; _s = _r.next()) {
|
|
9328
|
+
var parameterName = _s.value;
|
|
9263
9329
|
// TODO: [🧠] This definition should be made first in the task
|
|
9264
9330
|
defineParam({
|
|
9265
9331
|
parameterName: parameterName,
|
|
@@ -9270,12 +9336,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9270
9336
|
});
|
|
9271
9337
|
}
|
|
9272
9338
|
}
|
|
9273
|
-
catch (
|
|
9339
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
9274
9340
|
finally {
|
|
9275
9341
|
try {
|
|
9276
|
-
if (
|
|
9342
|
+
if (_s && !_s.done && (_o = _r.return)) _o.call(_r);
|
|
9277
9343
|
}
|
|
9278
|
-
finally { if (
|
|
9344
|
+
finally { if (e_7) throw e_7.error; }
|
|
9279
9345
|
}
|
|
9280
9346
|
/*
|
|
9281
9347
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
@@ -9304,21 +9370,21 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9304
9370
|
};
|
|
9305
9371
|
try {
|
|
9306
9372
|
// =============================================================
|
|
9307
|
-
// Note:
|
|
9308
|
-
for (var
|
|
9309
|
-
var section =
|
|
9373
|
+
// Note: 5️⃣ Process each section of the pipeline
|
|
9374
|
+
for (var pipelineSections_2 = __values(pipelineSections), pipelineSections_2_1 = pipelineSections_2.next(); !pipelineSections_2_1.done; pipelineSections_2_1 = pipelineSections_2.next()) {
|
|
9375
|
+
var section = pipelineSections_2_1.value;
|
|
9310
9376
|
_loop_2(section);
|
|
9311
9377
|
}
|
|
9312
9378
|
}
|
|
9313
|
-
catch (
|
|
9379
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
9314
9380
|
finally {
|
|
9315
9381
|
try {
|
|
9316
|
-
if (
|
|
9382
|
+
if (pipelineSections_2_1 && !pipelineSections_2_1.done && (_c = pipelineSections_2.return)) _c.call(pipelineSections_2);
|
|
9317
9383
|
}
|
|
9318
|
-
finally { if (
|
|
9384
|
+
finally { if (e_3) throw e_3.error; }
|
|
9319
9385
|
}
|
|
9320
9386
|
// =============================================================
|
|
9321
|
-
// Note:
|
|
9387
|
+
// Note: 6️⃣ Mark parameters as INPUT if not explicitly set
|
|
9322
9388
|
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
9323
9389
|
var _loop_3 = function (parameter) {
|
|
9324
9390
|
var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
|
|
@@ -9327,42 +9393,42 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9327
9393
|
}
|
|
9328
9394
|
};
|
|
9329
9395
|
try {
|
|
9330
|
-
for (var
|
|
9331
|
-
var parameter =
|
|
9396
|
+
for (var _h = __values($pipelineJson.parameters), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
9397
|
+
var parameter = _j.value;
|
|
9332
9398
|
_loop_3(parameter);
|
|
9333
9399
|
}
|
|
9334
9400
|
}
|
|
9335
|
-
catch (
|
|
9401
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
9336
9402
|
finally {
|
|
9337
9403
|
try {
|
|
9338
|
-
if (
|
|
9404
|
+
if (_j && !_j.done && (_d = _h.return)) _d.call(_h);
|
|
9339
9405
|
}
|
|
9340
|
-
finally { if (
|
|
9406
|
+
finally { if (e_4) throw e_4.error; }
|
|
9341
9407
|
}
|
|
9342
9408
|
}
|
|
9343
9409
|
// =============================================================
|
|
9344
|
-
// Note:
|
|
9410
|
+
// Note: 7️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
9345
9411
|
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
9346
9412
|
try {
|
|
9347
|
-
for (var
|
|
9348
|
-
var parameter =
|
|
9413
|
+
for (var _k = __values($pipelineJson.parameters), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
9414
|
+
var parameter = _l.value;
|
|
9349
9415
|
if (!parameter.isInput) {
|
|
9350
9416
|
parameter.isOutput = true;
|
|
9351
9417
|
}
|
|
9352
9418
|
}
|
|
9353
9419
|
}
|
|
9354
|
-
catch (
|
|
9420
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
9355
9421
|
finally {
|
|
9356
9422
|
try {
|
|
9357
|
-
if (
|
|
9423
|
+
if (_l && !_l.done && (_e = _k.return)) _e.call(_k);
|
|
9358
9424
|
}
|
|
9359
|
-
finally { if (
|
|
9425
|
+
finally { if (e_5) throw e_5.error; }
|
|
9360
9426
|
}
|
|
9361
9427
|
}
|
|
9362
9428
|
// =============================================================
|
|
9363
|
-
// Note:
|
|
9429
|
+
// Note: 8️⃣ Cleanup of undefined values
|
|
9364
9430
|
$pipelineJson.tasks.forEach(function (tasks) {
|
|
9365
|
-
var
|
|
9431
|
+
var e_8, _a;
|
|
9366
9432
|
try {
|
|
9367
9433
|
for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
9368
9434
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -9371,16 +9437,16 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9371
9437
|
}
|
|
9372
9438
|
}
|
|
9373
9439
|
}
|
|
9374
|
-
catch (
|
|
9440
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
9375
9441
|
finally {
|
|
9376
9442
|
try {
|
|
9377
9443
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
9378
9444
|
}
|
|
9379
|
-
finally { if (
|
|
9445
|
+
finally { if (e_8) throw e_8.error; }
|
|
9380
9446
|
}
|
|
9381
9447
|
});
|
|
9382
9448
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
9383
|
-
var
|
|
9449
|
+
var e_9, _a;
|
|
9384
9450
|
try {
|
|
9385
9451
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
9386
9452
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -9389,12 +9455,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
9389
9455
|
}
|
|
9390
9456
|
}
|
|
9391
9457
|
}
|
|
9392
|
-
catch (
|
|
9458
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
9393
9459
|
finally {
|
|
9394
9460
|
try {
|
|
9395
9461
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
9396
9462
|
}
|
|
9397
|
-
finally { if (
|
|
9463
|
+
finally { if (e_9) throw e_9.error; }
|
|
9398
9464
|
}
|
|
9399
9465
|
});
|
|
9400
9466
|
// =============================================================
|
|
@@ -10974,18 +11040,19 @@ function addAutoGeneratedSection(content, options) {
|
|
|
10974
11040
|
var warningLine = "<!-- ".concat(GENERATOR_WARNING, " -->");
|
|
10975
11041
|
var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
|
|
10976
11042
|
var sectionMatch = content.match(sectionRegex);
|
|
11043
|
+
var contentToInsert = spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); });
|
|
10977
11044
|
if (sectionMatch) {
|
|
10978
|
-
return content.replace(sectionRegex,
|
|
11045
|
+
return content.replace(sectionRegex, contentToInsert);
|
|
10979
11046
|
}
|
|
11047
|
+
// Note: Following is the case when the section is not found in the file so we add it there
|
|
10980
11048
|
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
10981
|
-
if (
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
"No place where to put the section <!--".concat(sectionName, "-->"));
|
|
10985
|
-
// <- [🚞]
|
|
11049
|
+
if (placeForSection !== null) {
|
|
11050
|
+
var _a = __read(placeForSection, 1), heading_1 = _a[0];
|
|
11051
|
+
return content.replace(heading_1, spaceTrim(function (block) { return "\n ".concat(block(contentToInsert), "\n \n ").concat(block(heading_1), "\n "); }));
|
|
10986
11052
|
}
|
|
10987
|
-
|
|
10988
|
-
|
|
11053
|
+
console.warn("No place where to put the section <!--".concat(sectionName, "-->, using the end of the file"));
|
|
11054
|
+
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
11055
|
+
return spaceTrim(function (block) { return "\n ".concat(block(content), "\n \n ").concat(block(contentToInsert), "\n "); });
|
|
10989
11056
|
}
|
|
10990
11057
|
/**
|
|
10991
11058
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -11013,7 +11080,7 @@ function renderPromptbookMermaid(pipelineJson, options) {
|
|
|
11013
11080
|
if (!task) {
|
|
11014
11081
|
throw new Error("Could not find task for {".concat(parameterName, "}"));
|
|
11015
11082
|
}
|
|
11016
|
-
return normalizeTo_camelCase('task-' + titleToName(task.title));
|
|
11083
|
+
return task.name || normalizeTo_camelCase('task-' + titleToName(task.title));
|
|
11017
11084
|
};
|
|
11018
11085
|
var promptbookMermaid = spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
|
|
11019
11086
|
.flatMap(function (_a) {
|
|
@@ -11076,7 +11143,7 @@ function prettifyPipelineString(pipelineString, options) {
|
|
|
11076
11143
|
return { href: "#".concat(task.name), title: task.title };
|
|
11077
11144
|
},
|
|
11078
11145
|
});
|
|
11079
|
-
promptbookMermaidBlock = spaceTrim(function (block) { return "\n
|
|
11146
|
+
promptbookMermaidBlock = spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
|
|
11080
11147
|
pipelineString = addAutoGeneratedSection(pipelineString, {
|
|
11081
11148
|
sectionName: 'Graph',
|
|
11082
11149
|
sectionContent: promptbookMermaidBlock,
|
|
@@ -13582,10 +13649,7 @@ var _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
13582
13649
|
packageName: '@promptbook/google',
|
|
13583
13650
|
className: 'GoogleExecutionTools',
|
|
13584
13651
|
options: {
|
|
13585
|
-
apiKey: '
|
|
13586
|
-
isProxied: true,
|
|
13587
|
-
remoteUrl: DEFAULT_REMOTE_URL,
|
|
13588
|
-
path: DEFAULT_REMOTE_URL_PATH,
|
|
13652
|
+
apiKey: 'AI',
|
|
13589
13653
|
},
|
|
13590
13654
|
};
|
|
13591
13655
|
},
|
|
@@ -13791,7 +13855,7 @@ var createGoogleExecutionTools = Object.assign(function (options) {
|
|
|
13791
13855
|
var createGoogleGenerativeAI = require('@ai-sdk/google').createGoogleGenerativeAI;
|
|
13792
13856
|
var googleGeminiVercelProvider = createGoogleGenerativeAI(__assign({}, options));
|
|
13793
13857
|
return createExecutionToolsFromVercelProvider(__assign({ title: 'Google', description: 'Implementation of Google models', vercelProvider: googleGeminiVercelProvider, availableModels: [
|
|
13794
|
-
// TODO:
|
|
13858
|
+
// TODO: [🕘] Maybe list models in same way as in other providers - in separate file with metadata
|
|
13795
13859
|
'gemini-1.5-flash',
|
|
13796
13860
|
'gemini-1.5-flash-latest',
|
|
13797
13861
|
'gemini-1.5-flash-001',
|
|
@@ -13813,10 +13877,6 @@ var createGoogleExecutionTools = Object.assign(function (options) {
|
|
|
13813
13877
|
className: 'GoogleExecutionTools',
|
|
13814
13878
|
});
|
|
13815
13879
|
/**
|
|
13816
|
-
* TODO: [🧠][main] !!!! Make anonymous this with all LLM providers
|
|
13817
|
-
* TODO: [🧠][🧱][main] !!!! Maybe change all `new GoogleExecutionTools` -> `createGoogleExecutionTools` in manual
|
|
13818
|
-
* TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
|
|
13819
|
-
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
13820
13880
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
13821
13881
|
*/
|
|
13822
13882
|
|