@promptbook/documents 0.103.0-55 → 0.103.0-66
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 +151 -99
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +2 -2
- package/esm/typings/src/_packages/core.index.d.ts +6 -8
- package/esm/typings/src/_packages/types.index.d.ts +7 -1
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +3 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +52 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +14 -0
- package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +4 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -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 +42 -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/_base/BaseCommitmentDefinition.d.ts +6 -0
- package/esm/typings/src/commitments/index.d.ts +93 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +3 -1
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/playground/playground.d.ts +3 -0
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/esm/typings/src/utils/color/Color.d.ts +9 -1
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +6 -0
- package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
- package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +3 -3
- package/umd/index.umd.js +119 -67
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +0 -29
- package/esm/typings/src/commitments/registry.d.ts +0 -68
- package/esm/typings/src/playground/playground1.d.ts +0 -2
package/esm/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mkdir, rm, readFile } from 'fs/promises';
|
|
2
|
-
import spaceTrim$
|
|
2
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
import colors from 'colors';
|
|
5
5
|
import { forTime } from 'waitasecond';
|
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-66';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -49,6 +49,17 @@ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-55';
|
|
|
49
49
|
function keepUnused(...valuesToKeep) {
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Trims string from all 4 sides
|
|
54
|
+
*
|
|
55
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
56
|
+
* Developed by same author @hejny as this package
|
|
57
|
+
*
|
|
58
|
+
* @public exported from `@promptbook/utils`
|
|
59
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
60
|
+
*/
|
|
61
|
+
const spaceTrim = spaceTrim$1;
|
|
62
|
+
|
|
52
63
|
/**
|
|
53
64
|
* @private util of `@promptbook/color`
|
|
54
65
|
* @de
|
|
@@ -97,6 +108,7 @@ function take(initialValue) {
|
|
|
97
108
|
* @public exported from `@promptbook/color`
|
|
98
109
|
*/
|
|
99
110
|
const CSS_COLORS = {
|
|
111
|
+
promptbook: '#79EAFD',
|
|
100
112
|
transparent: 'rgba(0,0,0,0)',
|
|
101
113
|
aliceblue: '#f0f8ff',
|
|
102
114
|
antiquewhite: '#faebd7',
|
|
@@ -297,21 +309,61 @@ class Color {
|
|
|
297
309
|
* @param color
|
|
298
310
|
* @returns Color object
|
|
299
311
|
*/
|
|
300
|
-
static from(color) {
|
|
301
|
-
if (color
|
|
312
|
+
static from(color, _isSingleValue = false) {
|
|
313
|
+
if (color === '') {
|
|
314
|
+
throw new Error(`Can not create color from empty string`);
|
|
315
|
+
}
|
|
316
|
+
else if (color instanceof Color) {
|
|
302
317
|
return take(color);
|
|
303
318
|
}
|
|
304
319
|
else if (Color.isColor(color)) {
|
|
305
320
|
return take(color);
|
|
306
321
|
}
|
|
307
322
|
else if (typeof color === 'string') {
|
|
308
|
-
|
|
323
|
+
try {
|
|
324
|
+
return Color.fromString(color);
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
328
|
+
if (_isSingleValue) {
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
const parts = color.split(/[\s+,;|]/);
|
|
332
|
+
if (parts.length > 0) {
|
|
333
|
+
return Color.from(parts[0].trim(), true);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
throw new Error(`Can not create color from given string "${color}"`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
309
339
|
}
|
|
310
340
|
else {
|
|
311
341
|
console.error({ color });
|
|
312
342
|
throw new Error(`Can not create color from given object`);
|
|
313
343
|
}
|
|
314
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Creates a new Color instance from miscellaneous formats
|
|
347
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
348
|
+
*
|
|
349
|
+
* @param color
|
|
350
|
+
* @returns Color object
|
|
351
|
+
*/
|
|
352
|
+
static fromSafe(color) {
|
|
353
|
+
try {
|
|
354
|
+
return Color.from(color);
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
358
|
+
console.warn(spaceTrim((block) => `
|
|
359
|
+
Color.fromSafe error:
|
|
360
|
+
${block(error.message)}
|
|
361
|
+
|
|
362
|
+
Returning default PROMPTBOOK_COLOR.
|
|
363
|
+
`));
|
|
364
|
+
return Color.fromString('promptbook');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
315
367
|
/**
|
|
316
368
|
* Creates a new Color instance from miscellaneous string formats
|
|
317
369
|
*
|
|
@@ -921,7 +973,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
921
973
|
*
|
|
922
974
|
* @public exported from `@promptbook/core`
|
|
923
975
|
*/
|
|
924
|
-
const PROMPTBOOK_COLOR = Color.
|
|
976
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
925
977
|
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
926
978
|
/**
|
|
927
979
|
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
@@ -1144,7 +1196,7 @@ class KnowledgeScrapeError extends Error {
|
|
|
1144
1196
|
*/
|
|
1145
1197
|
class MissingToolsError extends Error {
|
|
1146
1198
|
constructor(message) {
|
|
1147
|
-
super(spaceTrim((block) => `
|
|
1199
|
+
super(spaceTrim$1((block) => `
|
|
1148
1200
|
${block(message)}
|
|
1149
1201
|
|
|
1150
1202
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -1163,7 +1215,7 @@ class MissingToolsError extends Error {
|
|
|
1163
1215
|
function getErrorReportUrl(error) {
|
|
1164
1216
|
const report = {
|
|
1165
1217
|
title: `🐜 Error report from ${NAME}`,
|
|
1166
|
-
body: spaceTrim$
|
|
1218
|
+
body: spaceTrim$2((block) => `
|
|
1167
1219
|
|
|
1168
1220
|
|
|
1169
1221
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1206,7 +1258,7 @@ function getErrorReportUrl(error) {
|
|
|
1206
1258
|
*/
|
|
1207
1259
|
class UnexpectedError extends Error {
|
|
1208
1260
|
constructor(message) {
|
|
1209
|
-
super(spaceTrim((block) => `
|
|
1261
|
+
super(spaceTrim$1((block) => `
|
|
1210
1262
|
${block(message)}
|
|
1211
1263
|
|
|
1212
1264
|
Note: This error should not happen.
|
|
@@ -1367,11 +1419,11 @@ function $execCommand(options) {
|
|
|
1367
1419
|
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
1368
1420
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1369
1421
|
}
|
|
1370
|
-
resolve(spaceTrim(output.join('\n')));
|
|
1422
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1371
1423
|
}
|
|
1372
1424
|
}
|
|
1373
1425
|
else {
|
|
1374
|
-
resolve(spaceTrim(output.join('\n')));
|
|
1426
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1375
1427
|
}
|
|
1376
1428
|
};
|
|
1377
1429
|
commandProcess.on('close', finishWithCode);
|
|
@@ -1389,7 +1441,7 @@ function $execCommand(options) {
|
|
|
1389
1441
|
console.warn(error);
|
|
1390
1442
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1391
1443
|
}
|
|
1392
|
-
resolve(spaceTrim(output.join('\n')));
|
|
1444
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1393
1445
|
}
|
|
1394
1446
|
});
|
|
1395
1447
|
}
|
|
@@ -2006,7 +2058,7 @@ class WrappedError extends Error {
|
|
|
2006
2058
|
constructor(whatWasThrown) {
|
|
2007
2059
|
const tag = `[🤮]`;
|
|
2008
2060
|
console.error(tag, whatWasThrown);
|
|
2009
|
-
super(spaceTrim(`
|
|
2061
|
+
super(spaceTrim$1(`
|
|
2010
2062
|
Non-Error object was thrown
|
|
2011
2063
|
|
|
2012
2064
|
Note: Look for ${tag} in the console for more details
|
|
@@ -2232,7 +2284,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
2232
2284
|
pipelineString += '\n\n';
|
|
2233
2285
|
pipelineString += '```' + contentLanguage;
|
|
2234
2286
|
pipelineString += '\n';
|
|
2235
|
-
pipelineString += spaceTrim$
|
|
2287
|
+
pipelineString += spaceTrim$2(content);
|
|
2236
2288
|
// <- TODO: [main] !!3 Escape
|
|
2237
2289
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
2238
2290
|
pipelineString += '\n';
|
|
@@ -2353,7 +2405,7 @@ function checkSerializableAsJson(options) {
|
|
|
2353
2405
|
}
|
|
2354
2406
|
else if (typeof value === 'object') {
|
|
2355
2407
|
if (value instanceof Date) {
|
|
2356
|
-
throw new UnexpectedError(spaceTrim$
|
|
2408
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2357
2409
|
\`${name}\` is Date
|
|
2358
2410
|
|
|
2359
2411
|
Use \`string_date_iso8601\` instead
|
|
@@ -2372,7 +2424,7 @@ function checkSerializableAsJson(options) {
|
|
|
2372
2424
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2373
2425
|
}
|
|
2374
2426
|
else if (value instanceof Error) {
|
|
2375
|
-
throw new UnexpectedError(spaceTrim$
|
|
2427
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2376
2428
|
\`${name}\` is unserialized Error
|
|
2377
2429
|
|
|
2378
2430
|
Use function \`serializeError\`
|
|
@@ -2395,7 +2447,7 @@ function checkSerializableAsJson(options) {
|
|
|
2395
2447
|
}
|
|
2396
2448
|
catch (error) {
|
|
2397
2449
|
assertsError(error);
|
|
2398
|
-
throw new UnexpectedError(spaceTrim$
|
|
2450
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2399
2451
|
\`${name}\` is not serializable
|
|
2400
2452
|
|
|
2401
2453
|
${block(error.stack || error.message)}
|
|
@@ -2427,7 +2479,7 @@ function checkSerializableAsJson(options) {
|
|
|
2427
2479
|
}
|
|
2428
2480
|
}
|
|
2429
2481
|
else {
|
|
2430
|
-
throw new UnexpectedError(spaceTrim$
|
|
2482
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2431
2483
|
\`${name}\` is unknown type
|
|
2432
2484
|
|
|
2433
2485
|
Additional message for \`${name}\`:
|
|
@@ -2681,7 +2733,7 @@ function validatePipeline(pipeline) {
|
|
|
2681
2733
|
if (!(error instanceof PipelineLogicError)) {
|
|
2682
2734
|
throw error;
|
|
2683
2735
|
}
|
|
2684
|
-
console.error(spaceTrim((block) => `
|
|
2736
|
+
console.error(spaceTrim$1((block) => `
|
|
2685
2737
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2686
2738
|
|
|
2687
2739
|
${block(error.message)}
|
|
@@ -2708,7 +2760,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2708
2760
|
})();
|
|
2709
2761
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2710
2762
|
// <- Note: [🚲]
|
|
2711
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2763
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2712
2764
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
2713
2765
|
|
|
2714
2766
|
${block(pipelineIdentification)}
|
|
@@ -2716,7 +2768,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2716
2768
|
}
|
|
2717
2769
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
2718
2770
|
// <- Note: [🚲]
|
|
2719
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2771
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2720
2772
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
2721
2773
|
|
|
2722
2774
|
${block(pipelineIdentification)}
|
|
@@ -2725,7 +2777,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2725
2777
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2726
2778
|
if (!Array.isArray(pipeline.parameters)) {
|
|
2727
2779
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2728
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2780
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
2729
2781
|
Pipeline is valid JSON but with wrong structure
|
|
2730
2782
|
|
|
2731
2783
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -2736,7 +2788,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2736
2788
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2737
2789
|
if (!Array.isArray(pipeline.tasks)) {
|
|
2738
2790
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2739
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2791
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
2740
2792
|
Pipeline is valid JSON but with wrong structure
|
|
2741
2793
|
|
|
2742
2794
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -2762,7 +2814,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2762
2814
|
// Note: Check each parameter individually
|
|
2763
2815
|
for (const parameter of pipeline.parameters) {
|
|
2764
2816
|
if (parameter.isInput && parameter.isOutput) {
|
|
2765
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2817
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2766
2818
|
|
|
2767
2819
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
2768
2820
|
|
|
@@ -2773,7 +2825,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2773
2825
|
if (!parameter.isInput &&
|
|
2774
2826
|
!parameter.isOutput &&
|
|
2775
2827
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
2776
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2828
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2777
2829
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
2778
2830
|
|
|
2779
2831
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -2785,7 +2837,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2785
2837
|
}
|
|
2786
2838
|
// Note: Testing that parameter is either input or result of some task
|
|
2787
2839
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
2788
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2840
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2789
2841
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
2790
2842
|
|
|
2791
2843
|
You can do one of these:
|
|
@@ -2801,14 +2853,14 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2801
2853
|
// Note: Checking each task individually
|
|
2802
2854
|
for (const task of pipeline.tasks) {
|
|
2803
2855
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
2804
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2856
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2805
2857
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
2806
2858
|
|
|
2807
2859
|
${block(pipelineIdentification)}
|
|
2808
2860
|
`));
|
|
2809
2861
|
}
|
|
2810
2862
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
2811
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2863
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2812
2864
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
2813
2865
|
|
|
2814
2866
|
${block(pipelineIdentification)}
|
|
@@ -2818,7 +2870,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2818
2870
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
2819
2871
|
if (!task.format &&
|
|
2820
2872
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
2821
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2873
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2822
2874
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
2823
2875
|
|
|
2824
2876
|
${block(pipelineIdentification)}
|
|
@@ -2826,7 +2878,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2826
2878
|
}
|
|
2827
2879
|
for (const joker of task.jokerParameterNames) {
|
|
2828
2880
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
2829
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2881
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2830
2882
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
2831
2883
|
|
|
2832
2884
|
${block(pipelineIdentification)}
|
|
@@ -2837,21 +2889,21 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2837
2889
|
if (task.expectations) {
|
|
2838
2890
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
2839
2891
|
if (min !== undefined && max !== undefined && min > max) {
|
|
2840
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2892
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2841
2893
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
2842
2894
|
|
|
2843
2895
|
${block(pipelineIdentification)}
|
|
2844
2896
|
`));
|
|
2845
2897
|
}
|
|
2846
2898
|
if (min !== undefined && min < 0) {
|
|
2847
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2899
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2848
2900
|
Min expectation of ${unit} must be zero or positive
|
|
2849
2901
|
|
|
2850
2902
|
${block(pipelineIdentification)}
|
|
2851
2903
|
`));
|
|
2852
2904
|
}
|
|
2853
2905
|
if (max !== undefined && max <= 0) {
|
|
2854
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2906
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2855
2907
|
Max expectation of ${unit} must be positive
|
|
2856
2908
|
|
|
2857
2909
|
${block(pipelineIdentification)}
|
|
@@ -2873,7 +2925,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2873
2925
|
while (unresovedTasks.length > 0) {
|
|
2874
2926
|
if (loopLimit-- < 0) {
|
|
2875
2927
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2876
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2928
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2877
2929
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2878
2930
|
|
|
2879
2931
|
${block(pipelineIdentification)}
|
|
@@ -2883,7 +2935,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2883
2935
|
if (currentlyResovedTasks.length === 0) {
|
|
2884
2936
|
throw new PipelineLogicError(
|
|
2885
2937
|
// TODO: [🐎] DRY
|
|
2886
|
-
spaceTrim((block) => `
|
|
2938
|
+
spaceTrim$1((block) => `
|
|
2887
2939
|
|
|
2888
2940
|
Can not resolve some parameters:
|
|
2889
2941
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -3047,7 +3099,7 @@ class SimplePipelineCollection {
|
|
|
3047
3099
|
for (const pipeline of pipelines) {
|
|
3048
3100
|
// TODO: [👠] DRY
|
|
3049
3101
|
if (pipeline.pipelineUrl === undefined) {
|
|
3050
|
-
throw new PipelineUrlError(spaceTrim(`
|
|
3102
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
3051
3103
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
3052
3104
|
|
|
3053
3105
|
File:
|
|
@@ -3069,7 +3121,7 @@ class SimplePipelineCollection {
|
|
|
3069
3121
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
3070
3122
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
3071
3123
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
3072
|
-
throw new PipelineUrlError(spaceTrim(`
|
|
3124
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
3073
3125
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
3074
3126
|
|
|
3075
3127
|
Conflicting files:
|
|
@@ -3101,13 +3153,13 @@ class SimplePipelineCollection {
|
|
|
3101
3153
|
const pipeline = this.collection.get(url);
|
|
3102
3154
|
if (!pipeline) {
|
|
3103
3155
|
if (this.listPipelines().length === 0) {
|
|
3104
|
-
throw new NotFoundError(spaceTrim(`
|
|
3156
|
+
throw new NotFoundError(spaceTrim$1(`
|
|
3105
3157
|
Pipeline with url "${url}" not found
|
|
3106
3158
|
|
|
3107
3159
|
No pipelines available
|
|
3108
3160
|
`));
|
|
3109
3161
|
}
|
|
3110
|
-
throw new NotFoundError(spaceTrim((block) => `
|
|
3162
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
3111
3163
|
Pipeline with url "${url}" not found
|
|
3112
3164
|
|
|
3113
3165
|
Available pipelines:
|
|
@@ -3338,7 +3390,7 @@ class NotAllowed extends Error {
|
|
|
3338
3390
|
*/
|
|
3339
3391
|
class NotYetImplementedError extends Error {
|
|
3340
3392
|
constructor(message) {
|
|
3341
|
-
super(spaceTrim((block) => `
|
|
3393
|
+
super(spaceTrim$1((block) => `
|
|
3342
3394
|
${block(message)}
|
|
3343
3395
|
|
|
3344
3396
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -3440,7 +3492,7 @@ function serializeError(error) {
|
|
|
3440
3492
|
const { name, message, stack } = error;
|
|
3441
3493
|
const { id } = error;
|
|
3442
3494
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3443
|
-
console.error(spaceTrim$
|
|
3495
|
+
console.error(spaceTrim$2((block) => `
|
|
3444
3496
|
|
|
3445
3497
|
Cannot serialize error with name "${name}"
|
|
3446
3498
|
|
|
@@ -3473,7 +3525,7 @@ function jsonParse(value) {
|
|
|
3473
3525
|
}
|
|
3474
3526
|
else if (typeof value !== 'string') {
|
|
3475
3527
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
3476
|
-
throw new Error(spaceTrim$
|
|
3528
|
+
throw new Error(spaceTrim$2(`
|
|
3477
3529
|
Can not parse JSON from non-string value.
|
|
3478
3530
|
|
|
3479
3531
|
The value type: ${typeof value}
|
|
@@ -3487,7 +3539,7 @@ function jsonParse(value) {
|
|
|
3487
3539
|
if (!(error instanceof Error)) {
|
|
3488
3540
|
throw error;
|
|
3489
3541
|
}
|
|
3490
|
-
throw new Error(spaceTrim$
|
|
3542
|
+
throw new Error(spaceTrim$2((block) => `
|
|
3491
3543
|
${block(error.message)}
|
|
3492
3544
|
|
|
3493
3545
|
The expected JSON text:
|
|
@@ -3540,7 +3592,7 @@ function deserializeError(error) {
|
|
|
3540
3592
|
message = `${name}: ${message}`;
|
|
3541
3593
|
}
|
|
3542
3594
|
if (stack !== undefined && stack !== '') {
|
|
3543
|
-
message = spaceTrim$
|
|
3595
|
+
message = spaceTrim$2((block) => `
|
|
3544
3596
|
${block(message)}
|
|
3545
3597
|
|
|
3546
3598
|
Original stack trace:
|
|
@@ -3577,11 +3629,11 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
3577
3629
|
throw deserializeError(errors[0]);
|
|
3578
3630
|
}
|
|
3579
3631
|
else {
|
|
3580
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3632
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
3581
3633
|
Multiple errors occurred during Promptbook execution
|
|
3582
3634
|
|
|
3583
3635
|
${block(errors
|
|
3584
|
-
.map(({ name, stack, message }, index) => spaceTrim((block) => `
|
|
3636
|
+
.map(({ name, stack, message }, index) => spaceTrim$1((block) => `
|
|
3585
3637
|
${name} ${index + 1}:
|
|
3586
3638
|
${block(stack || message)}
|
|
3587
3639
|
`))
|
|
@@ -4052,14 +4104,14 @@ class MultipleLlmExecutionTools {
|
|
|
4052
4104
|
if (description === undefined) {
|
|
4053
4105
|
return headLine;
|
|
4054
4106
|
}
|
|
4055
|
-
return spaceTrim$
|
|
4107
|
+
return spaceTrim$2((block) => `
|
|
4056
4108
|
${headLine}
|
|
4057
4109
|
|
|
4058
4110
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
4059
4111
|
`);
|
|
4060
4112
|
})
|
|
4061
4113
|
.join('\n\n');
|
|
4062
|
-
return spaceTrim$
|
|
4114
|
+
return spaceTrim$2((block) => `
|
|
4063
4115
|
Multiple LLM Providers:
|
|
4064
4116
|
|
|
4065
4117
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -4150,7 +4202,7 @@ class MultipleLlmExecutionTools {
|
|
|
4150
4202
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4151
4203
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4152
4204
|
// 3) ...
|
|
4153
|
-
spaceTrim$
|
|
4205
|
+
spaceTrim$2((block) => `
|
|
4154
4206
|
All execution tools of ${this.title} failed:
|
|
4155
4207
|
|
|
4156
4208
|
${block(errors
|
|
@@ -4163,7 +4215,7 @@ class MultipleLlmExecutionTools {
|
|
|
4163
4215
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
4164
4216
|
}
|
|
4165
4217
|
else {
|
|
4166
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
4218
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
4167
4219
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
4168
4220
|
|
|
4169
4221
|
Available \`LlmExecutionTools\`:
|
|
@@ -4196,7 +4248,7 @@ class MultipleLlmExecutionTools {
|
|
|
4196
4248
|
*/
|
|
4197
4249
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
4198
4250
|
if (llmExecutionTools.length === 0) {
|
|
4199
|
-
const warningMessage = spaceTrim$
|
|
4251
|
+
const warningMessage = spaceTrim$2(`
|
|
4200
4252
|
You have not provided any \`LlmExecutionTools\`
|
|
4201
4253
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
4202
4254
|
|
|
@@ -4513,14 +4565,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4513
4565
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4514
4566
|
});
|
|
4515
4567
|
if (metadata.length === 0) {
|
|
4516
|
-
return spaceTrim$
|
|
4568
|
+
return spaceTrim$2(`
|
|
4517
4569
|
**No scrapers are available**
|
|
4518
4570
|
|
|
4519
4571
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4520
4572
|
At least there should be available the metadata of the scrapers
|
|
4521
4573
|
`);
|
|
4522
4574
|
}
|
|
4523
|
-
return spaceTrim$
|
|
4575
|
+
return spaceTrim$2((block) => `
|
|
4524
4576
|
Available scrapers are:
|
|
4525
4577
|
${block(metadata
|
|
4526
4578
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4621,7 +4673,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4621
4673
|
else if (urlOrRequest instanceof Request) {
|
|
4622
4674
|
url = urlOrRequest.url;
|
|
4623
4675
|
}
|
|
4624
|
-
throw new PromptbookFetchError(spaceTrim$
|
|
4676
|
+
throw new PromptbookFetchError(spaceTrim$2((block) => `
|
|
4625
4677
|
Can not fetch "${url}"
|
|
4626
4678
|
|
|
4627
4679
|
Fetch error:
|
|
@@ -4782,7 +4834,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4782
4834
|
const fileExtension = getFileExtension(filename);
|
|
4783
4835
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4784
4836
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4785
|
-
throw new NotFoundError(spaceTrim$
|
|
4837
|
+
throw new NotFoundError(spaceTrim$2((block) => `
|
|
4786
4838
|
Can not make source handler for file which does not exist:
|
|
4787
4839
|
|
|
4788
4840
|
File:
|
|
@@ -4875,7 +4927,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4875
4927
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
4876
4928
|
break;
|
|
4877
4929
|
}
|
|
4878
|
-
console.warn(spaceTrim$
|
|
4930
|
+
console.warn(spaceTrim$2((block) => `
|
|
4879
4931
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
4880
4932
|
|
|
4881
4933
|
The source:
|
|
@@ -4891,7 +4943,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4891
4943
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4892
4944
|
}
|
|
4893
4945
|
if (partialPieces === null) {
|
|
4894
|
-
throw new KnowledgeScrapeError(spaceTrim$
|
|
4946
|
+
throw new KnowledgeScrapeError(spaceTrim$2((block) => `
|
|
4895
4947
|
Cannot scrape knowledge
|
|
4896
4948
|
|
|
4897
4949
|
The source:
|
|
@@ -4970,7 +5022,7 @@ async function prepareTasks(pipeline, tools, options) {
|
|
|
4970
5022
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
4971
5023
|
knowledgePiecesCount > 0 &&
|
|
4972
5024
|
!dependentParameterNames.includes('knowledge')) {
|
|
4973
|
-
preparedContent = spaceTrim(`
|
|
5025
|
+
preparedContent = spaceTrim$1(`
|
|
4974
5026
|
{content}
|
|
4975
5027
|
|
|
4976
5028
|
## Knowledge
|
|
@@ -5283,7 +5335,7 @@ function extractVariablesFromJavascript(script) {
|
|
|
5283
5335
|
}
|
|
5284
5336
|
catch (error) {
|
|
5285
5337
|
assertsError(error);
|
|
5286
|
-
throw new ParseError(spaceTrim((block) => `
|
|
5338
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
5287
5339
|
Can not extract variables from the script
|
|
5288
5340
|
${block(error.stack || error.message)}
|
|
5289
5341
|
|
|
@@ -5466,7 +5518,7 @@ const CsvFormatParser = {
|
|
|
5466
5518
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5467
5519
|
const csv = csvParse(value, settings);
|
|
5468
5520
|
if (csv.errors.length !== 0) {
|
|
5469
|
-
throw new CsvFormatError(spaceTrim$
|
|
5521
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5470
5522
|
CSV parsing error
|
|
5471
5523
|
|
|
5472
5524
|
Error(s) from CSV parsing:
|
|
@@ -5511,7 +5563,7 @@ const CsvFormatParser = {
|
|
|
5511
5563
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5512
5564
|
const csv = csvParse(value, settings);
|
|
5513
5565
|
if (csv.errors.length !== 0) {
|
|
5514
|
-
throw new CsvFormatError(spaceTrim$
|
|
5566
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5515
5567
|
CSV parsing error
|
|
5516
5568
|
|
|
5517
5569
|
Error(s) from CSV parsing:
|
|
@@ -5721,7 +5773,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5721
5773
|
}
|
|
5722
5774
|
// Phase 2️⃣: Non-matching mapping
|
|
5723
5775
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5724
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
5776
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
5725
5777
|
Can not map available parameters to expected parameters
|
|
5726
5778
|
|
|
5727
5779
|
Mapped parameters:
|
|
@@ -6120,7 +6172,7 @@ function validatePromptResult(options) {
|
|
|
6120
6172
|
}
|
|
6121
6173
|
catch (error) {
|
|
6122
6174
|
keepUnused(error);
|
|
6123
|
-
throw new ExpectError(spaceTrim((block) => `
|
|
6175
|
+
throw new ExpectError(spaceTrim$1((block) => `
|
|
6124
6176
|
Expected valid JSON string
|
|
6125
6177
|
|
|
6126
6178
|
The expected JSON text:
|
|
@@ -6183,7 +6235,7 @@ async function executeAttempts(options) {
|
|
|
6183
6235
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
6184
6236
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
6185
6237
|
if (isJokerAttempt && !jokerParameterName) {
|
|
6186
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6238
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6187
6239
|
Joker not found in attempt ${attemptIndex}
|
|
6188
6240
|
|
|
6189
6241
|
${block(pipelineIdentification)}
|
|
@@ -6194,7 +6246,7 @@ async function executeAttempts(options) {
|
|
|
6194
6246
|
$ongoingTaskResult.$expectError = null;
|
|
6195
6247
|
if (isJokerAttempt) {
|
|
6196
6248
|
if (parameters[jokerParameterName] === undefined) {
|
|
6197
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6249
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6198
6250
|
Joker parameter {${jokerParameterName}} not defined
|
|
6199
6251
|
|
|
6200
6252
|
${block(pipelineIdentification)}
|
|
@@ -6252,7 +6304,7 @@ async function executeAttempts(options) {
|
|
|
6252
6304
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
6253
6305
|
break variant;
|
|
6254
6306
|
case 'EMBEDDING':
|
|
6255
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6307
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6256
6308
|
Embedding model can not be used in pipeline
|
|
6257
6309
|
|
|
6258
6310
|
This should be catched during parsing
|
|
@@ -6263,7 +6315,7 @@ async function executeAttempts(options) {
|
|
|
6263
6315
|
break variant;
|
|
6264
6316
|
// <- case [🤖]:
|
|
6265
6317
|
default:
|
|
6266
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6318
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6267
6319
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
6268
6320
|
|
|
6269
6321
|
${block(pipelineIdentification)}
|
|
@@ -6274,14 +6326,14 @@ async function executeAttempts(options) {
|
|
|
6274
6326
|
break;
|
|
6275
6327
|
case 'SCRIPT_TASK':
|
|
6276
6328
|
if (arrayableToArray(tools.script).length === 0) {
|
|
6277
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6329
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6278
6330
|
No script execution tools are available
|
|
6279
6331
|
|
|
6280
6332
|
${block(pipelineIdentification)}
|
|
6281
6333
|
`));
|
|
6282
6334
|
}
|
|
6283
6335
|
if (!task.contentLanguage) {
|
|
6284
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6336
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6285
6337
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
6286
6338
|
|
|
6287
6339
|
${block(pipelineIdentification)}
|
|
@@ -6312,7 +6364,7 @@ async function executeAttempts(options) {
|
|
|
6312
6364
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
6313
6365
|
}
|
|
6314
6366
|
else {
|
|
6315
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6367
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6316
6368
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
6317
6369
|
|
|
6318
6370
|
${block(pipelineIdentification)}
|
|
@@ -6326,7 +6378,7 @@ async function executeAttempts(options) {
|
|
|
6326
6378
|
break taskType;
|
|
6327
6379
|
case 'DIALOG_TASK':
|
|
6328
6380
|
if (tools.userInterface === undefined) {
|
|
6329
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6381
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6330
6382
|
User interface tools are not available
|
|
6331
6383
|
|
|
6332
6384
|
${block(pipelineIdentification)}
|
|
@@ -6344,7 +6396,7 @@ async function executeAttempts(options) {
|
|
|
6344
6396
|
break taskType;
|
|
6345
6397
|
// <- case: [🅱]
|
|
6346
6398
|
default:
|
|
6347
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6399
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6348
6400
|
Unknown execution type "${task.taskType}"
|
|
6349
6401
|
|
|
6350
6402
|
${block(pipelineIdentification)}
|
|
@@ -6442,7 +6494,7 @@ async function executeAttempts(options) {
|
|
|
6442
6494
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
6443
6495
|
// Note: Create a summary of all failures
|
|
6444
6496
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6445
|
-
.map((failure) => spaceTrim((block) => {
|
|
6497
|
+
.map((failure) => spaceTrim$1((block) => {
|
|
6446
6498
|
var _a, _b;
|
|
6447
6499
|
return `
|
|
6448
6500
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -6452,14 +6504,14 @@ async function executeAttempts(options) {
|
|
|
6452
6504
|
Result:
|
|
6453
6505
|
${block(failure.result === null
|
|
6454
6506
|
? 'null'
|
|
6455
|
-
: spaceTrim(failure.result)
|
|
6507
|
+
: spaceTrim$1(failure.result)
|
|
6456
6508
|
.split('\n')
|
|
6457
6509
|
.map((line) => `> ${line}`)
|
|
6458
6510
|
.join('\n'))}
|
|
6459
6511
|
`;
|
|
6460
6512
|
}))
|
|
6461
6513
|
.join('\n\n---\n\n');
|
|
6462
|
-
throw new PipelineExecutionError(spaceTrim((block) => {
|
|
6514
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => {
|
|
6463
6515
|
var _a;
|
|
6464
6516
|
return `
|
|
6465
6517
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -6479,7 +6531,7 @@ async function executeAttempts(options) {
|
|
|
6479
6531
|
}
|
|
6480
6532
|
}
|
|
6481
6533
|
if ($ongoingTaskResult.$resultString === null) {
|
|
6482
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6534
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6483
6535
|
Something went wrong and prompt result is null
|
|
6484
6536
|
|
|
6485
6537
|
${block(pipelineIdentification)}
|
|
@@ -6506,7 +6558,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6506
6558
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6507
6559
|
}
|
|
6508
6560
|
if (jokerParameterNames.length !== 0) {
|
|
6509
|
-
throw new UnexpectedError(spaceTrim$
|
|
6561
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6510
6562
|
JOKER parameters are not supported together with FOREACH command
|
|
6511
6563
|
|
|
6512
6564
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6519,7 +6571,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6519
6571
|
if (formatDefinition === undefined) {
|
|
6520
6572
|
throw new UnexpectedError(
|
|
6521
6573
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6522
|
-
spaceTrim$
|
|
6574
|
+
spaceTrim$2((block) => `
|
|
6523
6575
|
Unsupported format "${task.foreach.formatName}"
|
|
6524
6576
|
|
|
6525
6577
|
Available formats:
|
|
@@ -6536,7 +6588,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6536
6588
|
if (subvalueParser === undefined) {
|
|
6537
6589
|
throw new UnexpectedError(
|
|
6538
6590
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6539
|
-
spaceTrim$
|
|
6591
|
+
spaceTrim$2((block) => `
|
|
6540
6592
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6541
6593
|
|
|
6542
6594
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6576,7 +6628,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6576
6628
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6577
6629
|
throw error;
|
|
6578
6630
|
}
|
|
6579
|
-
const highLevelError = new PipelineExecutionError(spaceTrim$
|
|
6631
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6580
6632
|
${error.message}
|
|
6581
6633
|
|
|
6582
6634
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6600,7 +6652,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6600
6652
|
...options,
|
|
6601
6653
|
priority: priority + index,
|
|
6602
6654
|
parameters: allSubparameters,
|
|
6603
|
-
pipelineIdentification: spaceTrim$
|
|
6655
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
6604
6656
|
${block(pipelineIdentification)}
|
|
6605
6657
|
Subparameter index: ${index}
|
|
6606
6658
|
`),
|
|
@@ -6609,7 +6661,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6609
6661
|
}
|
|
6610
6662
|
catch (error) {
|
|
6611
6663
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6612
|
-
console.error(spaceTrim$
|
|
6664
|
+
console.error(spaceTrim$2((block) => `
|
|
6613
6665
|
${error.message}
|
|
6614
6666
|
|
|
6615
6667
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6785,7 +6837,7 @@ async function getReservedParametersForTask(options) {
|
|
|
6785
6837
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
6786
6838
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
6787
6839
|
if (reservedParameters[parameterName] === undefined) {
|
|
6788
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6840
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6789
6841
|
Reserved parameter {${parameterName}} is not defined
|
|
6790
6842
|
|
|
6791
6843
|
${block(pipelineIdentification)}
|
|
@@ -6811,7 +6863,7 @@ async function executeTask(options) {
|
|
|
6811
6863
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
6812
6864
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
6813
6865
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
6814
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6866
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6815
6867
|
Dependent parameters are not consistent with used parameters:
|
|
6816
6868
|
|
|
6817
6869
|
Dependent parameters:
|
|
@@ -6855,7 +6907,7 @@ async function executeTask(options) {
|
|
|
6855
6907
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
6856
6908
|
// Houston, we have a problem
|
|
6857
6909
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
6858
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6910
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6859
6911
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
6860
6912
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
6861
6913
|
|
|
@@ -6924,7 +6976,7 @@ function filterJustOutputParameters(options) {
|
|
|
6924
6976
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
6925
6977
|
if (parametersToPass[parameter.name] === undefined) {
|
|
6926
6978
|
// [4]
|
|
6927
|
-
$warnings.push(new PipelineExecutionError(spaceTrim((block) => `
|
|
6979
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6928
6980
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
6929
6981
|
|
|
6930
6982
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -7032,7 +7084,7 @@ async function executePipeline(options) {
|
|
|
7032
7084
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
7033
7085
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
7034
7086
|
if (parameter === undefined) {
|
|
7035
|
-
warnings.push(new PipelineExecutionError(spaceTrim((block) => `
|
|
7087
|
+
warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
|
|
7036
7088
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
7037
7089
|
|
|
7038
7090
|
${block(pipelineIdentification)}
|
|
@@ -7047,7 +7099,7 @@ async function executePipeline(options) {
|
|
|
7047
7099
|
// TODO: [🧠] This should be also non-critical error
|
|
7048
7100
|
return exportJson({
|
|
7049
7101
|
name: 'pipelineExecutorResult',
|
|
7050
|
-
message: spaceTrim((block) => `
|
|
7102
|
+
message: spaceTrim$1((block) => `
|
|
7051
7103
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
7052
7104
|
|
|
7053
7105
|
${block(pipelineIdentification)}
|
|
@@ -7056,7 +7108,7 @@ async function executePipeline(options) {
|
|
|
7056
7108
|
value: {
|
|
7057
7109
|
isSuccessful: false,
|
|
7058
7110
|
errors: [
|
|
7059
|
-
new PipelineExecutionError(spaceTrim((block) => `
|
|
7111
|
+
new PipelineExecutionError(spaceTrim$1((block) => `
|
|
7060
7112
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
7061
7113
|
|
|
7062
7114
|
${block(pipelineIdentification)}
|
|
@@ -7083,7 +7135,7 @@ async function executePipeline(options) {
|
|
|
7083
7135
|
while (unresovedTasks.length > 0) {
|
|
7084
7136
|
if (loopLimit-- < 0) {
|
|
7085
7137
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
7086
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
7138
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
7087
7139
|
Loop limit reached during resolving parameters pipeline execution
|
|
7088
7140
|
|
|
7089
7141
|
${block(pipelineIdentification)}
|
|
@@ -7093,7 +7145,7 @@ async function executePipeline(options) {
|
|
|
7093
7145
|
if (!currentTask && resolving.length === 0) {
|
|
7094
7146
|
throw new UnexpectedError(
|
|
7095
7147
|
// TODO: [🐎] DRY
|
|
7096
|
-
spaceTrim((block) => `
|
|
7148
|
+
spaceTrim$1((block) => `
|
|
7097
7149
|
Can not resolve some parameters:
|
|
7098
7150
|
|
|
7099
7151
|
${block(pipelineIdentification)}
|
|
@@ -7133,7 +7185,7 @@ async function executePipeline(options) {
|
|
|
7133
7185
|
tools,
|
|
7134
7186
|
onProgress(newOngoingResult) {
|
|
7135
7187
|
if (isReturned) {
|
|
7136
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
7188
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
7137
7189
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
7138
7190
|
|
|
7139
7191
|
${block(pipelineIdentification)}
|
|
@@ -7150,7 +7202,7 @@ async function executePipeline(options) {
|
|
|
7150
7202
|
},
|
|
7151
7203
|
logLlmCall,
|
|
7152
7204
|
$executionReport: executionReport,
|
|
7153
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
7205
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
7154
7206
|
${block(pipelineIdentification)}
|
|
7155
7207
|
Task name: ${currentTask.name}
|
|
7156
7208
|
Task title: ${currentTask.title}
|
|
@@ -7259,7 +7311,7 @@ function createPipelineExecutor(options) {
|
|
|
7259
7311
|
preparedPipeline = pipeline;
|
|
7260
7312
|
}
|
|
7261
7313
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
7262
|
-
console.warn(spaceTrim((block) => `
|
|
7314
|
+
console.warn(spaceTrim$1((block) => `
|
|
7263
7315
|
Pipeline is not prepared
|
|
7264
7316
|
|
|
7265
7317
|
${block(pipelineIdentification)}
|
|
@@ -7284,7 +7336,7 @@ function createPipelineExecutor(options) {
|
|
|
7284
7336
|
tools,
|
|
7285
7337
|
onProgress,
|
|
7286
7338
|
logLlmCall,
|
|
7287
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
7339
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
7288
7340
|
${block(pipelineIdentification)}
|
|
7289
7341
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
7290
7342
|
`),
|
|
@@ -7481,8 +7533,8 @@ class MarkdownScraper {
|
|
|
7481
7533
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
7482
7534
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
7483
7535
|
let name = `piece-${i}`;
|
|
7484
|
-
let title = spaceTrim$
|
|
7485
|
-
const knowledgePieceContent = spaceTrim$
|
|
7536
|
+
let title = spaceTrim$2(knowledgeTextPiece.substring(0, 100));
|
|
7537
|
+
const knowledgePieceContent = spaceTrim$2(knowledgeTextPiece);
|
|
7486
7538
|
let keywords = [];
|
|
7487
7539
|
const index = [];
|
|
7488
7540
|
/*
|
|
@@ -7495,7 +7547,7 @@ class MarkdownScraper {
|
|
|
7495
7547
|
isCrashedOnError: true,
|
|
7496
7548
|
});
|
|
7497
7549
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
7498
|
-
title = spaceTrim$
|
|
7550
|
+
title = spaceTrim$2(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
7499
7551
|
name = titleToName(title);
|
|
7500
7552
|
// --- Keywords
|
|
7501
7553
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -7641,7 +7693,7 @@ class DocumentScraper {
|
|
|
7641
7693
|
await $execCommand(command);
|
|
7642
7694
|
// Note: [0]
|
|
7643
7695
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
7644
|
-
throw new UnexpectedError(spaceTrim$
|
|
7696
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
7645
7697
|
File that was supposed to be created by Pandoc does not exist for unknown reason
|
|
7646
7698
|
|
|
7647
7699
|
Expected file:
|