@promptbook/node 0.84.0 → 0.85.0-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 +4 -0
- package/esm/index.es.js +155 -101
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +0 -2
- package/esm/typings/src/_packages/types.index.d.ts +14 -2
- package/esm/typings/src/_packages/utils.index.d.ts +0 -2
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +13 -0
- package/esm/typings/src/cli/cli-commands/start-server.d.ts +13 -0
- package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/execution/AbstractTaskResult.d.ts +25 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +71 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -5
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -15
- package/esm/typings/src/execution/PromptbookFetch.d.ts +8 -1
- package/esm/typings/src/execution/{assertsExecutionSuccessful.d.ts → assertsTaskSuccessful.d.ts} +2 -3
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +0 -3
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -6
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +3 -6
- package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +2 -0
- package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +2 -2
- package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +2 -2
- package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +2 -2
- package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +2 -1
- package/esm/typings/src/utils/random/$randomToken.d.ts +13 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +2 -3
- package/package.json +4 -2
- package/umd/index.umd.js +157 -105
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Progress.d.ts +0 -10
- package/esm/typings/src/types/TaskProgress.d.ts +0 -43
package/README.md
CHANGED
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
<blockquote style="color: #ff8811">
|
|
28
|
+
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
29
|
+
</blockquote>
|
|
30
|
+
|
|
27
31
|
## 📦 Package `@promptbook/node`
|
|
28
32
|
|
|
29
33
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -4,6 +4,8 @@ import { basename, join, dirname } from 'path';
|
|
|
4
4
|
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
5
5
|
import { format } from 'prettier';
|
|
6
6
|
import parserHtml from 'prettier/parser-html';
|
|
7
|
+
import { BehaviorSubject, concat, from } from 'rxjs';
|
|
8
|
+
import { randomBytes } from 'crypto';
|
|
7
9
|
import { forTime } from 'waitasecond';
|
|
8
10
|
import { unparse, parse } from 'papaparse';
|
|
9
11
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
@@ -27,7 +29,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
29
|
* @generated
|
|
28
30
|
* @see https://github.com/webgptorg/promptbook
|
|
29
31
|
*/
|
|
30
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.84.0
|
|
32
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.84.0';
|
|
31
33
|
/**
|
|
32
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1710,6 +1712,58 @@ var MissingToolsError = /** @class */ (function (_super) {
|
|
|
1710
1712
|
return MissingToolsError;
|
|
1711
1713
|
}(Error));
|
|
1712
1714
|
|
|
1715
|
+
/**
|
|
1716
|
+
* Determine if the pipeline is fully prepared
|
|
1717
|
+
*
|
|
1718
|
+
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
1719
|
+
*
|
|
1720
|
+
* @public exported from `@promptbook/core`
|
|
1721
|
+
*/
|
|
1722
|
+
function isPipelinePrepared(pipeline) {
|
|
1723
|
+
// Note: Ignoring `pipeline.preparations` @@@
|
|
1724
|
+
// Note: Ignoring `pipeline.knowledgePieces` @@@
|
|
1725
|
+
if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
|
|
1726
|
+
return false;
|
|
1727
|
+
}
|
|
1728
|
+
if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
|
|
1729
|
+
return false;
|
|
1730
|
+
}
|
|
1731
|
+
if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
|
|
1732
|
+
return false;
|
|
1733
|
+
}
|
|
1734
|
+
/*
|
|
1735
|
+
TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
|
|
1736
|
+
> if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
|
|
1737
|
+
> return false;
|
|
1738
|
+
> }
|
|
1739
|
+
*/
|
|
1740
|
+
return true;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
1744
|
+
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
1745
|
+
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
1746
|
+
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
1747
|
+
* - [🏍] ? Is context in each task
|
|
1748
|
+
* - [♨] Are examples prepared
|
|
1749
|
+
* - [♨] Are tasks prepared
|
|
1750
|
+
*/
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* Generates random token
|
|
1754
|
+
*
|
|
1755
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
1756
|
+
*
|
|
1757
|
+
* @private internal helper function
|
|
1758
|
+
* @returns secure random token
|
|
1759
|
+
*/
|
|
1760
|
+
function $randomToken(randomness) {
|
|
1761
|
+
return randomBytes(randomness).toString('hex');
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1765
|
+
*/
|
|
1766
|
+
|
|
1713
1767
|
/**
|
|
1714
1768
|
* This error indicates errors during the execution of the pipeline
|
|
1715
1769
|
*
|
|
@@ -1943,9 +1997,9 @@ function deserializeError(error) {
|
|
|
1943
1997
|
*
|
|
1944
1998
|
* @param executionResult - The partial result of the Promptbook execution
|
|
1945
1999
|
* @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
|
|
1946
|
-
* @
|
|
2000
|
+
* @private internal helper function of `asPromise` method of `ExecutionTask`
|
|
1947
2001
|
*/
|
|
1948
|
-
function
|
|
2002
|
+
function assertsTaskSuccessful(executionResult) {
|
|
1949
2003
|
var e_1, _a;
|
|
1950
2004
|
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
|
|
1951
2005
|
try {
|
|
@@ -1980,47 +2034,72 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
1980
2034
|
}
|
|
1981
2035
|
}
|
|
1982
2036
|
/**
|
|
1983
|
-
* TODO: [🐚] This function should be removed OR changed OR be completely rewritten
|
|
1984
2037
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1985
2038
|
*/
|
|
1986
2039
|
|
|
1987
2040
|
/**
|
|
1988
|
-
*
|
|
1989
|
-
*
|
|
1990
|
-
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
2041
|
+
* Helper to create a new task
|
|
1991
2042
|
*
|
|
1992
|
-
* @
|
|
2043
|
+
* @private internal helper function
|
|
1993
2044
|
*/
|
|
1994
|
-
function
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2045
|
+
function createTask(options) {
|
|
2046
|
+
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2047
|
+
var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
|
|
2048
|
+
var resultSubject = new BehaviorSubject({});
|
|
2049
|
+
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2050
|
+
resultSubject.next(newOngoingResult);
|
|
2051
|
+
});
|
|
2052
|
+
function asPromise(options) {
|
|
2053
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2054
|
+
var _a, isCrashedOnError, finalResult;
|
|
2055
|
+
return __generator(this, function (_b) {
|
|
2056
|
+
switch (_b.label) {
|
|
2057
|
+
case 0:
|
|
2058
|
+
_a = (options || {}).isCrashedOnError, isCrashedOnError = _a === void 0 ? true : _a;
|
|
2059
|
+
return [4 /*yield*/, finalResultPromise];
|
|
2060
|
+
case 1:
|
|
2061
|
+
finalResult = _b.sent();
|
|
2062
|
+
if (isCrashedOnError) {
|
|
2063
|
+
assertsTaskSuccessful(finalResult);
|
|
2064
|
+
}
|
|
2065
|
+
return [2 /*return*/, finalResult];
|
|
2066
|
+
}
|
|
2067
|
+
});
|
|
2068
|
+
});
|
|
2005
2069
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2070
|
+
return {
|
|
2071
|
+
taskType: taskType,
|
|
2072
|
+
taskId: taskId,
|
|
2073
|
+
asPromise: asPromise,
|
|
2074
|
+
asObservable: function () {
|
|
2075
|
+
return concat(resultSubject.asObservable(), from(asPromise({
|
|
2076
|
+
isCrashedOnError: true,
|
|
2077
|
+
})));
|
|
2078
|
+
},
|
|
2079
|
+
};
|
|
2013
2080
|
}
|
|
2014
2081
|
/**
|
|
2015
|
-
* TODO:
|
|
2016
|
-
* TODO: [
|
|
2017
|
-
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2018
|
-
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2019
|
-
* - [🏍] ? Is context in each task
|
|
2020
|
-
* - [♨] Are examples prepared
|
|
2021
|
-
* - [♨] Are tasks prepared
|
|
2082
|
+
* TODO: Maybe allow to terminate the task and add getter `isFinished` or `status`
|
|
2083
|
+
* TODO: [🐚] Split into more files and make `PrepareTask` & `RemoteTask` + split the function
|
|
2022
2084
|
*/
|
|
2023
2085
|
|
|
2086
|
+
/**
|
|
2087
|
+
* Serializes an error into a [🚉] JSON-serializable object
|
|
2088
|
+
*
|
|
2089
|
+
* @public exported from `@promptbook/utils`
|
|
2090
|
+
*/
|
|
2091
|
+
function serializeError(error) {
|
|
2092
|
+
var name = error.name, message = error.message, stack = error.stack;
|
|
2093
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2094
|
+
console.error(spaceTrim(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2095
|
+
}
|
|
2096
|
+
return {
|
|
2097
|
+
name: name,
|
|
2098
|
+
message: message,
|
|
2099
|
+
stack: stack,
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2024
2103
|
/**
|
|
2025
2104
|
* Format either small or big number
|
|
2026
2105
|
*
|
|
@@ -2096,23 +2175,6 @@ function valueToString(value) {
|
|
|
2096
2175
|
}
|
|
2097
2176
|
}
|
|
2098
2177
|
|
|
2099
|
-
/**
|
|
2100
|
-
* Serializes an error into a [🚉] JSON-serializable object
|
|
2101
|
-
*
|
|
2102
|
-
* @public exported from `@promptbook/utils`
|
|
2103
|
-
*/
|
|
2104
|
-
function serializeError(error) {
|
|
2105
|
-
var name = error.name, message = error.message, stack = error.stack;
|
|
2106
|
-
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2107
|
-
console.error(spaceTrim(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2108
|
-
}
|
|
2109
|
-
return {
|
|
2110
|
-
name: name,
|
|
2111
|
-
message: message,
|
|
2112
|
-
stack: stack,
|
|
2113
|
-
};
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
2178
|
/**
|
|
2117
2179
|
* Represents the usage with no resources consumed
|
|
2118
2180
|
*
|
|
@@ -4260,27 +4322,20 @@ function getReservedParametersForTask(options) {
|
|
|
4260
4322
|
*/
|
|
4261
4323
|
function executeTask(options) {
|
|
4262
4324
|
return __awaiter(this, void 0, void 0, function () {
|
|
4263
|
-
var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed,
|
|
4264
|
-
var e_1,
|
|
4265
|
-
return __generator(this, function (
|
|
4266
|
-
switch (
|
|
4325
|
+
var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_1, _d, _e, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
|
|
4326
|
+
var _f, e_1, _g, _h, _j;
|
|
4327
|
+
return __generator(this, function (_k) {
|
|
4328
|
+
switch (_k.label) {
|
|
4267
4329
|
case 0:
|
|
4268
4330
|
currentTask = options.currentTask, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts, maxParallelCount = options.maxParallelCount, csvSettings = options.csvSettings, isVerbose = options.isVerbose, rootDirname = options.rootDirname, cacheDirname = options.cacheDirname, intermediateFilesStrategy = options.intermediateFilesStrategy, isAutoInstalled = options.isAutoInstalled, isNotPreparedWarningSupressed = options.isNotPreparedWarningSupressed;
|
|
4269
|
-
name = "pipeline-executor-frame-".concat(currentTask.name);
|
|
4270
|
-
title = currentTask.title;
|
|
4271
4331
|
priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
4272
4332
|
return [4 /*yield*/, onProgress({
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
isDone: false,
|
|
4277
|
-
taskType: currentTask.taskType,
|
|
4278
|
-
parameterName: currentTask.resultingParameterName,
|
|
4279
|
-
parameterValue: null,
|
|
4280
|
-
// <- [🍸]
|
|
4333
|
+
outputParameters: (_f = {},
|
|
4334
|
+
_f[currentTask.resultingParameterName] = '',
|
|
4335
|
+
_f),
|
|
4281
4336
|
})];
|
|
4282
4337
|
case 1:
|
|
4283
|
-
|
|
4338
|
+
_k.sent();
|
|
4284
4339
|
usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
4285
4340
|
dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
4286
4341
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
@@ -4299,7 +4354,7 @@ function executeTask(options) {
|
|
|
4299
4354
|
pipelineIdentification: pipelineIdentification,
|
|
4300
4355
|
})];
|
|
4301
4356
|
case 2:
|
|
4302
|
-
definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(
|
|
4357
|
+
definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_k.sent())])), parametersToPass])]);
|
|
4303
4358
|
definedParameterNames = new Set(Object.keys(definedParameters));
|
|
4304
4359
|
parameters = {};
|
|
4305
4360
|
_loop_1 = function (parameterName) {
|
|
@@ -4327,7 +4382,7 @@ function executeTask(options) {
|
|
|
4327
4382
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4328
4383
|
finally {
|
|
4329
4384
|
try {
|
|
4330
|
-
if (_e && !_e.done && (
|
|
4385
|
+
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
4331
4386
|
}
|
|
4332
4387
|
finally { if (e_1) throw e_1.error; }
|
|
4333
4388
|
}
|
|
@@ -4358,24 +4413,19 @@ function executeTask(options) {
|
|
|
4358
4413
|
isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
|
|
4359
4414
|
})];
|
|
4360
4415
|
case 3:
|
|
4361
|
-
resultString =
|
|
4416
|
+
resultString = _k.sent();
|
|
4362
4417
|
return [4 /*yield*/, onProgress({
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
isDone: true,
|
|
4367
|
-
taskType: currentTask.taskType,
|
|
4368
|
-
parameterName: currentTask.resultingParameterName,
|
|
4369
|
-
parameterValue: resultString,
|
|
4370
|
-
// <- [🍸]
|
|
4418
|
+
outputParameters: (_h = {},
|
|
4419
|
+
_h[currentTask.resultingParameterName] = resultString,
|
|
4420
|
+
_h),
|
|
4371
4421
|
})];
|
|
4372
4422
|
case 4:
|
|
4373
|
-
|
|
4374
|
-
return [2 /*return*/, Object.freeze((
|
|
4375
|
-
|
|
4423
|
+
_k.sent();
|
|
4424
|
+
return [2 /*return*/, Object.freeze((_j = {},
|
|
4425
|
+
_j[currentTask.resultingParameterName] =
|
|
4376
4426
|
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
4377
4427
|
resultString,
|
|
4378
|
-
|
|
4428
|
+
_j))];
|
|
4379
4429
|
}
|
|
4380
4430
|
});
|
|
4381
4431
|
});
|
|
@@ -4383,9 +4433,6 @@ function executeTask(options) {
|
|
|
4383
4433
|
/**
|
|
4384
4434
|
* TODO: [🤹♂️]
|
|
4385
4435
|
*/
|
|
4386
|
-
/**
|
|
4387
|
-
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4388
|
-
*/
|
|
4389
4436
|
|
|
4390
4437
|
/**
|
|
4391
4438
|
* @@@
|
|
@@ -4647,15 +4694,15 @@ function executePipeline(options) {
|
|
|
4647
4694
|
return [3 /*break*/, 4];
|
|
4648
4695
|
case 3:
|
|
4649
4696
|
unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
|
|
4650
|
-
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (
|
|
4697
|
+
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (newOngoingResult) {
|
|
4651
4698
|
if (isReturned) {
|
|
4652
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(
|
|
4699
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(newOngoingResult, null, 4)
|
|
4653
4700
|
.split('\n')
|
|
4654
4701
|
.map(function (line) { return "> ".concat(line); })
|
|
4655
4702
|
.join('\n')), "\n "); }));
|
|
4656
4703
|
}
|
|
4657
4704
|
if (onProgress) {
|
|
4658
|
-
onProgress(
|
|
4705
|
+
onProgress(newOngoingResult);
|
|
4659
4706
|
}
|
|
4660
4707
|
}, $executionReport: executionReport, pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
|
|
4661
4708
|
.then(function (newParametersToPass) {
|
|
@@ -4758,9 +4805,6 @@ function executePipeline(options) {
|
|
|
4758
4805
|
});
|
|
4759
4806
|
});
|
|
4760
4807
|
}
|
|
4761
|
-
/**
|
|
4762
|
-
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4763
|
-
*/
|
|
4764
4808
|
|
|
4765
4809
|
/**
|
|
4766
4810
|
* Creates executor function from pipeline and execution tools.
|
|
@@ -4792,7 +4836,7 @@ function createPipelineExecutor(options) {
|
|
|
4792
4836
|
console.warn(spaceTrim$1(function (block) { return "\n Pipeline is not prepared\n\n ".concat(block(pipelineIdentification), "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "); }));
|
|
4793
4837
|
}
|
|
4794
4838
|
var runCount = 0;
|
|
4795
|
-
var
|
|
4839
|
+
var pipelineExecutorWithCallback = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
4796
4840
|
return __generator(this, function (_a) {
|
|
4797
4841
|
runCount++;
|
|
4798
4842
|
return [2 /*return*/, /* not await */ executePipeline({
|
|
@@ -4817,11 +4861,23 @@ function createPipelineExecutor(options) {
|
|
|
4817
4861
|
})];
|
|
4818
4862
|
});
|
|
4819
4863
|
}); };
|
|
4864
|
+
var pipelineExecutor = function (inputParameters) {
|
|
4865
|
+
return createTask({
|
|
4866
|
+
taskType: 'EXECUTION',
|
|
4867
|
+
taskProcessCallback: function (updateOngoingResult) {
|
|
4868
|
+
var _this = this;
|
|
4869
|
+
return pipelineExecutorWithCallback(inputParameters, function (newOngoingResult) { return __awaiter(_this, void 0, void 0, function () {
|
|
4870
|
+
return __generator(this, function (_a) {
|
|
4871
|
+
updateOngoingResult(newOngoingResult);
|
|
4872
|
+
return [2 /*return*/];
|
|
4873
|
+
});
|
|
4874
|
+
}); });
|
|
4875
|
+
},
|
|
4876
|
+
});
|
|
4877
|
+
};
|
|
4878
|
+
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
4820
4879
|
return pipelineExecutor;
|
|
4821
4880
|
}
|
|
4822
|
-
/**
|
|
4823
|
-
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4824
|
-
*/
|
|
4825
4881
|
|
|
4826
4882
|
/**
|
|
4827
4883
|
* Async version of Array.forEach
|
|
@@ -5026,10 +5082,9 @@ function preparePersona(personaDescription, tools, options) {
|
|
|
5026
5082
|
return modelName;
|
|
5027
5083
|
})
|
|
5028
5084
|
.join(',');
|
|
5029
|
-
return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription })];
|
|
5085
|
+
return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription }).asPromise()];
|
|
5030
5086
|
case 3:
|
|
5031
5087
|
result = _d.sent();
|
|
5032
|
-
assertsExecutionSuccessful(result);
|
|
5033
5088
|
outputParameters = result.outputParameters;
|
|
5034
5089
|
modelRequirementsRaw = outputParameters.modelRequirements;
|
|
5035
5090
|
modelRequirements = JSON.parse(modelRequirementsRaw);
|
|
@@ -5974,10 +6029,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
5974
6029
|
var content = _a.content;
|
|
5975
6030
|
return content;
|
|
5976
6031
|
}).join('\n\n'),
|
|
5977
|
-
})];
|
|
6032
|
+
}).asPromise()];
|
|
5978
6033
|
case 2:
|
|
5979
6034
|
result = _e.sent();
|
|
5980
|
-
assertsExecutionSuccessful(result);
|
|
5981
6035
|
outputParameters = result.outputParameters;
|
|
5982
6036
|
titleRaw = outputParameters.title;
|
|
5983
6037
|
if (isVerbose) {
|
|
@@ -9555,7 +9609,7 @@ function compilePipeline(pipelineString, tools, options) {
|
|
|
9555
9609
|
*/
|
|
9556
9610
|
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
9557
9611
|
/**
|
|
9558
|
-
* TODO: [
|
|
9612
|
+
* TODO: [🎺]
|
|
9559
9613
|
*/
|
|
9560
9614
|
|
|
9561
9615
|
/**
|
|
@@ -10494,7 +10548,7 @@ function $provideScrapersForNode(tools, options) {
|
|
|
10494
10548
|
*/
|
|
10495
10549
|
new Function("\n try {\n return this === window;\n } catch (e) {\n return false;\n }\n");
|
|
10496
10550
|
/**
|
|
10497
|
-
* TODO: [
|
|
10551
|
+
* TODO: [🎺]
|
|
10498
10552
|
*/
|
|
10499
10553
|
|
|
10500
10554
|
/**
|
|
@@ -10506,7 +10560,7 @@ new Function("\n try {\n return this === window;\n } catch (e) {\n
|
|
|
10506
10560
|
*/
|
|
10507
10561
|
new Function("\n try {\n return process.env.JEST_WORKER_ID !== undefined;\n } catch (e) {\n return false;\n }\n");
|
|
10508
10562
|
/**
|
|
10509
|
-
* TODO: [
|
|
10563
|
+
* TODO: [🎺]
|
|
10510
10564
|
*/
|
|
10511
10565
|
|
|
10512
10566
|
/**
|
|
@@ -10518,7 +10572,7 @@ new Function("\n try {\n return process.env.JEST_WORKER_ID !== undefin
|
|
|
10518
10572
|
*/
|
|
10519
10573
|
new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {\n return true;\n } else {\n return false;\n }\n } catch (e) {\n return false;\n }\n");
|
|
10520
10574
|
/**
|
|
10521
|
-
* TODO: [
|
|
10575
|
+
* TODO: [🎺]
|
|
10522
10576
|
*/
|
|
10523
10577
|
|
|
10524
10578
|
/**
|