@promptbook/node 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 +36 -7
- 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 +2 -2
- package/umd/index.umd.js +36 -7
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.88.0
|
|
3
|
+
"version": "0.88.0",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.88.0
|
|
50
|
+
"@promptbook/core": "0.88.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0';
|
|
50
50
|
/**
|
|
51
51
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
52
52
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
*
|
|
174
174
|
* @public exported from `@promptbook/core`
|
|
175
175
|
*/
|
|
176
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
176
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐คนโโ๏ธ]
|
|
177
177
|
// <- TODO: [๐] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
178
178
|
/**
|
|
179
179
|
* Where to store the temporary downloads
|
|
@@ -1658,11 +1658,17 @@
|
|
|
1658
1658
|
*/
|
|
1659
1659
|
class PipelineExecutionError extends Error {
|
|
1660
1660
|
constructor(message) {
|
|
1661
|
+
// Added id parameter
|
|
1661
1662
|
super(message);
|
|
1662
1663
|
this.name = 'PipelineExecutionError';
|
|
1664
|
+
// TODO: [๐] DRY - Maybe $randomId
|
|
1665
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
1663
1666
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
1664
1667
|
}
|
|
1665
1668
|
}
|
|
1669
|
+
/**
|
|
1670
|
+
* TODO: !!!!!! Add id to all errors
|
|
1671
|
+
*/
|
|
1666
1672
|
|
|
1667
1673
|
/**
|
|
1668
1674
|
* This error indicates problems parsing the format value
|
|
@@ -1850,7 +1856,7 @@
|
|
|
1850
1856
|
* @public exported from `@promptbook/utils`
|
|
1851
1857
|
*/
|
|
1852
1858
|
function deserializeError(error) {
|
|
1853
|
-
const { name, stack } = error;
|
|
1859
|
+
const { name, stack, id } = error; // Added id
|
|
1854
1860
|
let { message } = error;
|
|
1855
1861
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
1856
1862
|
if (ErrorClass === undefined) {
|
|
@@ -1865,7 +1871,9 @@
|
|
|
1865
1871
|
${block(stack || '')}
|
|
1866
1872
|
`);
|
|
1867
1873
|
}
|
|
1868
|
-
|
|
1874
|
+
const deserializedError = new ErrorClass(message);
|
|
1875
|
+
deserializedError.id = id; // Assign id to the error object
|
|
1876
|
+
return deserializedError;
|
|
1869
1877
|
}
|
|
1870
1878
|
|
|
1871
1879
|
/**
|
|
@@ -1915,6 +1923,7 @@
|
|
|
1915
1923
|
*/
|
|
1916
1924
|
function createTask(options) {
|
|
1917
1925
|
const { taskType, taskProcessCallback } = options;
|
|
1926
|
+
// TODO: [๐] DRY
|
|
1918
1927
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
1919
1928
|
let status = 'RUNNING';
|
|
1920
1929
|
const createdAt = new Date();
|
|
@@ -1947,7 +1956,7 @@
|
|
|
1947
1956
|
assertsTaskSuccessful(executionResult);
|
|
1948
1957
|
status = 'FINISHED';
|
|
1949
1958
|
currentValue = jsonStringsToJsons(executionResult);
|
|
1950
|
-
// <- TODO:
|
|
1959
|
+
// <- TODO: [๐ง ] Is this a good idea to convert JSON strins to JSONs?
|
|
1951
1960
|
partialResultSubject.next(executionResult);
|
|
1952
1961
|
}
|
|
1953
1962
|
catch (error) {
|
|
@@ -2011,19 +2020,21 @@
|
|
|
2011
2020
|
*/
|
|
2012
2021
|
function serializeError(error) {
|
|
2013
2022
|
const { name, message, stack } = error;
|
|
2023
|
+
const { id } = error;
|
|
2014
2024
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2015
2025
|
console.error(spaceTrim__default["default"]((block) => `
|
|
2016
|
-
|
|
2026
|
+
|
|
2017
2027
|
Cannot serialize error with name "${name}"
|
|
2018
2028
|
|
|
2019
2029
|
${block(stack || message)}
|
|
2020
|
-
|
|
2030
|
+
|
|
2021
2031
|
`));
|
|
2022
2032
|
}
|
|
2023
2033
|
return {
|
|
2024
2034
|
name: name,
|
|
2025
2035
|
message,
|
|
2026
2036
|
stack,
|
|
2037
|
+
id, // Include id in the serialized object
|
|
2027
2038
|
};
|
|
2028
2039
|
}
|
|
2029
2040
|
|
|
@@ -3066,6 +3077,9 @@
|
|
|
3066
3077
|
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
3067
3078
|
return text.length;
|
|
3068
3079
|
}
|
|
3080
|
+
/**
|
|
3081
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3082
|
+
*/
|
|
3069
3083
|
|
|
3070
3084
|
/**
|
|
3071
3085
|
* Number of characters per standard line with 11pt Arial font size.
|
|
@@ -3097,6 +3111,9 @@
|
|
|
3097
3111
|
const lines = text.split('\n');
|
|
3098
3112
|
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
3099
3113
|
}
|
|
3114
|
+
/**
|
|
3115
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3116
|
+
*/
|
|
3100
3117
|
|
|
3101
3118
|
/**
|
|
3102
3119
|
* Counts number of pages in the text
|
|
@@ -3108,6 +3125,9 @@
|
|
|
3108
3125
|
function countPages(text) {
|
|
3109
3126
|
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
3110
3127
|
}
|
|
3128
|
+
/**
|
|
3129
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3130
|
+
*/
|
|
3111
3131
|
|
|
3112
3132
|
/**
|
|
3113
3133
|
* Counts number of paragraphs in the text
|
|
@@ -3117,6 +3137,9 @@
|
|
|
3117
3137
|
function countParagraphs(text) {
|
|
3118
3138
|
return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
|
|
3119
3139
|
}
|
|
3140
|
+
/**
|
|
3141
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3142
|
+
*/
|
|
3120
3143
|
|
|
3121
3144
|
/**
|
|
3122
3145
|
* Split text into sentences
|
|
@@ -3134,6 +3157,9 @@
|
|
|
3134
3157
|
function countSentences(text) {
|
|
3135
3158
|
return splitIntoSentences(text).length;
|
|
3136
3159
|
}
|
|
3160
|
+
/**
|
|
3161
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3162
|
+
*/
|
|
3137
3163
|
|
|
3138
3164
|
const defaultDiacriticsRemovalMap = [
|
|
3139
3165
|
{
|
|
@@ -3408,6 +3434,9 @@
|
|
|
3408
3434
|
text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
3409
3435
|
return text.split(/[^a-zะฐ-ั0-9]+/i).filter((word) => word.length > 0).length;
|
|
3410
3436
|
}
|
|
3437
|
+
/**
|
|
3438
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3439
|
+
*/
|
|
3411
3440
|
|
|
3412
3441
|
/**
|
|
3413
3442
|
* Index of all counter functions
|