@promptbook/markdown-utils 0.103.0-55 → 0.103.0-56
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/esm/index.es.js +138 -104
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -8
- package/esm/typings/src/_packages/types.index.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +6 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/{IMPORTANT/IMPORTANT.d.ts → USE_MCP/USE_MCP.d.ts} +16 -5
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/commitments/index.d.ts +93 -1
- package/esm/typings/src/playground/playground.d.ts +3 -0
- package/esm/typings/src/utils/color/Color.d.ts +8 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +103 -69
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commitments/registry.d.ts +0 -68
- package/esm/typings/src/playground/playground1.d.ts +0 -2
package/umd/index.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('rxjs'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'rxjs', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.crypto, global.rxjs, global.waitasecond, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
-
})(this, (function (exports, spaceTrim, crypto, rxjs, waitasecond, hexEncoder, sha256, path, cryptoJs, mimeTypes, papaparse) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim$1, global.crypto, global.rxjs, global.waitasecond, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, spaceTrim$1, crypto, rxjs, waitasecond, hexEncoder, sha256, path, cryptoJs, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
9
|
+
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
|
|
10
10
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
11
11
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
12
12
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @generated
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
27
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -173,6 +173,17 @@
|
|
|
173
173
|
return content;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Trims string from all 4 sides
|
|
178
|
+
*
|
|
179
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
180
|
+
* Developed by same author @hejny as this package
|
|
181
|
+
*
|
|
182
|
+
* @public exported from `@promptbook/utils`
|
|
183
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
184
|
+
*/
|
|
185
|
+
const spaceTrim = spaceTrim$1.spaceTrim;
|
|
186
|
+
|
|
176
187
|
/**
|
|
177
188
|
* @private util of `@promptbook/color`
|
|
178
189
|
* @de
|
|
@@ -221,6 +232,7 @@
|
|
|
221
232
|
* @public exported from `@promptbook/color`
|
|
222
233
|
*/
|
|
223
234
|
const CSS_COLORS = {
|
|
235
|
+
promptbook: '#79EAFD',
|
|
224
236
|
transparent: 'rgba(0,0,0,0)',
|
|
225
237
|
aliceblue: '#f0f8ff',
|
|
226
238
|
antiquewhite: '#faebd7',
|
|
@@ -436,6 +448,28 @@
|
|
|
436
448
|
throw new Error(`Can not create color from given object`);
|
|
437
449
|
}
|
|
438
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* Creates a new Color instance from miscellaneous formats
|
|
453
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
454
|
+
*
|
|
455
|
+
* @param color
|
|
456
|
+
* @returns Color object
|
|
457
|
+
*/
|
|
458
|
+
static fromSafe(color) {
|
|
459
|
+
try {
|
|
460
|
+
return Color.from(color);
|
|
461
|
+
}
|
|
462
|
+
catch (error) {
|
|
463
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
464
|
+
console.warn(spaceTrim((block) => `
|
|
465
|
+
Color.fromSafe error:
|
|
466
|
+
${block(error.message)}
|
|
467
|
+
|
|
468
|
+
Returning default PROMPTBOOK_COLOR.
|
|
469
|
+
`));
|
|
470
|
+
return Color.fromString('promptbook');
|
|
471
|
+
}
|
|
472
|
+
}
|
|
439
473
|
/**
|
|
440
474
|
* Creates a new Color instance from miscellaneous string formats
|
|
441
475
|
*
|
|
@@ -1051,7 +1085,7 @@
|
|
|
1051
1085
|
*
|
|
1052
1086
|
* @public exported from `@promptbook/core`
|
|
1053
1087
|
*/
|
|
1054
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1088
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
1055
1089
|
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1056
1090
|
/**
|
|
1057
1091
|
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
@@ -1292,7 +1326,7 @@
|
|
|
1292
1326
|
*/
|
|
1293
1327
|
class UnexpectedError extends Error {
|
|
1294
1328
|
constructor(message) {
|
|
1295
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
1329
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
1296
1330
|
${block(message)}
|
|
1297
1331
|
|
|
1298
1332
|
Note: This error should not happen.
|
|
@@ -1318,7 +1352,7 @@
|
|
|
1318
1352
|
constructor(whatWasThrown) {
|
|
1319
1353
|
const tag = `[🤮]`;
|
|
1320
1354
|
console.error(tag, whatWasThrown);
|
|
1321
|
-
super(spaceTrim.spaceTrim(`
|
|
1355
|
+
super(spaceTrim$1.spaceTrim(`
|
|
1322
1356
|
Non-Error object was thrown
|
|
1323
1357
|
|
|
1324
1358
|
Note: Look for ${tag} in the console for more details
|
|
@@ -2138,7 +2172,7 @@
|
|
|
2138
2172
|
if (!(error instanceof PipelineLogicError)) {
|
|
2139
2173
|
throw error;
|
|
2140
2174
|
}
|
|
2141
|
-
console.error(spaceTrim.spaceTrim((block) => `
|
|
2175
|
+
console.error(spaceTrim$1.spaceTrim((block) => `
|
|
2142
2176
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2143
2177
|
|
|
2144
2178
|
${block(error.message)}
|
|
@@ -2165,7 +2199,7 @@
|
|
|
2165
2199
|
})();
|
|
2166
2200
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2167
2201
|
// <- Note: [🚲]
|
|
2168
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2202
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2169
2203
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
2170
2204
|
|
|
2171
2205
|
${block(pipelineIdentification)}
|
|
@@ -2173,7 +2207,7 @@
|
|
|
2173
2207
|
}
|
|
2174
2208
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
2175
2209
|
// <- Note: [🚲]
|
|
2176
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2210
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2177
2211
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
2178
2212
|
|
|
2179
2213
|
${block(pipelineIdentification)}
|
|
@@ -2182,7 +2216,7 @@
|
|
|
2182
2216
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2183
2217
|
if (!Array.isArray(pipeline.parameters)) {
|
|
2184
2218
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2185
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
2219
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
2186
2220
|
Pipeline is valid JSON but with wrong structure
|
|
2187
2221
|
|
|
2188
2222
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -2193,7 +2227,7 @@
|
|
|
2193
2227
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2194
2228
|
if (!Array.isArray(pipeline.tasks)) {
|
|
2195
2229
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2196
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
2230
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
2197
2231
|
Pipeline is valid JSON but with wrong structure
|
|
2198
2232
|
|
|
2199
2233
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -2219,7 +2253,7 @@
|
|
|
2219
2253
|
// Note: Check each parameter individually
|
|
2220
2254
|
for (const parameter of pipeline.parameters) {
|
|
2221
2255
|
if (parameter.isInput && parameter.isOutput) {
|
|
2222
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2256
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2223
2257
|
|
|
2224
2258
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
2225
2259
|
|
|
@@ -2230,7 +2264,7 @@
|
|
|
2230
2264
|
if (!parameter.isInput &&
|
|
2231
2265
|
!parameter.isOutput &&
|
|
2232
2266
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
2233
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2267
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2234
2268
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
2235
2269
|
|
|
2236
2270
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -2242,7 +2276,7 @@
|
|
|
2242
2276
|
}
|
|
2243
2277
|
// Note: Testing that parameter is either input or result of some task
|
|
2244
2278
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
2245
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2279
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2246
2280
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
2247
2281
|
|
|
2248
2282
|
You can do one of these:
|
|
@@ -2258,14 +2292,14 @@
|
|
|
2258
2292
|
// Note: Checking each task individually
|
|
2259
2293
|
for (const task of pipeline.tasks) {
|
|
2260
2294
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
2261
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2295
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2262
2296
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
2263
2297
|
|
|
2264
2298
|
${block(pipelineIdentification)}
|
|
2265
2299
|
`));
|
|
2266
2300
|
}
|
|
2267
2301
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
2268
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2302
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2269
2303
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
2270
2304
|
|
|
2271
2305
|
${block(pipelineIdentification)}
|
|
@@ -2275,7 +2309,7 @@
|
|
|
2275
2309
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
2276
2310
|
if (!task.format &&
|
|
2277
2311
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
2278
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2312
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2279
2313
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
2280
2314
|
|
|
2281
2315
|
${block(pipelineIdentification)}
|
|
@@ -2283,7 +2317,7 @@
|
|
|
2283
2317
|
}
|
|
2284
2318
|
for (const joker of task.jokerParameterNames) {
|
|
2285
2319
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
2286
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2320
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2287
2321
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
2288
2322
|
|
|
2289
2323
|
${block(pipelineIdentification)}
|
|
@@ -2294,21 +2328,21 @@
|
|
|
2294
2328
|
if (task.expectations) {
|
|
2295
2329
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
2296
2330
|
if (min !== undefined && max !== undefined && min > max) {
|
|
2297
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2331
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2298
2332
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
2299
2333
|
|
|
2300
2334
|
${block(pipelineIdentification)}
|
|
2301
2335
|
`));
|
|
2302
2336
|
}
|
|
2303
2337
|
if (min !== undefined && min < 0) {
|
|
2304
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2338
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2305
2339
|
Min expectation of ${unit} must be zero or positive
|
|
2306
2340
|
|
|
2307
2341
|
${block(pipelineIdentification)}
|
|
2308
2342
|
`));
|
|
2309
2343
|
}
|
|
2310
2344
|
if (max !== undefined && max <= 0) {
|
|
2311
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
2345
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
2312
2346
|
Max expectation of ${unit} must be positive
|
|
2313
2347
|
|
|
2314
2348
|
${block(pipelineIdentification)}
|
|
@@ -2330,7 +2364,7 @@
|
|
|
2330
2364
|
while (unresovedTasks.length > 0) {
|
|
2331
2365
|
if (loopLimit-- < 0) {
|
|
2332
2366
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2333
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
2367
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
2334
2368
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2335
2369
|
|
|
2336
2370
|
${block(pipelineIdentification)}
|
|
@@ -2340,7 +2374,7 @@
|
|
|
2340
2374
|
if (currentlyResovedTasks.length === 0) {
|
|
2341
2375
|
throw new PipelineLogicError(
|
|
2342
2376
|
// TODO: [🐎] DRY
|
|
2343
|
-
spaceTrim.spaceTrim((block) => `
|
|
2377
|
+
spaceTrim$1.spaceTrim((block) => `
|
|
2344
2378
|
|
|
2345
2379
|
Can not resolve some parameters:
|
|
2346
2380
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -2504,7 +2538,7 @@
|
|
|
2504
2538
|
for (const pipeline of pipelines) {
|
|
2505
2539
|
// TODO: [👠] DRY
|
|
2506
2540
|
if (pipeline.pipelineUrl === undefined) {
|
|
2507
|
-
throw new PipelineUrlError(spaceTrim.spaceTrim(`
|
|
2541
|
+
throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
|
|
2508
2542
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
2509
2543
|
|
|
2510
2544
|
File:
|
|
@@ -2526,7 +2560,7 @@
|
|
|
2526
2560
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
2527
2561
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
2528
2562
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
2529
|
-
throw new PipelineUrlError(spaceTrim.spaceTrim(`
|
|
2563
|
+
throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
|
|
2530
2564
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
2531
2565
|
|
|
2532
2566
|
Conflicting files:
|
|
@@ -2558,13 +2592,13 @@
|
|
|
2558
2592
|
const pipeline = this.collection.get(url);
|
|
2559
2593
|
if (!pipeline) {
|
|
2560
2594
|
if (this.listPipelines().length === 0) {
|
|
2561
|
-
throw new NotFoundError(spaceTrim.spaceTrim(`
|
|
2595
|
+
throw new NotFoundError(spaceTrim$1.spaceTrim(`
|
|
2562
2596
|
Pipeline with url "${url}" not found
|
|
2563
2597
|
|
|
2564
2598
|
No pipelines available
|
|
2565
2599
|
`));
|
|
2566
2600
|
}
|
|
2567
|
-
throw new NotFoundError(spaceTrim.spaceTrim((block) => `
|
|
2601
|
+
throw new NotFoundError(spaceTrim$1.spaceTrim((block) => `
|
|
2568
2602
|
Pipeline with url "${url}" not found
|
|
2569
2603
|
|
|
2570
2604
|
Available pipelines:
|
|
@@ -2605,7 +2639,7 @@
|
|
|
2605
2639
|
*/
|
|
2606
2640
|
class MissingToolsError extends Error {
|
|
2607
2641
|
constructor(message) {
|
|
2608
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
2642
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
2609
2643
|
${block(message)}
|
|
2610
2644
|
|
|
2611
2645
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -2839,7 +2873,7 @@
|
|
|
2839
2873
|
*/
|
|
2840
2874
|
class NotYetImplementedError extends Error {
|
|
2841
2875
|
constructor(message) {
|
|
2842
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
2876
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
2843
2877
|
${block(message)}
|
|
2844
2878
|
|
|
2845
2879
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -3078,11 +3112,11 @@
|
|
|
3078
3112
|
throw deserializeError(errors[0]);
|
|
3079
3113
|
}
|
|
3080
3114
|
else {
|
|
3081
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
3115
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
3082
3116
|
Multiple errors occurred during Promptbook execution
|
|
3083
3117
|
|
|
3084
3118
|
${block(errors
|
|
3085
|
-
.map(({ name, stack, message }, index) => spaceTrim.spaceTrim((block) => `
|
|
3119
|
+
.map(({ name, stack, message }, index) => spaceTrim$1.spaceTrim((block) => `
|
|
3086
3120
|
${name} ${index + 1}:
|
|
3087
3121
|
${block(stack || message)}
|
|
3088
3122
|
`))
|
|
@@ -4876,7 +4910,7 @@
|
|
|
4876
4910
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
4877
4911
|
knowledgePiecesCount > 0 &&
|
|
4878
4912
|
!dependentParameterNames.includes('knowledge')) {
|
|
4879
|
-
preparedContent = spaceTrim.spaceTrim(`
|
|
4913
|
+
preparedContent = spaceTrim$1.spaceTrim(`
|
|
4880
4914
|
{content}
|
|
4881
4915
|
|
|
4882
4916
|
## Knowledge
|
|
@@ -5189,7 +5223,7 @@
|
|
|
5189
5223
|
}
|
|
5190
5224
|
catch (error) {
|
|
5191
5225
|
assertsError(error);
|
|
5192
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
5226
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
5193
5227
|
Can not extract variables from the script
|
|
5194
5228
|
${block(error.stack || error.message)}
|
|
5195
5229
|
|
|
@@ -5924,7 +5958,7 @@
|
|
|
5924
5958
|
}
|
|
5925
5959
|
catch (error) {
|
|
5926
5960
|
keepUnused(error);
|
|
5927
|
-
throw new ExpectError(spaceTrim.spaceTrim((block) => `
|
|
5961
|
+
throw new ExpectError(spaceTrim$1.spaceTrim((block) => `
|
|
5928
5962
|
Expected valid JSON string
|
|
5929
5963
|
|
|
5930
5964
|
The expected JSON text:
|
|
@@ -5987,7 +6021,7 @@
|
|
|
5987
6021
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
5988
6022
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
5989
6023
|
if (isJokerAttempt && !jokerParameterName) {
|
|
5990
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6024
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
5991
6025
|
Joker not found in attempt ${attemptIndex}
|
|
5992
6026
|
|
|
5993
6027
|
${block(pipelineIdentification)}
|
|
@@ -5998,7 +6032,7 @@
|
|
|
5998
6032
|
$ongoingTaskResult.$expectError = null;
|
|
5999
6033
|
if (isJokerAttempt) {
|
|
6000
6034
|
if (parameters[jokerParameterName] === undefined) {
|
|
6001
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6035
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6002
6036
|
Joker parameter {${jokerParameterName}} not defined
|
|
6003
6037
|
|
|
6004
6038
|
${block(pipelineIdentification)}
|
|
@@ -6056,7 +6090,7 @@
|
|
|
6056
6090
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
6057
6091
|
break variant;
|
|
6058
6092
|
case 'EMBEDDING':
|
|
6059
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6093
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6060
6094
|
Embedding model can not be used in pipeline
|
|
6061
6095
|
|
|
6062
6096
|
This should be catched during parsing
|
|
@@ -6067,7 +6101,7 @@
|
|
|
6067
6101
|
break variant;
|
|
6068
6102
|
// <- case [🤖]:
|
|
6069
6103
|
default:
|
|
6070
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6104
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6071
6105
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
6072
6106
|
|
|
6073
6107
|
${block(pipelineIdentification)}
|
|
@@ -6078,14 +6112,14 @@
|
|
|
6078
6112
|
break;
|
|
6079
6113
|
case 'SCRIPT_TASK':
|
|
6080
6114
|
if (arrayableToArray(tools.script).length === 0) {
|
|
6081
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6115
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6082
6116
|
No script execution tools are available
|
|
6083
6117
|
|
|
6084
6118
|
${block(pipelineIdentification)}
|
|
6085
6119
|
`));
|
|
6086
6120
|
}
|
|
6087
6121
|
if (!task.contentLanguage) {
|
|
6088
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6122
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6089
6123
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
6090
6124
|
|
|
6091
6125
|
${block(pipelineIdentification)}
|
|
@@ -6116,7 +6150,7 @@
|
|
|
6116
6150
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
6117
6151
|
}
|
|
6118
6152
|
else {
|
|
6119
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6153
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6120
6154
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
6121
6155
|
|
|
6122
6156
|
${block(pipelineIdentification)}
|
|
@@ -6130,7 +6164,7 @@
|
|
|
6130
6164
|
break taskType;
|
|
6131
6165
|
case 'DIALOG_TASK':
|
|
6132
6166
|
if (tools.userInterface === undefined) {
|
|
6133
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6167
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6134
6168
|
User interface tools are not available
|
|
6135
6169
|
|
|
6136
6170
|
${block(pipelineIdentification)}
|
|
@@ -6148,7 +6182,7 @@
|
|
|
6148
6182
|
break taskType;
|
|
6149
6183
|
// <- case: [🅱]
|
|
6150
6184
|
default:
|
|
6151
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6185
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6152
6186
|
Unknown execution type "${task.taskType}"
|
|
6153
6187
|
|
|
6154
6188
|
${block(pipelineIdentification)}
|
|
@@ -6246,7 +6280,7 @@
|
|
|
6246
6280
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
6247
6281
|
// Note: Create a summary of all failures
|
|
6248
6282
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6249
|
-
.map((failure) => spaceTrim.spaceTrim((block) => {
|
|
6283
|
+
.map((failure) => spaceTrim$1.spaceTrim((block) => {
|
|
6250
6284
|
var _a, _b;
|
|
6251
6285
|
return `
|
|
6252
6286
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -6256,14 +6290,14 @@
|
|
|
6256
6290
|
Result:
|
|
6257
6291
|
${block(failure.result === null
|
|
6258
6292
|
? 'null'
|
|
6259
|
-
: spaceTrim.spaceTrim(failure.result)
|
|
6293
|
+
: spaceTrim$1.spaceTrim(failure.result)
|
|
6260
6294
|
.split('\n')
|
|
6261
6295
|
.map((line) => `> ${line}`)
|
|
6262
6296
|
.join('\n'))}
|
|
6263
6297
|
`;
|
|
6264
6298
|
}))
|
|
6265
6299
|
.join('\n\n---\n\n');
|
|
6266
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
|
|
6300
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => {
|
|
6267
6301
|
var _a;
|
|
6268
6302
|
return `
|
|
6269
6303
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -6283,7 +6317,7 @@
|
|
|
6283
6317
|
}
|
|
6284
6318
|
}
|
|
6285
6319
|
if ($ongoingTaskResult.$resultString === null) {
|
|
6286
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6320
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6287
6321
|
Something went wrong and prompt result is null
|
|
6288
6322
|
|
|
6289
6323
|
${block(pipelineIdentification)}
|
|
@@ -6589,7 +6623,7 @@
|
|
|
6589
6623
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
6590
6624
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
6591
6625
|
if (reservedParameters[parameterName] === undefined) {
|
|
6592
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6626
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6593
6627
|
Reserved parameter {${parameterName}} is not defined
|
|
6594
6628
|
|
|
6595
6629
|
${block(pipelineIdentification)}
|
|
@@ -6615,7 +6649,7 @@
|
|
|
6615
6649
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
6616
6650
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
6617
6651
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
6618
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6652
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6619
6653
|
Dependent parameters are not consistent with used parameters:
|
|
6620
6654
|
|
|
6621
6655
|
Dependent parameters:
|
|
@@ -6659,7 +6693,7 @@
|
|
|
6659
6693
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
6660
6694
|
// Houston, we have a problem
|
|
6661
6695
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
6662
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6696
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6663
6697
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
6664
6698
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
6665
6699
|
|
|
@@ -6728,7 +6762,7 @@
|
|
|
6728
6762
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
6729
6763
|
if (parametersToPass[parameter.name] === undefined) {
|
|
6730
6764
|
// [4]
|
|
6731
|
-
$warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6765
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6732
6766
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
6733
6767
|
|
|
6734
6768
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -6836,7 +6870,7 @@
|
|
|
6836
6870
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
6837
6871
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
6838
6872
|
if (parameter === undefined) {
|
|
6839
|
-
warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6873
|
+
warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6840
6874
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
6841
6875
|
|
|
6842
6876
|
${block(pipelineIdentification)}
|
|
@@ -6851,7 +6885,7 @@
|
|
|
6851
6885
|
// TODO: [🧠] This should be also non-critical error
|
|
6852
6886
|
return exportJson({
|
|
6853
6887
|
name: 'pipelineExecutorResult',
|
|
6854
|
-
message: spaceTrim.spaceTrim((block) => `
|
|
6888
|
+
message: spaceTrim$1.spaceTrim((block) => `
|
|
6855
6889
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
6856
6890
|
|
|
6857
6891
|
${block(pipelineIdentification)}
|
|
@@ -6860,7 +6894,7 @@
|
|
|
6860
6894
|
value: {
|
|
6861
6895
|
isSuccessful: false,
|
|
6862
6896
|
errors: [
|
|
6863
|
-
new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6897
|
+
new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6864
6898
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
6865
6899
|
|
|
6866
6900
|
${block(pipelineIdentification)}
|
|
@@ -6887,7 +6921,7 @@
|
|
|
6887
6921
|
while (unresovedTasks.length > 0) {
|
|
6888
6922
|
if (loopLimit-- < 0) {
|
|
6889
6923
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
6890
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6924
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6891
6925
|
Loop limit reached during resolving parameters pipeline execution
|
|
6892
6926
|
|
|
6893
6927
|
${block(pipelineIdentification)}
|
|
@@ -6897,7 +6931,7 @@
|
|
|
6897
6931
|
if (!currentTask && resolving.length === 0) {
|
|
6898
6932
|
throw new UnexpectedError(
|
|
6899
6933
|
// TODO: [🐎] DRY
|
|
6900
|
-
spaceTrim.spaceTrim((block) => `
|
|
6934
|
+
spaceTrim$1.spaceTrim((block) => `
|
|
6901
6935
|
Can not resolve some parameters:
|
|
6902
6936
|
|
|
6903
6937
|
${block(pipelineIdentification)}
|
|
@@ -6937,7 +6971,7 @@
|
|
|
6937
6971
|
tools,
|
|
6938
6972
|
onProgress(newOngoingResult) {
|
|
6939
6973
|
if (isReturned) {
|
|
6940
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6974
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6941
6975
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
6942
6976
|
|
|
6943
6977
|
${block(pipelineIdentification)}
|
|
@@ -6954,7 +6988,7 @@
|
|
|
6954
6988
|
},
|
|
6955
6989
|
logLlmCall,
|
|
6956
6990
|
$executionReport: executionReport,
|
|
6957
|
-
pipelineIdentification: spaceTrim.spaceTrim((block) => `
|
|
6991
|
+
pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
|
|
6958
6992
|
${block(pipelineIdentification)}
|
|
6959
6993
|
Task name: ${currentTask.name}
|
|
6960
6994
|
Task title: ${currentTask.title}
|
|
@@ -7063,7 +7097,7 @@
|
|
|
7063
7097
|
preparedPipeline = pipeline;
|
|
7064
7098
|
}
|
|
7065
7099
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
7066
|
-
console.warn(spaceTrim.spaceTrim((block) => `
|
|
7100
|
+
console.warn(spaceTrim$1.spaceTrim((block) => `
|
|
7067
7101
|
Pipeline is not prepared
|
|
7068
7102
|
|
|
7069
7103
|
${block(pipelineIdentification)}
|
|
@@ -7088,7 +7122,7 @@
|
|
|
7088
7122
|
tools,
|
|
7089
7123
|
onProgress,
|
|
7090
7124
|
logLlmCall,
|
|
7091
|
-
pipelineIdentification: spaceTrim.spaceTrim((block) => `
|
|
7125
|
+
pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
|
|
7092
7126
|
${block(pipelineIdentification)}
|
|
7093
7127
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
7094
7128
|
`),
|
|
@@ -7396,7 +7430,7 @@
|
|
|
7396
7430
|
* @public exported from `@promptbook/markdown-utils`
|
|
7397
7431
|
*/
|
|
7398
7432
|
function removeMarkdownComments(content) {
|
|
7399
|
-
return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
7433
|
+
return spaceTrim$1.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
7400
7434
|
}
|
|
7401
7435
|
|
|
7402
7436
|
/**
|
|
@@ -7409,7 +7443,7 @@
|
|
|
7409
7443
|
const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
|
|
7410
7444
|
const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
|
|
7411
7445
|
const sectionMatch = content.match(sectionRegex);
|
|
7412
|
-
const contentToInsert = spaceTrim.spaceTrim((block) => `
|
|
7446
|
+
const contentToInsert = spaceTrim$1.spaceTrim((block) => `
|
|
7413
7447
|
<!--${sectionName}-->
|
|
7414
7448
|
${block(warningLine)}
|
|
7415
7449
|
${block(sectionContent)}
|
|
@@ -7422,7 +7456,7 @@
|
|
|
7422
7456
|
const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
|
|
7423
7457
|
if (placeForSection !== null) {
|
|
7424
7458
|
const [heading] = placeForSection;
|
|
7425
|
-
return content.replace(heading, spaceTrim.spaceTrim((block) => `
|
|
7459
|
+
return content.replace(heading, spaceTrim$1.spaceTrim((block) => `
|
|
7426
7460
|
${block(contentToInsert)}
|
|
7427
7461
|
|
|
7428
7462
|
${block(heading)}
|
|
@@ -7431,7 +7465,7 @@
|
|
|
7431
7465
|
console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
|
|
7432
7466
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7433
7467
|
// <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
|
|
7434
|
-
return spaceTrim.spaceTrim((block) => `
|
|
7468
|
+
return spaceTrim$1.spaceTrim((block) => `
|
|
7435
7469
|
${block(content)}
|
|
7436
7470
|
|
|
7437
7471
|
${block(contentToInsert)}
|
|
@@ -7846,13 +7880,13 @@
|
|
|
7846
7880
|
* @public exported from `@promptbook/markdown-utils`
|
|
7847
7881
|
*/
|
|
7848
7882
|
function trimCodeBlock(value) {
|
|
7849
|
-
value = spaceTrim.spaceTrim(value);
|
|
7883
|
+
value = spaceTrim$1.spaceTrim(value);
|
|
7850
7884
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
7851
7885
|
return value;
|
|
7852
7886
|
}
|
|
7853
7887
|
value = value.replace(/^```[a-z]*/i, '');
|
|
7854
7888
|
value = value.replace(/```$/i, '');
|
|
7855
|
-
value = spaceTrim.spaceTrim(value);
|
|
7889
|
+
value = spaceTrim$1.spaceTrim(value);
|
|
7856
7890
|
return value;
|
|
7857
7891
|
}
|
|
7858
7892
|
|
|
@@ -7865,9 +7899,9 @@
|
|
|
7865
7899
|
* @public exported from `@promptbook/markdown-utils`
|
|
7866
7900
|
*/
|
|
7867
7901
|
function trimEndOfCodeBlock(value) {
|
|
7868
|
-
value = spaceTrim.spaceTrim(value);
|
|
7902
|
+
value = spaceTrim$1.spaceTrim(value);
|
|
7869
7903
|
value = value.replace(/```$/g, '');
|
|
7870
|
-
value = spaceTrim.spaceTrim(value);
|
|
7904
|
+
value = spaceTrim$1.spaceTrim(value);
|
|
7871
7905
|
return value;
|
|
7872
7906
|
}
|
|
7873
7907
|
|