@promptbook/website-crawler 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 +147 -95
- 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 +116 -64
- 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,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim$
|
|
1
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { Readability } from '@mozilla/readability';
|
|
3
3
|
import { JSDOM } from 'jsdom';
|
|
4
4
|
import { SHA256 } from 'crypto-js';
|
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-66';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -77,6 +77,17 @@ function $deepFreeze(objectValue) {
|
|
|
77
77
|
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
78
78
|
*/
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Trims string from all 4 sides
|
|
82
|
+
*
|
|
83
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
84
|
+
* Developed by same author @hejny as this package
|
|
85
|
+
*
|
|
86
|
+
* @public exported from `@promptbook/utils`
|
|
87
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
88
|
+
*/
|
|
89
|
+
const spaceTrim = spaceTrim$1;
|
|
90
|
+
|
|
80
91
|
/**
|
|
81
92
|
* @private util of `@promptbook/color`
|
|
82
93
|
* @de
|
|
@@ -125,6 +136,7 @@ function take(initialValue) {
|
|
|
125
136
|
* @public exported from `@promptbook/color`
|
|
126
137
|
*/
|
|
127
138
|
const CSS_COLORS = {
|
|
139
|
+
promptbook: '#79EAFD',
|
|
128
140
|
transparent: 'rgba(0,0,0,0)',
|
|
129
141
|
aliceblue: '#f0f8ff',
|
|
130
142
|
antiquewhite: '#faebd7',
|
|
@@ -325,21 +337,61 @@ class Color {
|
|
|
325
337
|
* @param color
|
|
326
338
|
* @returns Color object
|
|
327
339
|
*/
|
|
328
|
-
static from(color) {
|
|
329
|
-
if (color
|
|
340
|
+
static from(color, _isSingleValue = false) {
|
|
341
|
+
if (color === '') {
|
|
342
|
+
throw new Error(`Can not create color from empty string`);
|
|
343
|
+
}
|
|
344
|
+
else if (color instanceof Color) {
|
|
330
345
|
return take(color);
|
|
331
346
|
}
|
|
332
347
|
else if (Color.isColor(color)) {
|
|
333
348
|
return take(color);
|
|
334
349
|
}
|
|
335
350
|
else if (typeof color === 'string') {
|
|
336
|
-
|
|
351
|
+
try {
|
|
352
|
+
return Color.fromString(color);
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
356
|
+
if (_isSingleValue) {
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
359
|
+
const parts = color.split(/[\s+,;|]/);
|
|
360
|
+
if (parts.length > 0) {
|
|
361
|
+
return Color.from(parts[0].trim(), true);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
throw new Error(`Can not create color from given string "${color}"`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
337
367
|
}
|
|
338
368
|
else {
|
|
339
369
|
console.error({ color });
|
|
340
370
|
throw new Error(`Can not create color from given object`);
|
|
341
371
|
}
|
|
342
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Creates a new Color instance from miscellaneous formats
|
|
375
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
376
|
+
*
|
|
377
|
+
* @param color
|
|
378
|
+
* @returns Color object
|
|
379
|
+
*/
|
|
380
|
+
static fromSafe(color) {
|
|
381
|
+
try {
|
|
382
|
+
return Color.from(color);
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
386
|
+
console.warn(spaceTrim((block) => `
|
|
387
|
+
Color.fromSafe error:
|
|
388
|
+
${block(error.message)}
|
|
389
|
+
|
|
390
|
+
Returning default PROMPTBOOK_COLOR.
|
|
391
|
+
`));
|
|
392
|
+
return Color.fromString('promptbook');
|
|
393
|
+
}
|
|
394
|
+
}
|
|
343
395
|
/**
|
|
344
396
|
* Creates a new Color instance from miscellaneous string formats
|
|
345
397
|
*
|
|
@@ -949,7 +1001,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
949
1001
|
*
|
|
950
1002
|
* @public exported from `@promptbook/core`
|
|
951
1003
|
*/
|
|
952
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1004
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
953
1005
|
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
954
1006
|
/**
|
|
955
1007
|
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
@@ -1146,7 +1198,7 @@ true);
|
|
|
1146
1198
|
*/
|
|
1147
1199
|
class NotYetImplementedError extends Error {
|
|
1148
1200
|
constructor(message) {
|
|
1149
|
-
super(spaceTrim((block) => `
|
|
1201
|
+
super(spaceTrim$1((block) => `
|
|
1150
1202
|
${block(message)}
|
|
1151
1203
|
|
|
1152
1204
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -1170,7 +1222,7 @@ class NotYetImplementedError extends Error {
|
|
|
1170
1222
|
function getErrorReportUrl(error) {
|
|
1171
1223
|
const report = {
|
|
1172
1224
|
title: `🐜 Error report from ${NAME}`,
|
|
1173
|
-
body: spaceTrim$
|
|
1225
|
+
body: spaceTrim$2((block) => `
|
|
1174
1226
|
|
|
1175
1227
|
|
|
1176
1228
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1213,7 +1265,7 @@ function getErrorReportUrl(error) {
|
|
|
1213
1265
|
*/
|
|
1214
1266
|
class UnexpectedError extends Error {
|
|
1215
1267
|
constructor(message) {
|
|
1216
|
-
super(spaceTrim((block) => `
|
|
1268
|
+
super(spaceTrim$1((block) => `
|
|
1217
1269
|
${block(message)}
|
|
1218
1270
|
|
|
1219
1271
|
Note: This error should not happen.
|
|
@@ -1997,7 +2049,7 @@ class WrappedError extends Error {
|
|
|
1997
2049
|
constructor(whatWasThrown) {
|
|
1998
2050
|
const tag = `[🤮]`;
|
|
1999
2051
|
console.error(tag, whatWasThrown);
|
|
2000
|
-
super(spaceTrim(`
|
|
2052
|
+
super(spaceTrim$1(`
|
|
2001
2053
|
Non-Error object was thrown
|
|
2002
2054
|
|
|
2003
2055
|
Note: Look for ${tag} in the console for more details
|
|
@@ -2223,7 +2275,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
2223
2275
|
pipelineString += '\n\n';
|
|
2224
2276
|
pipelineString += '```' + contentLanguage;
|
|
2225
2277
|
pipelineString += '\n';
|
|
2226
|
-
pipelineString += spaceTrim$
|
|
2278
|
+
pipelineString += spaceTrim$2(content);
|
|
2227
2279
|
// <- TODO: [main] !!3 Escape
|
|
2228
2280
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
2229
2281
|
pipelineString += '\n';
|
|
@@ -2317,7 +2369,7 @@ function checkSerializableAsJson(options) {
|
|
|
2317
2369
|
}
|
|
2318
2370
|
else if (typeof value === 'object') {
|
|
2319
2371
|
if (value instanceof Date) {
|
|
2320
|
-
throw new UnexpectedError(spaceTrim$
|
|
2372
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2321
2373
|
\`${name}\` is Date
|
|
2322
2374
|
|
|
2323
2375
|
Use \`string_date_iso8601\` instead
|
|
@@ -2336,7 +2388,7 @@ function checkSerializableAsJson(options) {
|
|
|
2336
2388
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2337
2389
|
}
|
|
2338
2390
|
else if (value instanceof Error) {
|
|
2339
|
-
throw new UnexpectedError(spaceTrim$
|
|
2391
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2340
2392
|
\`${name}\` is unserialized Error
|
|
2341
2393
|
|
|
2342
2394
|
Use function \`serializeError\`
|
|
@@ -2359,7 +2411,7 @@ function checkSerializableAsJson(options) {
|
|
|
2359
2411
|
}
|
|
2360
2412
|
catch (error) {
|
|
2361
2413
|
assertsError(error);
|
|
2362
|
-
throw new UnexpectedError(spaceTrim$
|
|
2414
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2363
2415
|
\`${name}\` is not serializable
|
|
2364
2416
|
|
|
2365
2417
|
${block(error.stack || error.message)}
|
|
@@ -2391,7 +2443,7 @@ function checkSerializableAsJson(options) {
|
|
|
2391
2443
|
}
|
|
2392
2444
|
}
|
|
2393
2445
|
else {
|
|
2394
|
-
throw new UnexpectedError(spaceTrim$
|
|
2446
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2395
2447
|
\`${name}\` is unknown type
|
|
2396
2448
|
|
|
2397
2449
|
Additional message for \`${name}\`:
|
|
@@ -2645,7 +2697,7 @@ function validatePipeline(pipeline) {
|
|
|
2645
2697
|
if (!(error instanceof PipelineLogicError)) {
|
|
2646
2698
|
throw error;
|
|
2647
2699
|
}
|
|
2648
|
-
console.error(spaceTrim((block) => `
|
|
2700
|
+
console.error(spaceTrim$1((block) => `
|
|
2649
2701
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2650
2702
|
|
|
2651
2703
|
${block(error.message)}
|
|
@@ -2672,7 +2724,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2672
2724
|
})();
|
|
2673
2725
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2674
2726
|
// <- Note: [🚲]
|
|
2675
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2727
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2676
2728
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
2677
2729
|
|
|
2678
2730
|
${block(pipelineIdentification)}
|
|
@@ -2680,7 +2732,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2680
2732
|
}
|
|
2681
2733
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
2682
2734
|
// <- Note: [🚲]
|
|
2683
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2735
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2684
2736
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
2685
2737
|
|
|
2686
2738
|
${block(pipelineIdentification)}
|
|
@@ -2689,7 +2741,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2689
2741
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2690
2742
|
if (!Array.isArray(pipeline.parameters)) {
|
|
2691
2743
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2692
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2744
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
2693
2745
|
Pipeline is valid JSON but with wrong structure
|
|
2694
2746
|
|
|
2695
2747
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -2700,7 +2752,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2700
2752
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2701
2753
|
if (!Array.isArray(pipeline.tasks)) {
|
|
2702
2754
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2703
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2755
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
2704
2756
|
Pipeline is valid JSON but with wrong structure
|
|
2705
2757
|
|
|
2706
2758
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -2726,7 +2778,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2726
2778
|
// Note: Check each parameter individually
|
|
2727
2779
|
for (const parameter of pipeline.parameters) {
|
|
2728
2780
|
if (parameter.isInput && parameter.isOutput) {
|
|
2729
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2781
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2730
2782
|
|
|
2731
2783
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
2732
2784
|
|
|
@@ -2737,7 +2789,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2737
2789
|
if (!parameter.isInput &&
|
|
2738
2790
|
!parameter.isOutput &&
|
|
2739
2791
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
2740
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2792
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2741
2793
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
2742
2794
|
|
|
2743
2795
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -2749,7 +2801,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2749
2801
|
}
|
|
2750
2802
|
// Note: Testing that parameter is either input or result of some task
|
|
2751
2803
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
2752
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2804
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2753
2805
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
2754
2806
|
|
|
2755
2807
|
You can do one of these:
|
|
@@ -2765,14 +2817,14 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2765
2817
|
// Note: Checking each task individually
|
|
2766
2818
|
for (const task of pipeline.tasks) {
|
|
2767
2819
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
2768
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2820
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2769
2821
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
2770
2822
|
|
|
2771
2823
|
${block(pipelineIdentification)}
|
|
2772
2824
|
`));
|
|
2773
2825
|
}
|
|
2774
2826
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
2775
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2827
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2776
2828
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
2777
2829
|
|
|
2778
2830
|
${block(pipelineIdentification)}
|
|
@@ -2782,7 +2834,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2782
2834
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
2783
2835
|
if (!task.format &&
|
|
2784
2836
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
2785
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2837
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2786
2838
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
2787
2839
|
|
|
2788
2840
|
${block(pipelineIdentification)}
|
|
@@ -2790,7 +2842,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2790
2842
|
}
|
|
2791
2843
|
for (const joker of task.jokerParameterNames) {
|
|
2792
2844
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
2793
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2845
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2794
2846
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
2795
2847
|
|
|
2796
2848
|
${block(pipelineIdentification)}
|
|
@@ -2801,21 +2853,21 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2801
2853
|
if (task.expectations) {
|
|
2802
2854
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
2803
2855
|
if (min !== undefined && max !== undefined && min > max) {
|
|
2804
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2856
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2805
2857
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
2806
2858
|
|
|
2807
2859
|
${block(pipelineIdentification)}
|
|
2808
2860
|
`));
|
|
2809
2861
|
}
|
|
2810
2862
|
if (min !== undefined && min < 0) {
|
|
2811
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2863
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2812
2864
|
Min expectation of ${unit} must be zero or positive
|
|
2813
2865
|
|
|
2814
2866
|
${block(pipelineIdentification)}
|
|
2815
2867
|
`));
|
|
2816
2868
|
}
|
|
2817
2869
|
if (max !== undefined && max <= 0) {
|
|
2818
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2870
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2819
2871
|
Max expectation of ${unit} must be positive
|
|
2820
2872
|
|
|
2821
2873
|
${block(pipelineIdentification)}
|
|
@@ -2837,7 +2889,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2837
2889
|
while (unresovedTasks.length > 0) {
|
|
2838
2890
|
if (loopLimit-- < 0) {
|
|
2839
2891
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2840
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2892
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2841
2893
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2842
2894
|
|
|
2843
2895
|
${block(pipelineIdentification)}
|
|
@@ -2847,7 +2899,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2847
2899
|
if (currentlyResovedTasks.length === 0) {
|
|
2848
2900
|
throw new PipelineLogicError(
|
|
2849
2901
|
// TODO: [🐎] DRY
|
|
2850
|
-
spaceTrim((block) => `
|
|
2902
|
+
spaceTrim$1((block) => `
|
|
2851
2903
|
|
|
2852
2904
|
Can not resolve some parameters:
|
|
2853
2905
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -3011,7 +3063,7 @@ class SimplePipelineCollection {
|
|
|
3011
3063
|
for (const pipeline of pipelines) {
|
|
3012
3064
|
// TODO: [👠] DRY
|
|
3013
3065
|
if (pipeline.pipelineUrl === undefined) {
|
|
3014
|
-
throw new PipelineUrlError(spaceTrim(`
|
|
3066
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
3015
3067
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
3016
3068
|
|
|
3017
3069
|
File:
|
|
@@ -3033,7 +3085,7 @@ class SimplePipelineCollection {
|
|
|
3033
3085
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
3034
3086
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
3035
3087
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
3036
|
-
throw new PipelineUrlError(spaceTrim(`
|
|
3088
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
3037
3089
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
3038
3090
|
|
|
3039
3091
|
Conflicting files:
|
|
@@ -3065,13 +3117,13 @@ class SimplePipelineCollection {
|
|
|
3065
3117
|
const pipeline = this.collection.get(url);
|
|
3066
3118
|
if (!pipeline) {
|
|
3067
3119
|
if (this.listPipelines().length === 0) {
|
|
3068
|
-
throw new NotFoundError(spaceTrim(`
|
|
3120
|
+
throw new NotFoundError(spaceTrim$1(`
|
|
3069
3121
|
Pipeline with url "${url}" not found
|
|
3070
3122
|
|
|
3071
3123
|
No pipelines available
|
|
3072
3124
|
`));
|
|
3073
3125
|
}
|
|
3074
|
-
throw new NotFoundError(spaceTrim((block) => `
|
|
3126
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
3075
3127
|
Pipeline with url "${url}" not found
|
|
3076
3128
|
|
|
3077
3129
|
Available pipelines:
|
|
@@ -3112,7 +3164,7 @@ function createPipelineCollectionFromJson(...promptbooks) {
|
|
|
3112
3164
|
*/
|
|
3113
3165
|
class MissingToolsError extends Error {
|
|
3114
3166
|
constructor(message) {
|
|
3115
|
-
super(spaceTrim((block) => `
|
|
3167
|
+
super(spaceTrim$1((block) => `
|
|
3116
3168
|
${block(message)}
|
|
3117
3169
|
|
|
3118
3170
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -3399,7 +3451,7 @@ function serializeError(error) {
|
|
|
3399
3451
|
const { name, message, stack } = error;
|
|
3400
3452
|
const { id } = error;
|
|
3401
3453
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3402
|
-
console.error(spaceTrim$
|
|
3454
|
+
console.error(spaceTrim$2((block) => `
|
|
3403
3455
|
|
|
3404
3456
|
Cannot serialize error with name "${name}"
|
|
3405
3457
|
|
|
@@ -3432,7 +3484,7 @@ function jsonParse(value) {
|
|
|
3432
3484
|
}
|
|
3433
3485
|
else if (typeof value !== 'string') {
|
|
3434
3486
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
3435
|
-
throw new Error(spaceTrim$
|
|
3487
|
+
throw new Error(spaceTrim$2(`
|
|
3436
3488
|
Can not parse JSON from non-string value.
|
|
3437
3489
|
|
|
3438
3490
|
The value type: ${typeof value}
|
|
@@ -3446,7 +3498,7 @@ function jsonParse(value) {
|
|
|
3446
3498
|
if (!(error instanceof Error)) {
|
|
3447
3499
|
throw error;
|
|
3448
3500
|
}
|
|
3449
|
-
throw new Error(spaceTrim$
|
|
3501
|
+
throw new Error(spaceTrim$2((block) => `
|
|
3450
3502
|
${block(error.message)}
|
|
3451
3503
|
|
|
3452
3504
|
The expected JSON text:
|
|
@@ -3499,7 +3551,7 @@ function deserializeError(error) {
|
|
|
3499
3551
|
message = `${name}: ${message}`;
|
|
3500
3552
|
}
|
|
3501
3553
|
if (stack !== undefined && stack !== '') {
|
|
3502
|
-
message = spaceTrim$
|
|
3554
|
+
message = spaceTrim$2((block) => `
|
|
3503
3555
|
${block(message)}
|
|
3504
3556
|
|
|
3505
3557
|
Original stack trace:
|
|
@@ -3536,11 +3588,11 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
3536
3588
|
throw deserializeError(errors[0]);
|
|
3537
3589
|
}
|
|
3538
3590
|
else {
|
|
3539
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3591
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
3540
3592
|
Multiple errors occurred during Promptbook execution
|
|
3541
3593
|
|
|
3542
3594
|
${block(errors
|
|
3543
|
-
.map(({ name, stack, message }, index) => spaceTrim((block) => `
|
|
3595
|
+
.map(({ name, stack, message }, index) => spaceTrim$1((block) => `
|
|
3544
3596
|
${name} ${index + 1}:
|
|
3545
3597
|
${block(stack || message)}
|
|
3546
3598
|
`))
|
|
@@ -4011,14 +4063,14 @@ class MultipleLlmExecutionTools {
|
|
|
4011
4063
|
if (description === undefined) {
|
|
4012
4064
|
return headLine;
|
|
4013
4065
|
}
|
|
4014
|
-
return spaceTrim$
|
|
4066
|
+
return spaceTrim$2((block) => `
|
|
4015
4067
|
${headLine}
|
|
4016
4068
|
|
|
4017
4069
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
4018
4070
|
`);
|
|
4019
4071
|
})
|
|
4020
4072
|
.join('\n\n');
|
|
4021
|
-
return spaceTrim$
|
|
4073
|
+
return spaceTrim$2((block) => `
|
|
4022
4074
|
Multiple LLM Providers:
|
|
4023
4075
|
|
|
4024
4076
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -4109,7 +4161,7 @@ class MultipleLlmExecutionTools {
|
|
|
4109
4161
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4110
4162
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4111
4163
|
// 3) ...
|
|
4112
|
-
spaceTrim$
|
|
4164
|
+
spaceTrim$2((block) => `
|
|
4113
4165
|
All execution tools of ${this.title} failed:
|
|
4114
4166
|
|
|
4115
4167
|
${block(errors
|
|
@@ -4122,7 +4174,7 @@ class MultipleLlmExecutionTools {
|
|
|
4122
4174
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
4123
4175
|
}
|
|
4124
4176
|
else {
|
|
4125
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
4177
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
4126
4178
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
4127
4179
|
|
|
4128
4180
|
Available \`LlmExecutionTools\`:
|
|
@@ -4155,7 +4207,7 @@ class MultipleLlmExecutionTools {
|
|
|
4155
4207
|
*/
|
|
4156
4208
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
4157
4209
|
if (llmExecutionTools.length === 0) {
|
|
4158
|
-
const warningMessage = spaceTrim$
|
|
4210
|
+
const warningMessage = spaceTrim$2(`
|
|
4159
4211
|
You have not provided any \`LlmExecutionTools\`
|
|
4160
4212
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
4161
4213
|
|
|
@@ -4328,14 +4380,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4328
4380
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4329
4381
|
});
|
|
4330
4382
|
if (metadata.length === 0) {
|
|
4331
|
-
return spaceTrim$
|
|
4383
|
+
return spaceTrim$2(`
|
|
4332
4384
|
**No scrapers are available**
|
|
4333
4385
|
|
|
4334
4386
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4335
4387
|
At least there should be available the metadata of the scrapers
|
|
4336
4388
|
`);
|
|
4337
4389
|
}
|
|
4338
|
-
return spaceTrim$
|
|
4390
|
+
return spaceTrim$2((block) => `
|
|
4339
4391
|
Available scrapers are:
|
|
4340
4392
|
${block(metadata
|
|
4341
4393
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4471,7 +4523,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4471
4523
|
else if (urlOrRequest instanceof Request) {
|
|
4472
4524
|
url = urlOrRequest.url;
|
|
4473
4525
|
}
|
|
4474
|
-
throw new PromptbookFetchError(spaceTrim$
|
|
4526
|
+
throw new PromptbookFetchError(spaceTrim$2((block) => `
|
|
4475
4527
|
Can not fetch "${url}"
|
|
4476
4528
|
|
|
4477
4529
|
Fetch error:
|
|
@@ -4632,7 +4684,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4632
4684
|
const fileExtension = getFileExtension(filename);
|
|
4633
4685
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4634
4686
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4635
|
-
throw new NotFoundError(spaceTrim$
|
|
4687
|
+
throw new NotFoundError(spaceTrim$2((block) => `
|
|
4636
4688
|
Can not make source handler for file which does not exist:
|
|
4637
4689
|
|
|
4638
4690
|
File:
|
|
@@ -4725,7 +4777,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4725
4777
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
4726
4778
|
break;
|
|
4727
4779
|
}
|
|
4728
|
-
console.warn(spaceTrim$
|
|
4780
|
+
console.warn(spaceTrim$2((block) => `
|
|
4729
4781
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
4730
4782
|
|
|
4731
4783
|
The source:
|
|
@@ -4741,7 +4793,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4741
4793
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4742
4794
|
}
|
|
4743
4795
|
if (partialPieces === null) {
|
|
4744
|
-
throw new KnowledgeScrapeError(spaceTrim$
|
|
4796
|
+
throw new KnowledgeScrapeError(spaceTrim$2((block) => `
|
|
4745
4797
|
Cannot scrape knowledge
|
|
4746
4798
|
|
|
4747
4799
|
The source:
|
|
@@ -4820,7 +4872,7 @@ async function prepareTasks(pipeline, tools, options) {
|
|
|
4820
4872
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
4821
4873
|
knowledgePiecesCount > 0 &&
|
|
4822
4874
|
!dependentParameterNames.includes('knowledge')) {
|
|
4823
|
-
preparedContent = spaceTrim(`
|
|
4875
|
+
preparedContent = spaceTrim$1(`
|
|
4824
4876
|
{content}
|
|
4825
4877
|
|
|
4826
4878
|
## Knowledge
|
|
@@ -5133,7 +5185,7 @@ function extractVariablesFromJavascript(script) {
|
|
|
5133
5185
|
}
|
|
5134
5186
|
catch (error) {
|
|
5135
5187
|
assertsError(error);
|
|
5136
|
-
throw new ParseError(spaceTrim((block) => `
|
|
5188
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
5137
5189
|
Can not extract variables from the script
|
|
5138
5190
|
${block(error.stack || error.message)}
|
|
5139
5191
|
|
|
@@ -5316,7 +5368,7 @@ const CsvFormatParser = {
|
|
|
5316
5368
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5317
5369
|
const csv = csvParse(value, settings);
|
|
5318
5370
|
if (csv.errors.length !== 0) {
|
|
5319
|
-
throw new CsvFormatError(spaceTrim$
|
|
5371
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5320
5372
|
CSV parsing error
|
|
5321
5373
|
|
|
5322
5374
|
Error(s) from CSV parsing:
|
|
@@ -5361,7 +5413,7 @@ const CsvFormatParser = {
|
|
|
5361
5413
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5362
5414
|
const csv = csvParse(value, settings);
|
|
5363
5415
|
if (csv.errors.length !== 0) {
|
|
5364
|
-
throw new CsvFormatError(spaceTrim$
|
|
5416
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5365
5417
|
CSV parsing error
|
|
5366
5418
|
|
|
5367
5419
|
Error(s) from CSV parsing:
|
|
@@ -5571,7 +5623,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5571
5623
|
}
|
|
5572
5624
|
// Phase 2️⃣: Non-matching mapping
|
|
5573
5625
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5574
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
5626
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
5575
5627
|
Can not map available parameters to expected parameters
|
|
5576
5628
|
|
|
5577
5629
|
Mapped parameters:
|
|
@@ -5970,7 +6022,7 @@ function validatePromptResult(options) {
|
|
|
5970
6022
|
}
|
|
5971
6023
|
catch (error) {
|
|
5972
6024
|
keepUnused(error);
|
|
5973
|
-
throw new ExpectError(spaceTrim((block) => `
|
|
6025
|
+
throw new ExpectError(spaceTrim$1((block) => `
|
|
5974
6026
|
Expected valid JSON string
|
|
5975
6027
|
|
|
5976
6028
|
The expected JSON text:
|
|
@@ -6033,7 +6085,7 @@ async function executeAttempts(options) {
|
|
|
6033
6085
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
6034
6086
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
6035
6087
|
if (isJokerAttempt && !jokerParameterName) {
|
|
6036
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6088
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6037
6089
|
Joker not found in attempt ${attemptIndex}
|
|
6038
6090
|
|
|
6039
6091
|
${block(pipelineIdentification)}
|
|
@@ -6044,7 +6096,7 @@ async function executeAttempts(options) {
|
|
|
6044
6096
|
$ongoingTaskResult.$expectError = null;
|
|
6045
6097
|
if (isJokerAttempt) {
|
|
6046
6098
|
if (parameters[jokerParameterName] === undefined) {
|
|
6047
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6099
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6048
6100
|
Joker parameter {${jokerParameterName}} not defined
|
|
6049
6101
|
|
|
6050
6102
|
${block(pipelineIdentification)}
|
|
@@ -6102,7 +6154,7 @@ async function executeAttempts(options) {
|
|
|
6102
6154
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
6103
6155
|
break variant;
|
|
6104
6156
|
case 'EMBEDDING':
|
|
6105
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6157
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6106
6158
|
Embedding model can not be used in pipeline
|
|
6107
6159
|
|
|
6108
6160
|
This should be catched during parsing
|
|
@@ -6113,7 +6165,7 @@ async function executeAttempts(options) {
|
|
|
6113
6165
|
break variant;
|
|
6114
6166
|
// <- case [🤖]:
|
|
6115
6167
|
default:
|
|
6116
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6168
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6117
6169
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
6118
6170
|
|
|
6119
6171
|
${block(pipelineIdentification)}
|
|
@@ -6124,14 +6176,14 @@ async function executeAttempts(options) {
|
|
|
6124
6176
|
break;
|
|
6125
6177
|
case 'SCRIPT_TASK':
|
|
6126
6178
|
if (arrayableToArray(tools.script).length === 0) {
|
|
6127
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6179
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6128
6180
|
No script execution tools are available
|
|
6129
6181
|
|
|
6130
6182
|
${block(pipelineIdentification)}
|
|
6131
6183
|
`));
|
|
6132
6184
|
}
|
|
6133
6185
|
if (!task.contentLanguage) {
|
|
6134
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6186
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6135
6187
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
6136
6188
|
|
|
6137
6189
|
${block(pipelineIdentification)}
|
|
@@ -6162,7 +6214,7 @@ async function executeAttempts(options) {
|
|
|
6162
6214
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
6163
6215
|
}
|
|
6164
6216
|
else {
|
|
6165
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6217
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6166
6218
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
6167
6219
|
|
|
6168
6220
|
${block(pipelineIdentification)}
|
|
@@ -6176,7 +6228,7 @@ async function executeAttempts(options) {
|
|
|
6176
6228
|
break taskType;
|
|
6177
6229
|
case 'DIALOG_TASK':
|
|
6178
6230
|
if (tools.userInterface === undefined) {
|
|
6179
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6231
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6180
6232
|
User interface tools are not available
|
|
6181
6233
|
|
|
6182
6234
|
${block(pipelineIdentification)}
|
|
@@ -6194,7 +6246,7 @@ async function executeAttempts(options) {
|
|
|
6194
6246
|
break taskType;
|
|
6195
6247
|
// <- case: [🅱]
|
|
6196
6248
|
default:
|
|
6197
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6249
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6198
6250
|
Unknown execution type "${task.taskType}"
|
|
6199
6251
|
|
|
6200
6252
|
${block(pipelineIdentification)}
|
|
@@ -6292,7 +6344,7 @@ async function executeAttempts(options) {
|
|
|
6292
6344
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
6293
6345
|
// Note: Create a summary of all failures
|
|
6294
6346
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6295
|
-
.map((failure) => spaceTrim((block) => {
|
|
6347
|
+
.map((failure) => spaceTrim$1((block) => {
|
|
6296
6348
|
var _a, _b;
|
|
6297
6349
|
return `
|
|
6298
6350
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -6302,14 +6354,14 @@ async function executeAttempts(options) {
|
|
|
6302
6354
|
Result:
|
|
6303
6355
|
${block(failure.result === null
|
|
6304
6356
|
? 'null'
|
|
6305
|
-
: spaceTrim(failure.result)
|
|
6357
|
+
: spaceTrim$1(failure.result)
|
|
6306
6358
|
.split('\n')
|
|
6307
6359
|
.map((line) => `> ${line}`)
|
|
6308
6360
|
.join('\n'))}
|
|
6309
6361
|
`;
|
|
6310
6362
|
}))
|
|
6311
6363
|
.join('\n\n---\n\n');
|
|
6312
|
-
throw new PipelineExecutionError(spaceTrim((block) => {
|
|
6364
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => {
|
|
6313
6365
|
var _a;
|
|
6314
6366
|
return `
|
|
6315
6367
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -6329,7 +6381,7 @@ async function executeAttempts(options) {
|
|
|
6329
6381
|
}
|
|
6330
6382
|
}
|
|
6331
6383
|
if ($ongoingTaskResult.$resultString === null) {
|
|
6332
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6384
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6333
6385
|
Something went wrong and prompt result is null
|
|
6334
6386
|
|
|
6335
6387
|
${block(pipelineIdentification)}
|
|
@@ -6356,7 +6408,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6356
6408
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6357
6409
|
}
|
|
6358
6410
|
if (jokerParameterNames.length !== 0) {
|
|
6359
|
-
throw new UnexpectedError(spaceTrim$
|
|
6411
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6360
6412
|
JOKER parameters are not supported together with FOREACH command
|
|
6361
6413
|
|
|
6362
6414
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6369,7 +6421,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6369
6421
|
if (formatDefinition === undefined) {
|
|
6370
6422
|
throw new UnexpectedError(
|
|
6371
6423
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6372
|
-
spaceTrim$
|
|
6424
|
+
spaceTrim$2((block) => `
|
|
6373
6425
|
Unsupported format "${task.foreach.formatName}"
|
|
6374
6426
|
|
|
6375
6427
|
Available formats:
|
|
@@ -6386,7 +6438,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6386
6438
|
if (subvalueParser === undefined) {
|
|
6387
6439
|
throw new UnexpectedError(
|
|
6388
6440
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6389
|
-
spaceTrim$
|
|
6441
|
+
spaceTrim$2((block) => `
|
|
6390
6442
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6391
6443
|
|
|
6392
6444
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6426,7 +6478,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6426
6478
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6427
6479
|
throw error;
|
|
6428
6480
|
}
|
|
6429
|
-
const highLevelError = new PipelineExecutionError(spaceTrim$
|
|
6481
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6430
6482
|
${error.message}
|
|
6431
6483
|
|
|
6432
6484
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6450,7 +6502,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6450
6502
|
...options,
|
|
6451
6503
|
priority: priority + index,
|
|
6452
6504
|
parameters: allSubparameters,
|
|
6453
|
-
pipelineIdentification: spaceTrim$
|
|
6505
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
6454
6506
|
${block(pipelineIdentification)}
|
|
6455
6507
|
Subparameter index: ${index}
|
|
6456
6508
|
`),
|
|
@@ -6459,7 +6511,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6459
6511
|
}
|
|
6460
6512
|
catch (error) {
|
|
6461
6513
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6462
|
-
console.error(spaceTrim$
|
|
6514
|
+
console.error(spaceTrim$2((block) => `
|
|
6463
6515
|
${error.message}
|
|
6464
6516
|
|
|
6465
6517
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6635,7 +6687,7 @@ async function getReservedParametersForTask(options) {
|
|
|
6635
6687
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
6636
6688
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
6637
6689
|
if (reservedParameters[parameterName] === undefined) {
|
|
6638
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6690
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6639
6691
|
Reserved parameter {${parameterName}} is not defined
|
|
6640
6692
|
|
|
6641
6693
|
${block(pipelineIdentification)}
|
|
@@ -6661,7 +6713,7 @@ async function executeTask(options) {
|
|
|
6661
6713
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
6662
6714
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
6663
6715
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
6664
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6716
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6665
6717
|
Dependent parameters are not consistent with used parameters:
|
|
6666
6718
|
|
|
6667
6719
|
Dependent parameters:
|
|
@@ -6705,7 +6757,7 @@ async function executeTask(options) {
|
|
|
6705
6757
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
6706
6758
|
// Houston, we have a problem
|
|
6707
6759
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
6708
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6760
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6709
6761
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
6710
6762
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
6711
6763
|
|
|
@@ -6774,7 +6826,7 @@ function filterJustOutputParameters(options) {
|
|
|
6774
6826
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
6775
6827
|
if (parametersToPass[parameter.name] === undefined) {
|
|
6776
6828
|
// [4]
|
|
6777
|
-
$warnings.push(new PipelineExecutionError(spaceTrim((block) => `
|
|
6829
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6778
6830
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
6779
6831
|
|
|
6780
6832
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -6882,7 +6934,7 @@ async function executePipeline(options) {
|
|
|
6882
6934
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
6883
6935
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
6884
6936
|
if (parameter === undefined) {
|
|
6885
|
-
warnings.push(new PipelineExecutionError(spaceTrim((block) => `
|
|
6937
|
+
warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6886
6938
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
6887
6939
|
|
|
6888
6940
|
${block(pipelineIdentification)}
|
|
@@ -6897,7 +6949,7 @@ async function executePipeline(options) {
|
|
|
6897
6949
|
// TODO: [🧠] This should be also non-critical error
|
|
6898
6950
|
return exportJson({
|
|
6899
6951
|
name: 'pipelineExecutorResult',
|
|
6900
|
-
message: spaceTrim((block) => `
|
|
6952
|
+
message: spaceTrim$1((block) => `
|
|
6901
6953
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
6902
6954
|
|
|
6903
6955
|
${block(pipelineIdentification)}
|
|
@@ -6906,7 +6958,7 @@ async function executePipeline(options) {
|
|
|
6906
6958
|
value: {
|
|
6907
6959
|
isSuccessful: false,
|
|
6908
6960
|
errors: [
|
|
6909
|
-
new PipelineExecutionError(spaceTrim((block) => `
|
|
6961
|
+
new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6910
6962
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
6911
6963
|
|
|
6912
6964
|
${block(pipelineIdentification)}
|
|
@@ -6933,7 +6985,7 @@ async function executePipeline(options) {
|
|
|
6933
6985
|
while (unresovedTasks.length > 0) {
|
|
6934
6986
|
if (loopLimit-- < 0) {
|
|
6935
6987
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
6936
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6988
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6937
6989
|
Loop limit reached during resolving parameters pipeline execution
|
|
6938
6990
|
|
|
6939
6991
|
${block(pipelineIdentification)}
|
|
@@ -6943,7 +6995,7 @@ async function executePipeline(options) {
|
|
|
6943
6995
|
if (!currentTask && resolving.length === 0) {
|
|
6944
6996
|
throw new UnexpectedError(
|
|
6945
6997
|
// TODO: [🐎] DRY
|
|
6946
|
-
spaceTrim((block) => `
|
|
6998
|
+
spaceTrim$1((block) => `
|
|
6947
6999
|
Can not resolve some parameters:
|
|
6948
7000
|
|
|
6949
7001
|
${block(pipelineIdentification)}
|
|
@@ -6983,7 +7035,7 @@ async function executePipeline(options) {
|
|
|
6983
7035
|
tools,
|
|
6984
7036
|
onProgress(newOngoingResult) {
|
|
6985
7037
|
if (isReturned) {
|
|
6986
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
7038
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6987
7039
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
6988
7040
|
|
|
6989
7041
|
${block(pipelineIdentification)}
|
|
@@ -7000,7 +7052,7 @@ async function executePipeline(options) {
|
|
|
7000
7052
|
},
|
|
7001
7053
|
logLlmCall,
|
|
7002
7054
|
$executionReport: executionReport,
|
|
7003
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
7055
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
7004
7056
|
${block(pipelineIdentification)}
|
|
7005
7057
|
Task name: ${currentTask.name}
|
|
7006
7058
|
Task title: ${currentTask.title}
|
|
@@ -7109,7 +7161,7 @@ function createPipelineExecutor(options) {
|
|
|
7109
7161
|
preparedPipeline = pipeline;
|
|
7110
7162
|
}
|
|
7111
7163
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
7112
|
-
console.warn(spaceTrim((block) => `
|
|
7164
|
+
console.warn(spaceTrim$1((block) => `
|
|
7113
7165
|
Pipeline is not prepared
|
|
7114
7166
|
|
|
7115
7167
|
${block(pipelineIdentification)}
|
|
@@ -7134,7 +7186,7 @@ function createPipelineExecutor(options) {
|
|
|
7134
7186
|
tools,
|
|
7135
7187
|
onProgress,
|
|
7136
7188
|
logLlmCall,
|
|
7137
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
7189
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
7138
7190
|
${block(pipelineIdentification)}
|
|
7139
7191
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
7140
7192
|
`),
|
|
@@ -7331,8 +7383,8 @@ class MarkdownScraper {
|
|
|
7331
7383
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
7332
7384
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
7333
7385
|
let name = `piece-${i}`;
|
|
7334
|
-
let title = spaceTrim$
|
|
7335
|
-
const knowledgePieceContent = spaceTrim$
|
|
7386
|
+
let title = spaceTrim$2(knowledgeTextPiece.substring(0, 100));
|
|
7387
|
+
const knowledgePieceContent = spaceTrim$2(knowledgeTextPiece);
|
|
7336
7388
|
let keywords = [];
|
|
7337
7389
|
const index = [];
|
|
7338
7390
|
/*
|
|
@@ -7345,7 +7397,7 @@ class MarkdownScraper {
|
|
|
7345
7397
|
isCrashedOnError: true,
|
|
7346
7398
|
});
|
|
7347
7399
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
7348
|
-
title = spaceTrim$
|
|
7400
|
+
title = spaceTrim$2(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
7349
7401
|
name = titleToName(title);
|
|
7350
7402
|
// --- Keywords
|
|
7351
7403
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|