@promptbook/markdown-utils 0.112.0-13 → 0.112.0-15
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 +67 -67
- package/esm/index.es.js.map +1 -1
- package/esm/src/cli/cli-commands/coder/{find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags.d.ts} +1 -1
- package/esm/src/cli/cli-commands/coder.d.ts +1 -1
- package/esm/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +1 -1
- package/esm/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/esm/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +1 -2
- package/esm/src/scrapers/document/DocumentScraper.d.ts +1 -2
- package/esm/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -2
- package/esm/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/esm/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +1 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +105 -106
- package/umd/index.umd.js.map +1 -1
- package/umd/src/cli/cli-commands/coder/{find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags.d.ts} +1 -1
- package/umd/src/cli/cli-commands/coder.d.ts +1 -1
- package/umd/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +1 -1
- package/umd/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/umd/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/umd/src/llm-providers/google/google-models.d.ts +1 -1
- package/umd/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/umd/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +1 -2
- package/umd/src/scrapers/document/DocumentScraper.d.ts +1 -2
- package/umd/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -2
- package/umd/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/umd/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +1 -2
- package/umd/src/version.d.ts +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('rxjs'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'rxjs', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.
|
|
5
|
-
})(this, (function (exports,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spacetrim, global.crypto, global.rxjs, global.waitasecond, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, spacetrim, crypto, rxjs, waitasecond, hexEncoder, sha256, path, cryptoJs, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
|
|
10
9
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
11
10
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
12
11
|
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
* @generated
|
|
25
24
|
* @see https://github.com/webgptorg/promptbook
|
|
26
25
|
*/
|
|
27
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-15';
|
|
28
27
|
/**
|
|
29
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -142,7 +141,7 @@
|
|
|
142
141
|
function extractOneBlockFromMarkdown(markdown) {
|
|
143
142
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
144
143
|
if (codeBlocks.length !== 1) {
|
|
145
|
-
throw new ParseError(
|
|
144
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
146
145
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
147
146
|
|
|
148
147
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -182,7 +181,7 @@
|
|
|
182
181
|
* @public exported from `@promptbook/utils`
|
|
183
182
|
* @see https://github.com/hejny/spacetrim#usage
|
|
184
183
|
*/
|
|
185
|
-
const spaceTrim =
|
|
184
|
+
const spaceTrim = spacetrim.spaceTrim;
|
|
186
185
|
|
|
187
186
|
/**
|
|
188
187
|
* @private util of `@promptbook/color`
|
|
@@ -1309,7 +1308,7 @@
|
|
|
1309
1308
|
function getErrorReportUrl(error) {
|
|
1310
1309
|
const report = {
|
|
1311
1310
|
title: `🐜 Error report from ${NAME}`,
|
|
1312
|
-
body:
|
|
1311
|
+
body: spacetrim.spaceTrim((block) => `
|
|
1313
1312
|
|
|
1314
1313
|
|
|
1315
1314
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1352,7 +1351,7 @@
|
|
|
1352
1351
|
*/
|
|
1353
1352
|
class UnexpectedError extends Error {
|
|
1354
1353
|
constructor(message) {
|
|
1355
|
-
super(
|
|
1354
|
+
super(spacetrim.spaceTrim((block) => `
|
|
1356
1355
|
${block(message)}
|
|
1357
1356
|
|
|
1358
1357
|
Note: This error should not happen.
|
|
@@ -1378,7 +1377,7 @@
|
|
|
1378
1377
|
constructor(whatWasThrown) {
|
|
1379
1378
|
const tag = `[🤮]`;
|
|
1380
1379
|
console.error(tag, whatWasThrown);
|
|
1381
|
-
super(
|
|
1380
|
+
super(spacetrim.spaceTrim(`
|
|
1382
1381
|
Non-Error object was thrown
|
|
1383
1382
|
|
|
1384
1383
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1750,7 +1749,7 @@
|
|
|
1750
1749
|
pipelineString += '\n\n';
|
|
1751
1750
|
pipelineString += '```' + contentLanguage;
|
|
1752
1751
|
pipelineString += '\n';
|
|
1753
|
-
pipelineString +=
|
|
1752
|
+
pipelineString += spacetrim.spaceTrim(content);
|
|
1754
1753
|
// <- TODO: [main] !!3 Escape
|
|
1755
1754
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
1756
1755
|
pipelineString += '\n';
|
|
@@ -1871,7 +1870,7 @@
|
|
|
1871
1870
|
}
|
|
1872
1871
|
else if (typeof value === 'object') {
|
|
1873
1872
|
if (value instanceof Date) {
|
|
1874
|
-
throw new UnexpectedError(
|
|
1873
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
1875
1874
|
\`${name}\` is Date
|
|
1876
1875
|
|
|
1877
1876
|
Use \`string_date_iso8601\` instead
|
|
@@ -1890,7 +1889,7 @@
|
|
|
1890
1889
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
1891
1890
|
}
|
|
1892
1891
|
else if (value instanceof Error) {
|
|
1893
|
-
throw new UnexpectedError(
|
|
1892
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
1894
1893
|
\`${name}\` is unserialized Error
|
|
1895
1894
|
|
|
1896
1895
|
Use function \`serializeError\`
|
|
@@ -1913,7 +1912,7 @@
|
|
|
1913
1912
|
}
|
|
1914
1913
|
catch (error) {
|
|
1915
1914
|
assertsError(error);
|
|
1916
|
-
throw new UnexpectedError(
|
|
1915
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
1917
1916
|
\`${name}\` is not serializable
|
|
1918
1917
|
|
|
1919
1918
|
${block(error.stack || error.message)}
|
|
@@ -1945,7 +1944,7 @@
|
|
|
1945
1944
|
}
|
|
1946
1945
|
}
|
|
1947
1946
|
else {
|
|
1948
|
-
throw new UnexpectedError(
|
|
1947
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
1949
1948
|
\`${name}\` is unknown type
|
|
1950
1949
|
|
|
1951
1950
|
Additional message for \`${name}\`:
|
|
@@ -2200,7 +2199,7 @@
|
|
|
2200
2199
|
if (!(error instanceof PipelineLogicError)) {
|
|
2201
2200
|
throw error;
|
|
2202
2201
|
}
|
|
2203
|
-
console.error(
|
|
2202
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
2204
2203
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2205
2204
|
|
|
2206
2205
|
${block(error.message)}
|
|
@@ -2227,7 +2226,7 @@
|
|
|
2227
2226
|
})();
|
|
2228
2227
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2229
2228
|
// <- Note: [🚲]
|
|
2230
|
-
throw new PipelineLogicError(
|
|
2229
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2231
2230
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
2232
2231
|
|
|
2233
2232
|
${block(pipelineIdentification)}
|
|
@@ -2235,7 +2234,7 @@
|
|
|
2235
2234
|
}
|
|
2236
2235
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
2237
2236
|
// <- Note: [🚲]
|
|
2238
|
-
throw new PipelineLogicError(
|
|
2237
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2239
2238
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
2240
2239
|
|
|
2241
2240
|
${block(pipelineIdentification)}
|
|
@@ -2244,7 +2243,7 @@
|
|
|
2244
2243
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2245
2244
|
if (!Array.isArray(pipeline.parameters)) {
|
|
2246
2245
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2247
|
-
throw new ParseError(
|
|
2246
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2248
2247
|
Pipeline is valid JSON but with wrong structure
|
|
2249
2248
|
|
|
2250
2249
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -2255,7 +2254,7 @@
|
|
|
2255
2254
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2256
2255
|
if (!Array.isArray(pipeline.tasks)) {
|
|
2257
2256
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2258
|
-
throw new ParseError(
|
|
2257
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2259
2258
|
Pipeline is valid JSON but with wrong structure
|
|
2260
2259
|
|
|
2261
2260
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -2281,7 +2280,7 @@
|
|
|
2281
2280
|
// Note: Check each parameter individually
|
|
2282
2281
|
for (const parameter of pipeline.parameters) {
|
|
2283
2282
|
if (parameter.isInput && parameter.isOutput) {
|
|
2284
|
-
throw new PipelineLogicError(
|
|
2283
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2285
2284
|
|
|
2286
2285
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
2287
2286
|
|
|
@@ -2292,7 +2291,7 @@
|
|
|
2292
2291
|
if (!parameter.isInput &&
|
|
2293
2292
|
!parameter.isOutput &&
|
|
2294
2293
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
2295
|
-
throw new PipelineLogicError(
|
|
2294
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2296
2295
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
2297
2296
|
|
|
2298
2297
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -2304,7 +2303,7 @@
|
|
|
2304
2303
|
}
|
|
2305
2304
|
// Note: Testing that parameter is either input or result of some task
|
|
2306
2305
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
2307
|
-
throw new PipelineLogicError(
|
|
2306
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2308
2307
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
2309
2308
|
|
|
2310
2309
|
You can do one of these:
|
|
@@ -2320,14 +2319,14 @@
|
|
|
2320
2319
|
// Note: Checking each task individually
|
|
2321
2320
|
for (const task of pipeline.tasks) {
|
|
2322
2321
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
2323
|
-
throw new PipelineLogicError(
|
|
2322
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2324
2323
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
2325
2324
|
|
|
2326
2325
|
${block(pipelineIdentification)}
|
|
2327
2326
|
`));
|
|
2328
2327
|
}
|
|
2329
2328
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
2330
|
-
throw new PipelineLogicError(
|
|
2329
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2331
2330
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
2332
2331
|
|
|
2333
2332
|
${block(pipelineIdentification)}
|
|
@@ -2337,7 +2336,7 @@
|
|
|
2337
2336
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
2338
2337
|
if (!task.format &&
|
|
2339
2338
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
2340
|
-
throw new PipelineLogicError(
|
|
2339
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2341
2340
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
2342
2341
|
|
|
2343
2342
|
${block(pipelineIdentification)}
|
|
@@ -2345,7 +2344,7 @@
|
|
|
2345
2344
|
}
|
|
2346
2345
|
for (const joker of task.jokerParameterNames) {
|
|
2347
2346
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
2348
|
-
throw new PipelineLogicError(
|
|
2347
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2349
2348
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
2350
2349
|
|
|
2351
2350
|
${block(pipelineIdentification)}
|
|
@@ -2356,21 +2355,21 @@
|
|
|
2356
2355
|
if (task.expectations) {
|
|
2357
2356
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
2358
2357
|
if (min !== undefined && max !== undefined && min > max) {
|
|
2359
|
-
throw new PipelineLogicError(
|
|
2358
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2360
2359
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
2361
2360
|
|
|
2362
2361
|
${block(pipelineIdentification)}
|
|
2363
2362
|
`));
|
|
2364
2363
|
}
|
|
2365
2364
|
if (min !== undefined && min < 0) {
|
|
2366
|
-
throw new PipelineLogicError(
|
|
2365
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2367
2366
|
Min expectation of ${unit} must be zero or positive
|
|
2368
2367
|
|
|
2369
2368
|
${block(pipelineIdentification)}
|
|
2370
2369
|
`));
|
|
2371
2370
|
}
|
|
2372
2371
|
if (max !== undefined && max <= 0) {
|
|
2373
|
-
throw new PipelineLogicError(
|
|
2372
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
2374
2373
|
Max expectation of ${unit} must be positive
|
|
2375
2374
|
|
|
2376
2375
|
${block(pipelineIdentification)}
|
|
@@ -2392,7 +2391,7 @@
|
|
|
2392
2391
|
while (unresovedTasks.length > 0) {
|
|
2393
2392
|
if (loopLimit-- < 0) {
|
|
2394
2393
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2395
|
-
throw new UnexpectedError(
|
|
2394
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2396
2395
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2397
2396
|
|
|
2398
2397
|
${block(pipelineIdentification)}
|
|
@@ -2402,7 +2401,7 @@
|
|
|
2402
2401
|
if (currentlyResovedTasks.length === 0) {
|
|
2403
2402
|
throw new PipelineLogicError(
|
|
2404
2403
|
// TODO: [🐎] DRY
|
|
2405
|
-
|
|
2404
|
+
spacetrim.spaceTrim((block) => `
|
|
2406
2405
|
|
|
2407
2406
|
Can not resolve some parameters:
|
|
2408
2407
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -2566,7 +2565,7 @@
|
|
|
2566
2565
|
for (const pipeline of pipelines) {
|
|
2567
2566
|
// TODO: [👠] DRY
|
|
2568
2567
|
if (pipeline.pipelineUrl === undefined) {
|
|
2569
|
-
throw new PipelineUrlError(
|
|
2568
|
+
throw new PipelineUrlError(spacetrim.spaceTrim(`
|
|
2570
2569
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
2571
2570
|
|
|
2572
2571
|
File:
|
|
@@ -2588,7 +2587,7 @@
|
|
|
2588
2587
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
2589
2588
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
2590
2589
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
2591
|
-
throw new PipelineUrlError(
|
|
2590
|
+
throw new PipelineUrlError(spacetrim.spaceTrim(`
|
|
2592
2591
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
2593
2592
|
|
|
2594
2593
|
Conflicting files:
|
|
@@ -2620,13 +2619,13 @@
|
|
|
2620
2619
|
const pipeline = this.collection.get(url);
|
|
2621
2620
|
if (!pipeline) {
|
|
2622
2621
|
if (this.listPipelines().length === 0) {
|
|
2623
|
-
throw new NotFoundError(
|
|
2622
|
+
throw new NotFoundError(spacetrim.spaceTrim(`
|
|
2624
2623
|
Pipeline with url "${url}" not found
|
|
2625
2624
|
|
|
2626
2625
|
No pipelines available
|
|
2627
2626
|
`));
|
|
2628
2627
|
}
|
|
2629
|
-
throw new NotFoundError(
|
|
2628
|
+
throw new NotFoundError(spacetrim.spaceTrim((block) => `
|
|
2630
2629
|
Pipeline with url "${url}" not found
|
|
2631
2630
|
|
|
2632
2631
|
Available pipelines:
|
|
@@ -2667,7 +2666,7 @@
|
|
|
2667
2666
|
*/
|
|
2668
2667
|
class MissingToolsError extends Error {
|
|
2669
2668
|
constructor(message) {
|
|
2670
|
-
super(
|
|
2669
|
+
super(spacetrim.spaceTrim((block) => `
|
|
2671
2670
|
${block(message)}
|
|
2672
2671
|
|
|
2673
2672
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -2914,7 +2913,7 @@
|
|
|
2914
2913
|
*/
|
|
2915
2914
|
class NotYetImplementedError extends Error {
|
|
2916
2915
|
constructor(message) {
|
|
2917
|
-
super(
|
|
2916
|
+
super(spacetrim.spaceTrim((block) => `
|
|
2918
2917
|
${block(message)}
|
|
2919
2918
|
|
|
2920
2919
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -3017,7 +3016,7 @@
|
|
|
3017
3016
|
const { name, message, stack } = error;
|
|
3018
3017
|
const { id } = error;
|
|
3019
3018
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3020
|
-
console.error(
|
|
3019
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
3021
3020
|
|
|
3022
3021
|
Cannot serialize error with name "${name}"
|
|
3023
3022
|
|
|
@@ -3050,7 +3049,7 @@
|
|
|
3050
3049
|
}
|
|
3051
3050
|
else if (typeof value !== 'string') {
|
|
3052
3051
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
3053
|
-
throw new Error(
|
|
3052
|
+
throw new Error(spacetrim.spaceTrim(`
|
|
3054
3053
|
Can not parse JSON from non-string value.
|
|
3055
3054
|
|
|
3056
3055
|
The value type: ${typeof value}
|
|
@@ -3064,7 +3063,7 @@
|
|
|
3064
3063
|
if (!(error instanceof Error)) {
|
|
3065
3064
|
throw error;
|
|
3066
3065
|
}
|
|
3067
|
-
throw new Error(
|
|
3066
|
+
throw new Error(spacetrim.spaceTrim((block) => `
|
|
3068
3067
|
${block(error.message)}
|
|
3069
3068
|
|
|
3070
3069
|
The expected JSON text:
|
|
@@ -3117,7 +3116,7 @@
|
|
|
3117
3116
|
message = `${name}: ${message}`;
|
|
3118
3117
|
}
|
|
3119
3118
|
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
3120
|
-
message =
|
|
3119
|
+
message = spacetrim.spaceTrim((block) => `
|
|
3121
3120
|
${block(message)}
|
|
3122
3121
|
|
|
3123
3122
|
Original stack trace:
|
|
@@ -3154,11 +3153,11 @@
|
|
|
3154
3153
|
throw deserializeError(errors[0]);
|
|
3155
3154
|
}
|
|
3156
3155
|
else {
|
|
3157
|
-
throw new PipelineExecutionError(
|
|
3156
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
3158
3157
|
Multiple errors occurred during Promptbook execution
|
|
3159
3158
|
|
|
3160
3159
|
${block(errors
|
|
3161
|
-
.map(({ name, stack, message }, index) =>
|
|
3160
|
+
.map(({ name, stack, message }, index) => spacetrim.spaceTrim((block) => `
|
|
3162
3161
|
${name} ${index + 1}:
|
|
3163
3162
|
${block(stack || message)}
|
|
3164
3163
|
`))
|
|
@@ -3667,14 +3666,14 @@
|
|
|
3667
3666
|
if (description === undefined) {
|
|
3668
3667
|
return headLine;
|
|
3669
3668
|
}
|
|
3670
|
-
return
|
|
3669
|
+
return spacetrim.spaceTrim((block) => `
|
|
3671
3670
|
${headLine}
|
|
3672
3671
|
|
|
3673
3672
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
3674
3673
|
`);
|
|
3675
3674
|
})
|
|
3676
3675
|
.join('\n\n');
|
|
3677
|
-
return
|
|
3676
|
+
return spacetrim.spaceTrim((block) => `
|
|
3678
3677
|
Multiple LLM Providers:
|
|
3679
3678
|
|
|
3680
3679
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -3776,7 +3775,7 @@
|
|
|
3776
3775
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3777
3776
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3778
3777
|
// 3) ...
|
|
3779
|
-
|
|
3778
|
+
spacetrim.spaceTrim((block) => `
|
|
3780
3779
|
All execution tools of ${this.title} failed:
|
|
3781
3780
|
|
|
3782
3781
|
${block(errors
|
|
@@ -3789,7 +3788,7 @@
|
|
|
3789
3788
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
3790
3789
|
}
|
|
3791
3790
|
else {
|
|
3792
|
-
throw new PipelineExecutionError(
|
|
3791
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
3793
3792
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
3794
3793
|
|
|
3795
3794
|
Available \`LlmExecutionTools\`:
|
|
@@ -3826,7 +3825,7 @@
|
|
|
3826
3825
|
*/
|
|
3827
3826
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
3828
3827
|
if (llmExecutionTools.length === 0) {
|
|
3829
|
-
const warningMessage =
|
|
3828
|
+
const warningMessage = spacetrim.spaceTrim(`
|
|
3830
3829
|
You have not provided any \`LlmExecutionTools\`
|
|
3831
3830
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
3832
3831
|
|
|
@@ -4143,14 +4142,14 @@
|
|
|
4143
4142
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4144
4143
|
});
|
|
4145
4144
|
if (metadata.length === 0) {
|
|
4146
|
-
return
|
|
4145
|
+
return spacetrim.spaceTrim(`
|
|
4147
4146
|
**No scrapers are available**
|
|
4148
4147
|
|
|
4149
4148
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4150
4149
|
At least there should be available the metadata of the scrapers
|
|
4151
4150
|
`);
|
|
4152
4151
|
}
|
|
4153
|
-
return
|
|
4152
|
+
return spacetrim.spaceTrim((block) => `
|
|
4154
4153
|
Available scrapers are:
|
|
4155
4154
|
${block(metadata
|
|
4156
4155
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4656,7 +4655,7 @@
|
|
|
4656
4655
|
else if (urlOrRequest instanceof Request) {
|
|
4657
4656
|
url = urlOrRequest.url;
|
|
4658
4657
|
}
|
|
4659
|
-
throw new PromptbookFetchError(
|
|
4658
|
+
throw new PromptbookFetchError(spacetrim.spaceTrim((block) => `
|
|
4660
4659
|
Can not fetch "${url}"
|
|
4661
4660
|
|
|
4662
4661
|
Fetch error:
|
|
@@ -4816,7 +4815,7 @@
|
|
|
4816
4815
|
const fileExtension = getFileExtension(filename);
|
|
4817
4816
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4818
4817
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4819
|
-
throw new NotFoundError(
|
|
4818
|
+
throw new NotFoundError(spacetrim.spaceTrim((block) => `
|
|
4820
4819
|
Can not make source handler for file which does not exist:
|
|
4821
4820
|
|
|
4822
4821
|
File:
|
|
@@ -4909,7 +4908,7 @@
|
|
|
4909
4908
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
4910
4909
|
break;
|
|
4911
4910
|
}
|
|
4912
|
-
console.warn(
|
|
4911
|
+
console.warn(spacetrim.spaceTrim((block) => `
|
|
4913
4912
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
4914
4913
|
|
|
4915
4914
|
The source:
|
|
@@ -4925,7 +4924,7 @@
|
|
|
4925
4924
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4926
4925
|
}
|
|
4927
4926
|
if (partialPieces === null) {
|
|
4928
|
-
throw new KnowledgeScrapeError(
|
|
4927
|
+
throw new KnowledgeScrapeError(spacetrim.spaceTrim((block) => `
|
|
4929
4928
|
Cannot scrape knowledge
|
|
4930
4929
|
|
|
4931
4930
|
The source:
|
|
@@ -5004,7 +5003,7 @@
|
|
|
5004
5003
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
5005
5004
|
knowledgePiecesCount > 0 &&
|
|
5006
5005
|
!dependentParameterNames.includes('knowledge')) {
|
|
5007
|
-
preparedContent =
|
|
5006
|
+
preparedContent = spacetrim.spaceTrim(`
|
|
5008
5007
|
{content}
|
|
5009
5008
|
|
|
5010
5009
|
## Knowledge
|
|
@@ -5317,7 +5316,7 @@
|
|
|
5317
5316
|
}
|
|
5318
5317
|
catch (error) {
|
|
5319
5318
|
assertsError(error);
|
|
5320
|
-
throw new ParseError(
|
|
5319
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
5321
5320
|
Can not extract variables from the script
|
|
5322
5321
|
${block(error.stack || error.message)}
|
|
5323
5322
|
|
|
@@ -5500,7 +5499,7 @@
|
|
|
5500
5499
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5501
5500
|
const csv = csvParse(value, settings);
|
|
5502
5501
|
if (csv.errors.length !== 0) {
|
|
5503
|
-
throw new CsvFormatError(
|
|
5502
|
+
throw new CsvFormatError(spacetrim.spaceTrim((block) => `
|
|
5504
5503
|
CSV parsing error
|
|
5505
5504
|
|
|
5506
5505
|
Error(s) from CSV parsing:
|
|
@@ -5545,7 +5544,7 @@
|
|
|
5545
5544
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5546
5545
|
const csv = csvParse(value, settings);
|
|
5547
5546
|
if (csv.errors.length !== 0) {
|
|
5548
|
-
throw new CsvFormatError(
|
|
5547
|
+
throw new CsvFormatError(spacetrim.spaceTrim((block) => `
|
|
5549
5548
|
CSV parsing error
|
|
5550
5549
|
|
|
5551
5550
|
Error(s) from CSV parsing:
|
|
@@ -5755,7 +5754,7 @@
|
|
|
5755
5754
|
}
|
|
5756
5755
|
// Phase 2️⃣: Non-matching mapping
|
|
5757
5756
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5758
|
-
throw new PipelineExecutionError(
|
|
5757
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
5759
5758
|
Can not map available parameters to expected parameters
|
|
5760
5759
|
|
|
5761
5760
|
Mapped parameters:
|
|
@@ -6052,7 +6051,7 @@
|
|
|
6052
6051
|
}
|
|
6053
6052
|
catch (error) {
|
|
6054
6053
|
keepUnused(error);
|
|
6055
|
-
throw new ExpectError(
|
|
6054
|
+
throw new ExpectError(spacetrim.spaceTrim((block) => `
|
|
6056
6055
|
Expected valid JSON string
|
|
6057
6056
|
|
|
6058
6057
|
The expected JSON text:
|
|
@@ -6115,7 +6114,7 @@
|
|
|
6115
6114
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
6116
6115
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
6117
6116
|
if (isJokerAttempt && !jokerParameterName) {
|
|
6118
|
-
throw new UnexpectedError(
|
|
6117
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
6119
6118
|
Joker not found in attempt ${attemptIndex}
|
|
6120
6119
|
|
|
6121
6120
|
${block(pipelineIdentification)}
|
|
@@ -6126,7 +6125,7 @@
|
|
|
6126
6125
|
$ongoingTaskResult.$expectError = null;
|
|
6127
6126
|
if (isJokerAttempt) {
|
|
6128
6127
|
if (parameters[jokerParameterName] === undefined) {
|
|
6129
|
-
throw new PipelineExecutionError(
|
|
6128
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6130
6129
|
Joker parameter {${jokerParameterName}} not defined
|
|
6131
6130
|
|
|
6132
6131
|
${block(pipelineIdentification)}
|
|
@@ -6185,7 +6184,7 @@
|
|
|
6185
6184
|
break variant;
|
|
6186
6185
|
case 'EMBEDDING':
|
|
6187
6186
|
case 'IMAGE_GENERATION':
|
|
6188
|
-
throw new PipelineExecutionError(
|
|
6187
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6189
6188
|
${modelRequirements.modelVariant} model can not be used in pipeline
|
|
6190
6189
|
|
|
6191
6190
|
This should be catched during parsing
|
|
@@ -6196,7 +6195,7 @@
|
|
|
6196
6195
|
break variant;
|
|
6197
6196
|
// <- case [🤖]:
|
|
6198
6197
|
default:
|
|
6199
|
-
throw new PipelineExecutionError(
|
|
6198
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6200
6199
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
6201
6200
|
|
|
6202
6201
|
${block(pipelineIdentification)}
|
|
@@ -6207,14 +6206,14 @@
|
|
|
6207
6206
|
break;
|
|
6208
6207
|
case 'SCRIPT_TASK':
|
|
6209
6208
|
if (arrayableToArray(tools.script).length === 0) {
|
|
6210
|
-
throw new PipelineExecutionError(
|
|
6209
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6211
6210
|
No script execution tools are available
|
|
6212
6211
|
|
|
6213
6212
|
${block(pipelineIdentification)}
|
|
6214
6213
|
`));
|
|
6215
6214
|
}
|
|
6216
6215
|
if (!task.contentLanguage) {
|
|
6217
|
-
throw new PipelineExecutionError(
|
|
6216
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6218
6217
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
6219
6218
|
|
|
6220
6219
|
${block(pipelineIdentification)}
|
|
@@ -6245,7 +6244,7 @@
|
|
|
6245
6244
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
6246
6245
|
}
|
|
6247
6246
|
else {
|
|
6248
|
-
throw new PipelineExecutionError(
|
|
6247
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6249
6248
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
6250
6249
|
|
|
6251
6250
|
${block(pipelineIdentification)}
|
|
@@ -6259,7 +6258,7 @@
|
|
|
6259
6258
|
break taskType;
|
|
6260
6259
|
case 'DIALOG_TASK':
|
|
6261
6260
|
if (tools.userInterface === undefined) {
|
|
6262
|
-
throw new PipelineExecutionError(
|
|
6261
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6263
6262
|
User interface tools are not available
|
|
6264
6263
|
|
|
6265
6264
|
${block(pipelineIdentification)}
|
|
@@ -6277,7 +6276,7 @@
|
|
|
6277
6276
|
break taskType;
|
|
6278
6277
|
// <- case: [🅱]
|
|
6279
6278
|
default:
|
|
6280
|
-
throw new PipelineExecutionError(
|
|
6279
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6281
6280
|
Unknown execution type "${task.taskType}"
|
|
6282
6281
|
|
|
6283
6282
|
${block(pipelineIdentification)}
|
|
@@ -6375,7 +6374,7 @@
|
|
|
6375
6374
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
6376
6375
|
// Note: Create a summary of all failures
|
|
6377
6376
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6378
|
-
.map((failure) =>
|
|
6377
|
+
.map((failure) => spacetrim.spaceTrim((block) => {
|
|
6379
6378
|
var _a, _b;
|
|
6380
6379
|
return `
|
|
6381
6380
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -6385,14 +6384,14 @@
|
|
|
6385
6384
|
Result:
|
|
6386
6385
|
${block(failure.result === null
|
|
6387
6386
|
? 'null'
|
|
6388
|
-
:
|
|
6387
|
+
: spacetrim.spaceTrim(failure.result)
|
|
6389
6388
|
.split(/\r?\n/)
|
|
6390
6389
|
.map((line) => `> ${line}`)
|
|
6391
6390
|
.join('\n'))}
|
|
6392
6391
|
`;
|
|
6393
6392
|
}))
|
|
6394
6393
|
.join('\n\n---\n\n');
|
|
6395
|
-
throw new PipelineExecutionError(
|
|
6394
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => {
|
|
6396
6395
|
var _a;
|
|
6397
6396
|
return `
|
|
6398
6397
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -6412,7 +6411,7 @@
|
|
|
6412
6411
|
}
|
|
6413
6412
|
}
|
|
6414
6413
|
if ($ongoingTaskResult.$resultString === null) {
|
|
6415
|
-
throw new UnexpectedError(
|
|
6414
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
6416
6415
|
Something went wrong and prompt result is null
|
|
6417
6416
|
|
|
6418
6417
|
${block(pipelineIdentification)}
|
|
@@ -6439,7 +6438,7 @@
|
|
|
6439
6438
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6440
6439
|
}
|
|
6441
6440
|
if (jokerParameterNames.length !== 0) {
|
|
6442
|
-
throw new UnexpectedError(
|
|
6441
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
6443
6442
|
JOKER parameters are not supported together with FOREACH command
|
|
6444
6443
|
|
|
6445
6444
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6452,7 +6451,7 @@
|
|
|
6452
6451
|
if (formatDefinition === undefined) {
|
|
6453
6452
|
throw new UnexpectedError(
|
|
6454
6453
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6455
|
-
|
|
6454
|
+
spacetrim.spaceTrim((block) => `
|
|
6456
6455
|
Unsupported format "${task.foreach.formatName}"
|
|
6457
6456
|
|
|
6458
6457
|
Available formats:
|
|
@@ -6469,7 +6468,7 @@
|
|
|
6469
6468
|
if (subvalueParser === undefined) {
|
|
6470
6469
|
throw new UnexpectedError(
|
|
6471
6470
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6472
|
-
|
|
6471
|
+
spacetrim.spaceTrim((block) => `
|
|
6473
6472
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6474
6473
|
|
|
6475
6474
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6509,7 +6508,7 @@
|
|
|
6509
6508
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6510
6509
|
throw error;
|
|
6511
6510
|
}
|
|
6512
|
-
const highLevelError = new PipelineExecutionError(
|
|
6511
|
+
const highLevelError = new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6513
6512
|
${error.message}
|
|
6514
6513
|
|
|
6515
6514
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6533,7 +6532,7 @@
|
|
|
6533
6532
|
...options,
|
|
6534
6533
|
priority: priority + index,
|
|
6535
6534
|
parameters: allSubparameters,
|
|
6536
|
-
pipelineIdentification:
|
|
6535
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
6537
6536
|
${block(pipelineIdentification)}
|
|
6538
6537
|
Subparameter index: ${index}
|
|
6539
6538
|
`),
|
|
@@ -6542,7 +6541,7 @@
|
|
|
6542
6541
|
}
|
|
6543
6542
|
catch (error) {
|
|
6544
6543
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6545
|
-
console.error(
|
|
6544
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
6546
6545
|
${error.message}
|
|
6547
6546
|
|
|
6548
6547
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6718,7 +6717,7 @@
|
|
|
6718
6717
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
6719
6718
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
6720
6719
|
if (reservedParameters[parameterName] === undefined) {
|
|
6721
|
-
throw new UnexpectedError(
|
|
6720
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
6722
6721
|
Reserved parameter {${parameterName}} is not defined
|
|
6723
6722
|
|
|
6724
6723
|
${block(pipelineIdentification)}
|
|
@@ -6744,7 +6743,7 @@
|
|
|
6744
6743
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
6745
6744
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
6746
6745
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
6747
|
-
throw new UnexpectedError(
|
|
6746
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
6748
6747
|
Dependent parameters are not consistent with used parameters:
|
|
6749
6748
|
|
|
6750
6749
|
Dependent parameters:
|
|
@@ -6788,7 +6787,7 @@
|
|
|
6788
6787
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
6789
6788
|
// Houston, we have a problem
|
|
6790
6789
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
6791
|
-
throw new UnexpectedError(
|
|
6790
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
6792
6791
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
6793
6792
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
6794
6793
|
|
|
@@ -6857,7 +6856,7 @@
|
|
|
6857
6856
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
6858
6857
|
if (parametersToPass[parameter.name] === undefined) {
|
|
6859
6858
|
// [4]
|
|
6860
|
-
$warnings.push(new PipelineExecutionError(
|
|
6859
|
+
$warnings.push(new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6861
6860
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
6862
6861
|
|
|
6863
6862
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -6965,7 +6964,7 @@
|
|
|
6965
6964
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
6966
6965
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
6967
6966
|
if (parameter === undefined) {
|
|
6968
|
-
warnings.push(new PipelineExecutionError(
|
|
6967
|
+
warnings.push(new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6969
6968
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
6970
6969
|
|
|
6971
6970
|
${block(pipelineIdentification)}
|
|
@@ -6980,7 +6979,7 @@
|
|
|
6980
6979
|
// TODO: [🧠] This should be also non-critical error
|
|
6981
6980
|
return exportJson({
|
|
6982
6981
|
name: 'pipelineExecutorResult',
|
|
6983
|
-
message:
|
|
6982
|
+
message: spacetrim.spaceTrim((block) => `
|
|
6984
6983
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
6985
6984
|
|
|
6986
6985
|
${block(pipelineIdentification)}
|
|
@@ -6989,7 +6988,7 @@
|
|
|
6989
6988
|
value: {
|
|
6990
6989
|
isSuccessful: false,
|
|
6991
6990
|
errors: [
|
|
6992
|
-
new PipelineExecutionError(
|
|
6991
|
+
new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
6993
6992
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
6994
6993
|
|
|
6995
6994
|
${block(pipelineIdentification)}
|
|
@@ -7016,7 +7015,7 @@
|
|
|
7016
7015
|
while (unresovedTasks.length > 0) {
|
|
7017
7016
|
if (loopLimit-- < 0) {
|
|
7018
7017
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
7019
|
-
throw new UnexpectedError(
|
|
7018
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
7020
7019
|
Loop limit reached during resolving parameters pipeline execution
|
|
7021
7020
|
|
|
7022
7021
|
${block(pipelineIdentification)}
|
|
@@ -7026,7 +7025,7 @@
|
|
|
7026
7025
|
if (!currentTask && resolving.length === 0) {
|
|
7027
7026
|
throw new UnexpectedError(
|
|
7028
7027
|
// TODO: [🐎] DRY
|
|
7029
|
-
|
|
7028
|
+
spacetrim.spaceTrim((block) => `
|
|
7030
7029
|
Can not resolve some parameters:
|
|
7031
7030
|
|
|
7032
7031
|
${block(pipelineIdentification)}
|
|
@@ -7066,7 +7065,7 @@
|
|
|
7066
7065
|
tools,
|
|
7067
7066
|
onProgress(newOngoingResult) {
|
|
7068
7067
|
if (isReturned) {
|
|
7069
|
-
throw new UnexpectedError(
|
|
7068
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
7070
7069
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
7071
7070
|
|
|
7072
7071
|
${block(pipelineIdentification)}
|
|
@@ -7083,7 +7082,7 @@
|
|
|
7083
7082
|
},
|
|
7084
7083
|
logLlmCall,
|
|
7085
7084
|
$executionReport: executionReport,
|
|
7086
|
-
pipelineIdentification:
|
|
7085
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
7087
7086
|
${block(pipelineIdentification)}
|
|
7088
7087
|
Task name: ${currentTask.name}
|
|
7089
7088
|
Task title: ${currentTask.title}
|
|
@@ -7192,7 +7191,7 @@
|
|
|
7192
7191
|
preparedPipeline = pipeline;
|
|
7193
7192
|
}
|
|
7194
7193
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
7195
|
-
console.warn(
|
|
7194
|
+
console.warn(spacetrim.spaceTrim((block) => `
|
|
7196
7195
|
Pipeline is not prepared
|
|
7197
7196
|
|
|
7198
7197
|
${block(pipelineIdentification)}
|
|
@@ -7217,7 +7216,7 @@
|
|
|
7217
7216
|
tools,
|
|
7218
7217
|
onProgress,
|
|
7219
7218
|
logLlmCall,
|
|
7220
|
-
pipelineIdentification:
|
|
7219
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
7221
7220
|
${block(pipelineIdentification)}
|
|
7222
7221
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
7223
7222
|
`),
|
|
@@ -7414,8 +7413,8 @@
|
|
|
7414
7413
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
7415
7414
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
7416
7415
|
let name = `piece-${i}`;
|
|
7417
|
-
let title =
|
|
7418
|
-
const knowledgePieceContent =
|
|
7416
|
+
let title = spacetrim.spaceTrim(knowledgeTextPiece.substring(0, 100));
|
|
7417
|
+
const knowledgePieceContent = spacetrim.spaceTrim(knowledgeTextPiece);
|
|
7419
7418
|
let keywords = [];
|
|
7420
7419
|
const index = [];
|
|
7421
7420
|
/*
|
|
@@ -7428,7 +7427,7 @@
|
|
|
7428
7427
|
isCrashedOnError: true,
|
|
7429
7428
|
});
|
|
7430
7429
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
7431
|
-
title =
|
|
7430
|
+
title = spacetrim.spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
7432
7431
|
name = titleToName(title);
|
|
7433
7432
|
// --- Keywords
|
|
7434
7433
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -7525,7 +7524,7 @@
|
|
|
7525
7524
|
* @public exported from `@promptbook/markdown-utils`
|
|
7526
7525
|
*/
|
|
7527
7526
|
function removeMarkdownComments(content) {
|
|
7528
|
-
return
|
|
7527
|
+
return spacetrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
7529
7528
|
}
|
|
7530
7529
|
|
|
7531
7530
|
/**
|
|
@@ -7538,7 +7537,7 @@
|
|
|
7538
7537
|
const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
|
|
7539
7538
|
const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
|
|
7540
7539
|
const sectionMatch = content.match(sectionRegex);
|
|
7541
|
-
const contentToInsert =
|
|
7540
|
+
const contentToInsert = spacetrim.spaceTrim((block) => `
|
|
7542
7541
|
<!--${sectionName}-->
|
|
7543
7542
|
${block(warningLine)}
|
|
7544
7543
|
${block(sectionContent)}
|
|
@@ -7551,7 +7550,7 @@
|
|
|
7551
7550
|
const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
|
|
7552
7551
|
if (placeForSection !== null) {
|
|
7553
7552
|
const [heading] = placeForSection;
|
|
7554
|
-
return content.replace(heading,
|
|
7553
|
+
return content.replace(heading, spacetrim.spaceTrim((block) => `
|
|
7555
7554
|
${block(contentToInsert)}
|
|
7556
7555
|
|
|
7557
7556
|
${block(heading)}
|
|
@@ -7560,7 +7559,7 @@
|
|
|
7560
7559
|
console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
|
|
7561
7560
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7562
7561
|
// <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
|
|
7563
|
-
return
|
|
7562
|
+
return spacetrim.spaceTrim((block) => `
|
|
7564
7563
|
${block(content)}
|
|
7565
7564
|
|
|
7566
7565
|
${block(contentToInsert)}
|
|
@@ -7681,7 +7680,7 @@
|
|
|
7681
7680
|
}
|
|
7682
7681
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
7683
7682
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
7684
|
-
const content =
|
|
7683
|
+
const content = spacetrim.spaceTrim(lines.slice(1).join('\n'));
|
|
7685
7684
|
if (level < 1 || level > 6) {
|
|
7686
7685
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
7687
7686
|
}
|
|
@@ -7709,7 +7708,7 @@
|
|
|
7709
7708
|
if (buffer.length === 0) {
|
|
7710
7709
|
return;
|
|
7711
7710
|
}
|
|
7712
|
-
let section =
|
|
7711
|
+
let section = spacetrim.spaceTrim(buffer.join('\n'));
|
|
7713
7712
|
if (section === '') {
|
|
7714
7713
|
return;
|
|
7715
7714
|
}
|
|
@@ -7784,7 +7783,7 @@
|
|
|
7784
7783
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
7785
7784
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
7786
7785
|
}
|
|
7787
|
-
return
|
|
7786
|
+
return spacetrim.spaceTrim(flattenedMarkdown);
|
|
7788
7787
|
}
|
|
7789
7788
|
/**
|
|
7790
7789
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -7984,13 +7983,13 @@
|
|
|
7984
7983
|
* @public exported from `@promptbook/markdown-utils`
|
|
7985
7984
|
*/
|
|
7986
7985
|
function trimCodeBlock(value) {
|
|
7987
|
-
value =
|
|
7986
|
+
value = spacetrim.spaceTrim(value);
|
|
7988
7987
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
7989
7988
|
return value;
|
|
7990
7989
|
}
|
|
7991
7990
|
value = value.replace(/^```[a-z]*/i, '');
|
|
7992
7991
|
value = value.replace(/```$/i, '');
|
|
7993
|
-
value =
|
|
7992
|
+
value = spacetrim.spaceTrim(value);
|
|
7994
7993
|
return value;
|
|
7995
7994
|
}
|
|
7996
7995
|
|
|
@@ -8003,9 +8002,9 @@
|
|
|
8003
8002
|
* @public exported from `@promptbook/markdown-utils`
|
|
8004
8003
|
*/
|
|
8005
8004
|
function trimEndOfCodeBlock(value) {
|
|
8006
|
-
value =
|
|
8005
|
+
value = spacetrim.spaceTrim(value);
|
|
8007
8006
|
value = value.replace(/```$/g, '');
|
|
8008
|
-
value =
|
|
8007
|
+
value = spacetrim.spaceTrim(value);
|
|
8009
8008
|
return value;
|
|
8010
8009
|
}
|
|
8011
8010
|
|