@promptbook/cli 0.88.0-9 → 0.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -18
- package/esm/index.es.js +53 -24
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +5 -0
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +5 -0
- package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -0
- package/package.json +1 -1
- package/umd/index.umd.js +56 -27
- package/umd/index.umd.js.map +1 -1
|
@@ -162,7 +162,7 @@ export declare const DEFAULT_MAX_PARALLEL_COUNT = 5;
|
|
|
162
162
|
*
|
|
163
163
|
* @public exported from `@promptbook/core`
|
|
164
164
|
*/
|
|
165
|
-
export declare const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
165
|
+
export declare const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10;
|
|
166
166
|
/**
|
|
167
167
|
* @@@
|
|
168
168
|
* TODO: [🐝][main] !!3 Use
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { task_id } from '../types/typeAliases';
|
|
1
2
|
/**
|
|
2
3
|
* This error indicates errors during the execution of the pipeline
|
|
3
4
|
*
|
|
@@ -5,5 +6,9 @@
|
|
|
5
6
|
*/
|
|
6
7
|
export declare class PipelineExecutionError extends Error {
|
|
7
8
|
readonly name = "PipelineExecutionError";
|
|
9
|
+
readonly id?: task_id;
|
|
8
10
|
constructor(message: string);
|
|
9
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* TODO: !!!!!! Add id to all errors
|
|
14
|
+
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { task_id } from '../../types/typeAliases';
|
|
1
2
|
import type { ALL_ERRORS } from '../0-index';
|
|
2
3
|
/**
|
|
3
4
|
* Represents a serialized error or custom Promptbook error
|
|
@@ -5,6 +6,10 @@ import type { ALL_ERRORS } from '../0-index';
|
|
|
5
6
|
* Note: [🚉] This is fully serializable as JSON
|
|
6
7
|
*/
|
|
7
8
|
export type ErrorJson = {
|
|
9
|
+
/**
|
|
10
|
+
* The unique identifier of the error
|
|
11
|
+
*/
|
|
12
|
+
readonly id?: task_id;
|
|
8
13
|
/**
|
|
9
14
|
* The type of the error
|
|
10
15
|
*/
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countCharacters(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
|
@@ -7,3 +7,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
9
|
export declare function countLines(text: string): ExpectationAmount;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
12
|
+
*/
|
|
@@ -7,3 +7,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
9
|
export declare function countPages(text: string): ExpectationAmount;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
12
|
+
*/
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countParagraphs(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
|
@@ -11,3 +11,6 @@ export declare function splitIntoSentences(text: string): ReadonlyArray<string>;
|
|
|
11
11
|
* @public exported from `@promptbook/utils`
|
|
12
12
|
*/
|
|
13
13
|
export declare function countSentences(text: string): ExpectationAmount;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
16
|
+
*/
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countWords(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('waitasecond'), require('path'), require('fs/promises'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('dotenv'), require('child_process'), require('jszip'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'path', 'fs/promises', 'crypto-js/enc-hex', 'crypto-js/sha256', 'dotenv', 'child_process', 'jszip', 'prettier', 'prettier/parser-html', 'rxjs', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.path, global.promises, global.hexEncoder, global.sha256, global.dotenv, global.child_process, global.JSZip, global.prettier, global.parserHtml, global.rxjs, global.
|
|
5
|
-
})(this, (function (exports, colors, commander, spaceTrim, waitasecond, path, promises, hexEncoder, sha256, dotenv, child_process, JSZip, prettier, parserHtml, rxjs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('waitasecond'), require('path'), require('fs/promises'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto'), require('dotenv'), require('child_process'), require('jszip'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('papaparse'), require('crypto-js'), require('mime-types'), require('glob-promise'), require('prompts'), require('moment'), require('express'), require('http'), require('socket.io'), require('socket.io-client'), require('@anthropic-ai/sdk'), require('@azure/openai'), require('openai'), require('@mozilla/readability'), require('jsdom'), require('showdown')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'path', 'fs/promises', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto', 'dotenv', 'child_process', 'jszip', 'prettier', 'prettier/parser-html', 'rxjs', 'papaparse', 'crypto-js', 'mime-types', 'glob-promise', 'prompts', 'moment', 'express', 'http', 'socket.io', 'socket.io-client', '@anthropic-ai/sdk', '@azure/openai', 'openai', '@mozilla/readability', 'jsdom', 'showdown'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.path, global.promises, global.hexEncoder, global.sha256, global.crypto, global.dotenv, global.child_process, global.JSZip, global.prettier, global.parserHtml, global.rxjs, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.prompts, global.moment, global.express, global.http, global.socket_io, global.socket_ioClient, global.Anthropic, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
|
|
5
|
+
})(this, (function (exports, colors, commander, spaceTrim, waitasecond, path, promises, hexEncoder, sha256, crypto, dotenv, child_process, JSZip, prettier, parserHtml, rxjs, papaparse, cryptoJs, mimeTypes, glob, prompts, moment, express, http, socket_io, socket_ioClient, Anthropic, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
* @generated
|
|
55
55
|
* @see https://github.com/webgptorg/promptbook
|
|
56
56
|
*/
|
|
57
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0
|
|
57
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0';
|
|
58
58
|
/**
|
|
59
59
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
60
60
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
*
|
|
215
215
|
* @public exported from `@promptbook/core`
|
|
216
216
|
*/
|
|
217
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
217
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [🤹♂️]
|
|
218
218
|
/**
|
|
219
219
|
* Where to store your books
|
|
220
220
|
* This is kind of a "src" for your books
|
|
@@ -1508,6 +1508,21 @@
|
|
|
1508
1508
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1509
1509
|
*/
|
|
1510
1510
|
|
|
1511
|
+
/**
|
|
1512
|
+
* Generates random token
|
|
1513
|
+
*
|
|
1514
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
1515
|
+
*
|
|
1516
|
+
* @private internal helper function
|
|
1517
|
+
* @returns secure random token
|
|
1518
|
+
*/
|
|
1519
|
+
function $randomToken(randomness) {
|
|
1520
|
+
return crypto.randomBytes(randomness).toString('hex');
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1524
|
+
*/
|
|
1525
|
+
|
|
1511
1526
|
/**
|
|
1512
1527
|
* This error indicates errors during the execution of the pipeline
|
|
1513
1528
|
*
|
|
@@ -1515,11 +1530,17 @@
|
|
|
1515
1530
|
*/
|
|
1516
1531
|
class PipelineExecutionError extends Error {
|
|
1517
1532
|
constructor(message) {
|
|
1533
|
+
// Added id parameter
|
|
1518
1534
|
super(message);
|
|
1519
1535
|
this.name = 'PipelineExecutionError';
|
|
1536
|
+
// TODO: [🐙] DRY - Maybe $randomId
|
|
1537
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
1520
1538
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
1521
1539
|
}
|
|
1522
1540
|
}
|
|
1541
|
+
/**
|
|
1542
|
+
* TODO: !!!!!! Add id to all errors
|
|
1543
|
+
*/
|
|
1523
1544
|
|
|
1524
1545
|
/**
|
|
1525
1546
|
* Stores data in memory (HEAP)
|
|
@@ -4083,21 +4104,6 @@
|
|
|
4083
4104
|
* - [♨] Are tasks prepared
|
|
4084
4105
|
*/
|
|
4085
4106
|
|
|
4086
|
-
/**
|
|
4087
|
-
* Generates random token
|
|
4088
|
-
*
|
|
4089
|
-
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
4090
|
-
*
|
|
4091
|
-
* @private internal helper function
|
|
4092
|
-
* @returns secure random token
|
|
4093
|
-
*/
|
|
4094
|
-
function $randomToken(randomness) {
|
|
4095
|
-
return crypto.randomBytes(randomness).toString('hex');
|
|
4096
|
-
}
|
|
4097
|
-
/**
|
|
4098
|
-
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
4099
|
-
*/
|
|
4100
|
-
|
|
4101
4107
|
/**
|
|
4102
4108
|
* Recursively converts JSON strings to JSON objects
|
|
4103
4109
|
|
|
@@ -4278,7 +4284,7 @@
|
|
|
4278
4284
|
* @public exported from `@promptbook/utils`
|
|
4279
4285
|
*/
|
|
4280
4286
|
function deserializeError(error) {
|
|
4281
|
-
const { name, stack } = error;
|
|
4287
|
+
const { name, stack, id } = error; // Added id
|
|
4282
4288
|
let { message } = error;
|
|
4283
4289
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
4284
4290
|
if (ErrorClass === undefined) {
|
|
@@ -4293,7 +4299,9 @@
|
|
|
4293
4299
|
${block(stack || '')}
|
|
4294
4300
|
`);
|
|
4295
4301
|
}
|
|
4296
|
-
|
|
4302
|
+
const deserializedError = new ErrorClass(message);
|
|
4303
|
+
deserializedError.id = id; // Assign id to the error object
|
|
4304
|
+
return deserializedError;
|
|
4297
4305
|
}
|
|
4298
4306
|
|
|
4299
4307
|
/**
|
|
@@ -4343,6 +4351,7 @@
|
|
|
4343
4351
|
*/
|
|
4344
4352
|
function createTask(options) {
|
|
4345
4353
|
const { taskType, taskProcessCallback } = options;
|
|
4354
|
+
// TODO: [🐙] DRY
|
|
4346
4355
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
4347
4356
|
let status = 'RUNNING';
|
|
4348
4357
|
const createdAt = new Date();
|
|
@@ -4375,7 +4384,7 @@
|
|
|
4375
4384
|
assertsTaskSuccessful(executionResult);
|
|
4376
4385
|
status = 'FINISHED';
|
|
4377
4386
|
currentValue = jsonStringsToJsons(executionResult);
|
|
4378
|
-
// <- TODO:
|
|
4387
|
+
// <- TODO: [🧠] Is this a good idea to convert JSON strins to JSONs?
|
|
4379
4388
|
partialResultSubject.next(executionResult);
|
|
4380
4389
|
}
|
|
4381
4390
|
catch (error) {
|
|
@@ -4439,19 +4448,21 @@
|
|
|
4439
4448
|
*/
|
|
4440
4449
|
function serializeError(error) {
|
|
4441
4450
|
const { name, message, stack } = error;
|
|
4451
|
+
const { id } = error;
|
|
4442
4452
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
4443
4453
|
console.error(spaceTrim__default["default"]((block) => `
|
|
4444
|
-
|
|
4454
|
+
|
|
4445
4455
|
Cannot serialize error with name "${name}"
|
|
4446
4456
|
|
|
4447
4457
|
${block(stack || message)}
|
|
4448
|
-
|
|
4458
|
+
|
|
4449
4459
|
`));
|
|
4450
4460
|
}
|
|
4451
4461
|
return {
|
|
4452
4462
|
name: name,
|
|
4453
4463
|
message,
|
|
4454
4464
|
stack,
|
|
4465
|
+
id, // Include id in the serialized object
|
|
4455
4466
|
};
|
|
4456
4467
|
}
|
|
4457
4468
|
|
|
@@ -5184,6 +5195,9 @@
|
|
|
5184
5195
|
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
5185
5196
|
return text.length;
|
|
5186
5197
|
}
|
|
5198
|
+
/**
|
|
5199
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5200
|
+
*/
|
|
5187
5201
|
|
|
5188
5202
|
/**
|
|
5189
5203
|
* Number of characters per standard line with 11pt Arial font size.
|
|
@@ -5215,6 +5229,9 @@
|
|
|
5215
5229
|
const lines = text.split('\n');
|
|
5216
5230
|
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
5217
5231
|
}
|
|
5232
|
+
/**
|
|
5233
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5234
|
+
*/
|
|
5218
5235
|
|
|
5219
5236
|
/**
|
|
5220
5237
|
* Counts number of pages in the text
|
|
@@ -5226,6 +5243,9 @@
|
|
|
5226
5243
|
function countPages(text) {
|
|
5227
5244
|
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
5228
5245
|
}
|
|
5246
|
+
/**
|
|
5247
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5248
|
+
*/
|
|
5229
5249
|
|
|
5230
5250
|
/**
|
|
5231
5251
|
* Counts number of paragraphs in the text
|
|
@@ -5235,6 +5255,9 @@
|
|
|
5235
5255
|
function countParagraphs(text) {
|
|
5236
5256
|
return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
|
|
5237
5257
|
}
|
|
5258
|
+
/**
|
|
5259
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5260
|
+
*/
|
|
5238
5261
|
|
|
5239
5262
|
/**
|
|
5240
5263
|
* Split text into sentences
|
|
@@ -5252,6 +5275,9 @@
|
|
|
5252
5275
|
function countSentences(text) {
|
|
5253
5276
|
return splitIntoSentences(text).length;
|
|
5254
5277
|
}
|
|
5278
|
+
/**
|
|
5279
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5280
|
+
*/
|
|
5255
5281
|
|
|
5256
5282
|
/**
|
|
5257
5283
|
* Counts number of words in the text
|
|
@@ -5265,6 +5291,9 @@
|
|
|
5265
5291
|
text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
5266
5292
|
return text.split(/[^a-zа-я0-9]+/i).filter((word) => word.length > 0).length;
|
|
5267
5293
|
}
|
|
5294
|
+
/**
|
|
5295
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5296
|
+
*/
|
|
5268
5297
|
|
|
5269
5298
|
/**
|
|
5270
5299
|
* Index of all counter functions
|
|
@@ -12351,7 +12380,7 @@
|
|
|
12351
12380
|
pipeline,
|
|
12352
12381
|
tools,
|
|
12353
12382
|
isNotPreparedWarningSupressed: true,
|
|
12354
|
-
maxExecutionAttempts:
|
|
12383
|
+
maxExecutionAttempts: DEFAULT_MAX_EXECUTION_ATTEMPTS,
|
|
12355
12384
|
// <- TODO: Why "LLM execution failed undefinedx"
|
|
12356
12385
|
maxParallelCount: 1, // <- TODO: Pass CLI argument
|
|
12357
12386
|
});
|