@promptbook/remote-server 0.77.1 → 0.78.2
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 +43 -198
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +10 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -8
- package/esm/typings/src/commands/_common/types/CommandType.d.ts +17 -0
- package/esm/typings/src/config.d.ts +14 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +1 -1
- package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/removePipelineCommand.d.ts +22 -0
- package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts} +3 -3
- package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +6 -0
- package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
- package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +43 -198
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/conversion/utils/{extractVariables.test.d.ts → extractVariablesFromScript.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{renameParameter.test.d.ts → removePipelineCommand.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{titleToName.test.d.ts → renamePipelineParameter.test.d.ts} +0 -0
- /package/esm/typings/src/{conversion/utils → utils/normalization}/titleToName.d.ts +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Command } from './Command';
|
|
2
|
+
/**
|
|
3
|
+
* Command is one piece of the book file section which adds some logic to the task or the whole pipeline.
|
|
4
|
+
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
5
|
+
*
|
|
6
|
+
* This is a type of the command like "KNOWLEDGE" or "PERSONA"
|
|
7
|
+
*/
|
|
8
|
+
export type CommandType = Command['type'];
|
|
9
|
+
/**
|
|
10
|
+
* Command is one piece of the book file section which adds some logic to the task or the whole pipeline.
|
|
11
|
+
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
12
|
+
*
|
|
13
|
+
* This is a type of the command like "KNOWLEDGE" or "PERSONA"
|
|
14
|
+
*
|
|
15
|
+
export type CommandTypeOrAlias = Command['type'] | Command['aliasNames'] | Command['deprecatedNames'];
|
|
16
|
+
// <- TODO: [🧘] Implement
|
|
17
|
+
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CsvSettings } from './formats/csv/CsvSettings';
|
|
2
2
|
import type { IntermediateFilesStrategy } from './types/IntermediateFilesStrategy';
|
|
3
|
+
import type { string_email } from './types/typeAliases';
|
|
4
|
+
import type { string_name } from './types/typeAliases';
|
|
3
5
|
import type { string_url_image } from './types/typeAliases';
|
|
4
6
|
/**
|
|
5
7
|
* Warning message for the generated sections and files files
|
|
@@ -15,6 +17,18 @@ export declare const GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has be
|
|
|
15
17
|
* @public exported from `@promptbook/core`
|
|
16
18
|
*/
|
|
17
19
|
export declare const NAME = "Promptbook";
|
|
20
|
+
/**
|
|
21
|
+
* Email of the responsible person
|
|
22
|
+
*
|
|
23
|
+
* @public exported from `@promptbook/core`
|
|
24
|
+
*/
|
|
25
|
+
export declare const ADMIN_EMAIL: string_email;
|
|
26
|
+
/**
|
|
27
|
+
* Name of the responsible person for the Promptbook on GitHub
|
|
28
|
+
*
|
|
29
|
+
* @public exported from `@promptbook/core`
|
|
30
|
+
*/
|
|
31
|
+
export declare const ADMIN_GITHUB_NAME: string_name;
|
|
18
32
|
/**
|
|
19
33
|
* Claim for the Promptbook
|
|
20
34
|
*
|
|
@@ -7,7 +7,7 @@ import type { string_parameter_name } from '../../types/typeAliases';
|
|
|
7
7
|
* @param task the task with used parameters
|
|
8
8
|
* @returns the set of parameter names
|
|
9
9
|
* @throws {ParseError} if the script is invalid
|
|
10
|
-
* @public exported from `@promptbook/
|
|
10
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
11
11
|
*/
|
|
12
12
|
export declare function extractParameterNamesFromTask(task: ReadonlyDeep<Pick<TaskJson, 'title' | 'description' | 'taskType' | 'content' | 'preparedContent' | 'jokerParameterNames' | 'foreach'>>): Set<string_parameter_name>;
|
|
13
13
|
/**
|
package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts}
RENAMED
|
@@ -6,9 +6,9 @@ import type { string_javascript_name } from '../../types/typeAliases';
|
|
|
6
6
|
* @param script from which to extract the variables
|
|
7
7
|
* @returns the list of variable names
|
|
8
8
|
* @throws {ParseError} if the script is invalid
|
|
9
|
-
* @public exported from `@promptbook/utils`
|
|
9
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function extractVariablesFromScript(script: string_javascript): Set<string_javascript_name>;
|
|
12
12
|
/**
|
|
13
13
|
* TODO: [🔣] Support for multiple languages - python, java,...
|
|
14
14
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CommandType } from '../../commands/_common/types/CommandType';
|
|
2
|
+
import type { PipelineString } from '../../pipeline/PipelineString';
|
|
3
|
+
/**
|
|
4
|
+
* Options for `removePipelineCommand`
|
|
5
|
+
*/
|
|
6
|
+
type RemovePipelineCommandOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The command you want to remove
|
|
9
|
+
*/
|
|
10
|
+
command: CommandType;
|
|
11
|
+
/**
|
|
12
|
+
* Pipeline you want to remove command from
|
|
13
|
+
*/
|
|
14
|
+
pipeline: PipelineString;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Function `removePipelineCommand` will remove one command from pipeline string
|
|
18
|
+
*
|
|
19
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
20
|
+
*/
|
|
21
|
+
export declare function removePipelineCommand(options: RemovePipelineCommandOptions): PipelineString;
|
|
22
|
+
export {};
|
package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts}
RENAMED
|
@@ -16,11 +16,11 @@ type RenameParameterOptions = {
|
|
|
16
16
|
readonly newParameterName: string_name;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Function `
|
|
19
|
+
* Function `renamePipelineParameter` will find all usable parameters for given task
|
|
20
20
|
* In other words, it will find all parameters that are not used in the task itseld and all its dependencies
|
|
21
21
|
*
|
|
22
22
|
* @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
|
|
23
|
-
* @public exported from `@promptbook/
|
|
23
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
24
24
|
*/
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function renamePipelineParameter(options: RenameParameterOptions): PipelineJson;
|
|
26
26
|
export {};
|
|
@@ -24,7 +24,7 @@ export declare const OPENAI_MODELS: ReadonlyArray<AvailableModel & {
|
|
|
24
24
|
* @see https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4
|
|
25
25
|
* @see https://openai.com/api/pricing/
|
|
26
26
|
* @see /other/playground/playground.ts
|
|
27
|
-
* TODO: [🍓] Make better
|
|
27
|
+
* TODO: [🍓][💩] Make better
|
|
28
28
|
* TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
|
|
29
29
|
* TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -8,5 +8,5 @@ export type PipelineString = string & {
|
|
|
8
8
|
readonly _type: 'Promptbook';
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* TODO:
|
|
11
|
+
* TODO: [💩] Better validation (validatePipelineString) or remove branded type and make it just string
|
|
12
12
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.2",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"--note-0": " <- [🐊]",
|
|
6
6
|
"private": false,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
55
55
|
"typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@promptbook/core": "0.
|
|
57
|
+
"@promptbook/core": "0.78.2"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.78.1';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -168,214 +168,25 @@
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
174
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
171
|
+
* Name for the Promptbook
|
|
175
172
|
*
|
|
176
|
-
*
|
|
177
|
-
* @public exported from `@promptbook/utils`
|
|
178
|
-
*/
|
|
179
|
-
function $deepFreeze(objectValue) {
|
|
180
|
-
var e_1, _a;
|
|
181
|
-
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
182
|
-
try {
|
|
183
|
-
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
184
|
-
var propertyName = propertyNames_1_1.value;
|
|
185
|
-
var value = objectValue[propertyName];
|
|
186
|
-
if (value && typeof value === 'object') {
|
|
187
|
-
$deepFreeze(value);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
192
|
-
finally {
|
|
193
|
-
try {
|
|
194
|
-
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
195
|
-
}
|
|
196
|
-
finally { if (e_1) throw e_1.error; }
|
|
197
|
-
}
|
|
198
|
-
return Object.freeze(objectValue);
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
173
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
206
174
|
*
|
|
207
175
|
* @public exported from `@promptbook/core`
|
|
208
176
|
*/
|
|
209
|
-
var
|
|
210
|
-
__extends(UnexpectedError, _super);
|
|
211
|
-
function UnexpectedError(message) {
|
|
212
|
-
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
213
|
-
_this.name = 'UnexpectedError';
|
|
214
|
-
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
215
|
-
return _this;
|
|
216
|
-
}
|
|
217
|
-
return UnexpectedError;
|
|
218
|
-
}(Error));
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Checks if the value is [🚉] serializable as JSON
|
|
222
|
-
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
223
|
-
*
|
|
224
|
-
* - Almost all primitives are serializable BUT:
|
|
225
|
-
* - `undefined` is not serializable
|
|
226
|
-
* - `NaN` is not serializable
|
|
227
|
-
* - Objects and arrays are serializable if all their properties are serializable
|
|
228
|
-
* - Functions are not serializable
|
|
229
|
-
* - Circular references are not serializable
|
|
230
|
-
* - `Date` objects are not serializable
|
|
231
|
-
* - `Map` and `Set` objects are not serializable
|
|
232
|
-
* - `RegExp` objects are not serializable
|
|
233
|
-
* - `Error` objects are not serializable
|
|
234
|
-
* - `Symbol` objects are not serializable
|
|
235
|
-
* - And much more...
|
|
236
|
-
*
|
|
237
|
-
* @throws UnexpectedError if the value is not serializable as JSON
|
|
238
|
-
* @public exported from `@promptbook/utils`
|
|
239
|
-
*/
|
|
240
|
-
function checkSerializableAsJson(name, value) {
|
|
241
|
-
var e_1, _a;
|
|
242
|
-
if (value === undefined) {
|
|
243
|
-
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
244
|
-
}
|
|
245
|
-
else if (value === null) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
else if (typeof value === 'boolean') {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
else if (typeof value === 'number' && !isNaN(value)) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
else if (typeof value === 'string') {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
else if (typeof value === 'symbol') {
|
|
258
|
-
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
259
|
-
}
|
|
260
|
-
else if (typeof value === 'function') {
|
|
261
|
-
throw new UnexpectedError("".concat(name, " is function"));
|
|
262
|
-
}
|
|
263
|
-
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
264
|
-
for (var i = 0; i < value.length; i++) {
|
|
265
|
-
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
else if (typeof value === 'object') {
|
|
269
|
-
if (value instanceof Date) {
|
|
270
|
-
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
271
|
-
}
|
|
272
|
-
else if (value instanceof Map) {
|
|
273
|
-
throw new UnexpectedError("".concat(name, " is Map"));
|
|
274
|
-
}
|
|
275
|
-
else if (value instanceof Set) {
|
|
276
|
-
throw new UnexpectedError("".concat(name, " is Set"));
|
|
277
|
-
}
|
|
278
|
-
else if (value instanceof RegExp) {
|
|
279
|
-
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
280
|
-
}
|
|
281
|
-
else if (value instanceof Error) {
|
|
282
|
-
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
try {
|
|
286
|
-
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
287
|
-
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
288
|
-
if (subValue === undefined) {
|
|
289
|
-
// Note: undefined in object is serializable - it is just omited
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
296
|
-
finally {
|
|
297
|
-
try {
|
|
298
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
299
|
-
}
|
|
300
|
-
finally { if (e_1) throw e_1.error; }
|
|
301
|
-
}
|
|
302
|
-
try {
|
|
303
|
-
JSON.stringify(value); // <- TODO: [0]
|
|
304
|
-
}
|
|
305
|
-
catch (error) {
|
|
306
|
-
if (!(error instanceof Error)) {
|
|
307
|
-
throw error;
|
|
308
|
-
}
|
|
309
|
-
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
310
|
-
}
|
|
311
|
-
/*
|
|
312
|
-
TODO: [0] Is there some more elegant way to check circular references?
|
|
313
|
-
const seen = new Set();
|
|
314
|
-
const stack = [{ value }];
|
|
315
|
-
while (stack.length > 0) {
|
|
316
|
-
const { value } = stack.pop()!;
|
|
317
|
-
if (typeof value === 'object' && value !== null) {
|
|
318
|
-
if (seen.has(value)) {
|
|
319
|
-
throw new UnexpectedError(`${name} has circular reference`);
|
|
320
|
-
}
|
|
321
|
-
seen.add(value);
|
|
322
|
-
if (Array.isArray(value)) {
|
|
323
|
-
stack.push(...value.map((value) => ({ value })));
|
|
324
|
-
} else {
|
|
325
|
-
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
*/
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
339
|
-
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
340
|
-
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
341
|
-
*/
|
|
342
|
-
|
|
177
|
+
var NAME = "Promptbook";
|
|
343
178
|
/**
|
|
344
|
-
*
|
|
345
|
-
* @@@
|
|
346
|
-
*
|
|
347
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
179
|
+
* Email of the responsible person
|
|
348
180
|
*
|
|
349
|
-
* @
|
|
350
|
-
* @param objectValue - Object to be deeply frozen
|
|
351
|
-
* @returns The same object as the input, but deeply frozen
|
|
352
|
-
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
353
|
-
*/
|
|
354
|
-
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
355
|
-
checkSerializableAsJson(name, objectValue);
|
|
356
|
-
return $deepFreeze(objectValue);
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
360
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
181
|
+
* @public exported from `@promptbook/core`
|
|
361
182
|
*/
|
|
362
|
-
|
|
183
|
+
var ADMIN_EMAIL = 'me@pavolhejny.com';
|
|
363
184
|
/**
|
|
364
|
-
*
|
|
185
|
+
* Name of the responsible person for the Promptbook on GitHub
|
|
365
186
|
*
|
|
366
187
|
* @public exported from `@promptbook/core`
|
|
367
188
|
*/
|
|
368
|
-
|
|
369
|
-
'content',
|
|
370
|
-
'context',
|
|
371
|
-
'knowledge',
|
|
372
|
-
'examples',
|
|
373
|
-
'modelName',
|
|
374
|
-
'currentDate',
|
|
375
|
-
// <- TODO: list here all command names
|
|
376
|
-
// <- TODO: Add more like 'date', 'modelName',...
|
|
377
|
-
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
378
|
-
]);
|
|
189
|
+
var ADMIN_GITHUB_NAME = 'hejny';
|
|
379
190
|
// <- TODO: [🧜♂️]
|
|
380
191
|
/**
|
|
381
192
|
* @@@
|
|
@@ -634,6 +445,40 @@
|
|
|
634
445
|
return PipelineUrlError;
|
|
635
446
|
}(Error));
|
|
636
447
|
|
|
448
|
+
/**
|
|
449
|
+
* Make error report URL for the given error
|
|
450
|
+
*
|
|
451
|
+
* @private !!!!!!
|
|
452
|
+
*/
|
|
453
|
+
function getErrorReportUrl(error) {
|
|
454
|
+
var report = {
|
|
455
|
+
title: "\uD83D\uDC1C Error report from ".concat(NAME),
|
|
456
|
+
body: spaceTrim__default["default"](function (block) { return "\n\n\n `".concat(error.name || 'Error', "` has occurred in the [").concat(NAME, "], please look into it @").concat(ADMIN_GITHUB_NAME, ".\n\n ```\n ").concat(block(error.message || '(no error message)'), "\n ```\n\n\n ## More info:\n\n - **Promptbook engine version:** ").concat(PROMPTBOOK_ENGINE_VERSION, "\n - **Book language version:** ").concat(BOOK_LANGUAGE_VERSION, "\n - **Time:** ").concat(new Date().toISOString(), "\n\n <details>\n <summary>Stack trace:</summary>\n\n ## Stack trace:\n\n ```stacktrace\n ").concat(block(error.stack || '(empty)'), "\n ```\n </details>\n\n "); }),
|
|
457
|
+
};
|
|
458
|
+
var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
|
|
459
|
+
reportUrl.searchParams.set('labels', 'bug');
|
|
460
|
+
reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
|
|
461
|
+
reportUrl.searchParams.set('title', report.title);
|
|
462
|
+
reportUrl.searchParams.set('body', report.body);
|
|
463
|
+
return reportUrl;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
468
|
+
*
|
|
469
|
+
* @public exported from `@promptbook/core`
|
|
470
|
+
*/
|
|
471
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
472
|
+
__extends(UnexpectedError, _super);
|
|
473
|
+
function UnexpectedError(message) {
|
|
474
|
+
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n ").concat(block(getErrorReportUrl(new Error(message)).href), "\n\n Or contact us on ").concat(ADMIN_EMAIL, "\n\n "); })) || this;
|
|
475
|
+
_this.name = 'UnexpectedError';
|
|
476
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
477
|
+
return _this;
|
|
478
|
+
}
|
|
479
|
+
return UnexpectedError;
|
|
480
|
+
}(Error));
|
|
481
|
+
|
|
637
482
|
/**
|
|
638
483
|
* Index of all custom errors
|
|
639
484
|
*
|