@promptbook/core 0.84.0 → 0.85.0-1
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/FilesystemTools.d.ts +1 -1
- 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 +3 -0
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +6 -4
- 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 +3 -1
- package/umd/index.umd.js +161 -110
- 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/core`
|
|
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
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { format } from 'prettier';
|
|
3
3
|
import parserHtml from 'prettier/parser-html';
|
|
4
|
+
import { BehaviorSubject, concat, from } from 'rxjs';
|
|
5
|
+
import { randomBytes } from 'crypto';
|
|
4
6
|
import { forTime } from 'waitasecond';
|
|
5
7
|
import { unparse, parse } from 'papaparse';
|
|
6
8
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
7
9
|
import sha256 from 'crypto-js/sha256';
|
|
8
|
-
import { basename, join, dirname } from 'path';
|
|
10
|
+
import { basename, join, dirname } from 'node:path';
|
|
9
11
|
import { SHA256 } from 'crypto-js';
|
|
10
12
|
import { lookup, extension } from 'mime-types';
|
|
11
13
|
import moment from 'moment';
|
|
@@ -25,7 +27,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
25
27
|
* @generated
|
|
26
28
|
* @see https://github.com/webgptorg/promptbook
|
|
27
29
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
30
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-0';
|
|
29
31
|
/**
|
|
30
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2040,6 +2042,58 @@ var MissingToolsError = /** @class */ (function (_super) {
|
|
|
2040
2042
|
return MissingToolsError;
|
|
2041
2043
|
}(Error));
|
|
2042
2044
|
|
|
2045
|
+
/**
|
|
2046
|
+
* Determine if the pipeline is fully prepared
|
|
2047
|
+
*
|
|
2048
|
+
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
2049
|
+
*
|
|
2050
|
+
* @public exported from `@promptbook/core`
|
|
2051
|
+
*/
|
|
2052
|
+
function isPipelinePrepared(pipeline) {
|
|
2053
|
+
// Note: Ignoring `pipeline.preparations` @@@
|
|
2054
|
+
// Note: Ignoring `pipeline.knowledgePieces` @@@
|
|
2055
|
+
if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
|
|
2056
|
+
return false;
|
|
2057
|
+
}
|
|
2058
|
+
if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
|
|
2059
|
+
return false;
|
|
2060
|
+
}
|
|
2061
|
+
if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
|
|
2062
|
+
return false;
|
|
2063
|
+
}
|
|
2064
|
+
/*
|
|
2065
|
+
TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
|
|
2066
|
+
> if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
|
|
2067
|
+
> return false;
|
|
2068
|
+
> }
|
|
2069
|
+
*/
|
|
2070
|
+
return true;
|
|
2071
|
+
}
|
|
2072
|
+
/**
|
|
2073
|
+
* TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2074
|
+
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2075
|
+
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2076
|
+
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2077
|
+
* - [🏍] ? Is context in each task
|
|
2078
|
+
* - [♨] Are examples prepared
|
|
2079
|
+
* - [♨] Are tasks prepared
|
|
2080
|
+
*/
|
|
2081
|
+
|
|
2082
|
+
/**
|
|
2083
|
+
* Generates random token
|
|
2084
|
+
*
|
|
2085
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2086
|
+
*
|
|
2087
|
+
* @private internal helper function
|
|
2088
|
+
* @returns secure random token
|
|
2089
|
+
*/
|
|
2090
|
+
function $randomToken(randomness) {
|
|
2091
|
+
return randomBytes(randomness).toString('hex');
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2095
|
+
*/
|
|
2096
|
+
|
|
2043
2097
|
/**
|
|
2044
2098
|
* This error indicates errors during the execution of the pipeline
|
|
2045
2099
|
*
|
|
@@ -2273,9 +2327,9 @@ function deserializeError(error) {
|
|
|
2273
2327
|
*
|
|
2274
2328
|
* @param executionResult - The partial result of the Promptbook execution
|
|
2275
2329
|
* @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2276
|
-
* @
|
|
2330
|
+
* @private internal helper function of `asPromise` method of `ExecutionTask`
|
|
2277
2331
|
*/
|
|
2278
|
-
function
|
|
2332
|
+
function assertsTaskSuccessful(executionResult) {
|
|
2279
2333
|
var e_1, _a;
|
|
2280
2334
|
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
|
|
2281
2335
|
try {
|
|
@@ -2310,47 +2364,72 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
2310
2364
|
}
|
|
2311
2365
|
}
|
|
2312
2366
|
/**
|
|
2313
|
-
* TODO: [🐚] This function should be removed OR changed OR be completely rewritten
|
|
2314
2367
|
* TODO: [🧠] Can this return type be better typed than void
|
|
2315
2368
|
*/
|
|
2316
2369
|
|
|
2317
2370
|
/**
|
|
2318
|
-
*
|
|
2319
|
-
*
|
|
2320
|
-
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
2371
|
+
* Helper to create a new task
|
|
2321
2372
|
*
|
|
2322
|
-
* @
|
|
2373
|
+
* @private internal helper function
|
|
2323
2374
|
*/
|
|
2324
|
-
function
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2375
|
+
function createTask(options) {
|
|
2376
|
+
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2377
|
+
var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
|
|
2378
|
+
var partialResultSubject = new BehaviorSubject({});
|
|
2379
|
+
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2380
|
+
partialResultSubject.next(newOngoingResult);
|
|
2381
|
+
});
|
|
2382
|
+
function asPromise(options) {
|
|
2383
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2384
|
+
var _a, isCrashedOnError, finalResult;
|
|
2385
|
+
return __generator(this, function (_b) {
|
|
2386
|
+
switch (_b.label) {
|
|
2387
|
+
case 0:
|
|
2388
|
+
_a = (options || {}).isCrashedOnError, isCrashedOnError = _a === void 0 ? true : _a;
|
|
2389
|
+
return [4 /*yield*/, finalResultPromise];
|
|
2390
|
+
case 1:
|
|
2391
|
+
finalResult = _b.sent();
|
|
2392
|
+
if (isCrashedOnError) {
|
|
2393
|
+
assertsTaskSuccessful(finalResult);
|
|
2394
|
+
}
|
|
2395
|
+
return [2 /*return*/, finalResult];
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
});
|
|
2335
2399
|
}
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2400
|
+
return {
|
|
2401
|
+
taskType: taskType,
|
|
2402
|
+
taskId: taskId,
|
|
2403
|
+
asPromise: asPromise,
|
|
2404
|
+
asObservable: function () {
|
|
2405
|
+
return concat(partialResultSubject.asObservable(), from(asPromise({
|
|
2406
|
+
isCrashedOnError: true,
|
|
2407
|
+
})));
|
|
2408
|
+
},
|
|
2409
|
+
};
|
|
2343
2410
|
}
|
|
2344
2411
|
/**
|
|
2345
|
-
* TODO:
|
|
2346
|
-
* TODO: [
|
|
2347
|
-
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2348
|
-
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2349
|
-
* - [🏍] ? Is context in each task
|
|
2350
|
-
* - [♨] Are examples prepared
|
|
2351
|
-
* - [♨] Are tasks prepared
|
|
2412
|
+
* TODO: Maybe allow to terminate the task and add getter `isFinished` or `status`
|
|
2413
|
+
* TODO: [🐚] Split into more files and make `PrepareTask` & `RemoteTask` + split the function
|
|
2352
2414
|
*/
|
|
2353
2415
|
|
|
2416
|
+
/**
|
|
2417
|
+
* Serializes an error into a [🚉] JSON-serializable object
|
|
2418
|
+
*
|
|
2419
|
+
* @public exported from `@promptbook/utils`
|
|
2420
|
+
*/
|
|
2421
|
+
function serializeError(error) {
|
|
2422
|
+
var name = error.name, message = error.message, stack = error.stack;
|
|
2423
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2424
|
+
console.error(spaceTrim(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2425
|
+
}
|
|
2426
|
+
return {
|
|
2427
|
+
name: name,
|
|
2428
|
+
message: message,
|
|
2429
|
+
stack: stack,
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2354
2433
|
/**
|
|
2355
2434
|
* Format either small or big number
|
|
2356
2435
|
*
|
|
@@ -2426,23 +2505,6 @@ function valueToString(value) {
|
|
|
2426
2505
|
}
|
|
2427
2506
|
}
|
|
2428
2507
|
|
|
2429
|
-
/**
|
|
2430
|
-
* Serializes an error into a [🚉] JSON-serializable object
|
|
2431
|
-
*
|
|
2432
|
-
* @public exported from `@promptbook/utils`
|
|
2433
|
-
*/
|
|
2434
|
-
function serializeError(error) {
|
|
2435
|
-
var name = error.name, message = error.message, stack = error.stack;
|
|
2436
|
-
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2437
|
-
console.error(spaceTrim(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2438
|
-
}
|
|
2439
|
-
return {
|
|
2440
|
-
name: name,
|
|
2441
|
-
message: message,
|
|
2442
|
-
stack: stack,
|
|
2443
|
-
};
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
2508
|
/**
|
|
2447
2509
|
* Represents the usage with no resources consumed
|
|
2448
2510
|
*
|
|
@@ -4612,27 +4674,20 @@ function getReservedParametersForTask(options) {
|
|
|
4612
4674
|
*/
|
|
4613
4675
|
function executeTask(options) {
|
|
4614
4676
|
return __awaiter(this, void 0, void 0, function () {
|
|
4615
|
-
var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed,
|
|
4616
|
-
var e_1,
|
|
4617
|
-
return __generator(this, function (
|
|
4618
|
-
switch (
|
|
4677
|
+
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;
|
|
4678
|
+
var _f, e_1, _g, _h, _j;
|
|
4679
|
+
return __generator(this, function (_k) {
|
|
4680
|
+
switch (_k.label) {
|
|
4619
4681
|
case 0:
|
|
4620
4682
|
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;
|
|
4621
|
-
name = "pipeline-executor-frame-".concat(currentTask.name);
|
|
4622
|
-
title = currentTask.title;
|
|
4623
4683
|
priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
4624
4684
|
return [4 /*yield*/, onProgress({
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
isDone: false,
|
|
4629
|
-
taskType: currentTask.taskType,
|
|
4630
|
-
parameterName: currentTask.resultingParameterName,
|
|
4631
|
-
parameterValue: null,
|
|
4632
|
-
// <- [🍸]
|
|
4685
|
+
outputParameters: (_f = {},
|
|
4686
|
+
_f[currentTask.resultingParameterName] = '',
|
|
4687
|
+
_f),
|
|
4633
4688
|
})];
|
|
4634
4689
|
case 1:
|
|
4635
|
-
|
|
4690
|
+
_k.sent();
|
|
4636
4691
|
usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
4637
4692
|
dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
4638
4693
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
@@ -4651,7 +4706,7 @@ function executeTask(options) {
|
|
|
4651
4706
|
pipelineIdentification: pipelineIdentification,
|
|
4652
4707
|
})];
|
|
4653
4708
|
case 2:
|
|
4654
|
-
definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(
|
|
4709
|
+
definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_k.sent())])), parametersToPass])]);
|
|
4655
4710
|
definedParameterNames = new Set(Object.keys(definedParameters));
|
|
4656
4711
|
parameters = {};
|
|
4657
4712
|
_loop_1 = function (parameterName) {
|
|
@@ -4679,7 +4734,7 @@ function executeTask(options) {
|
|
|
4679
4734
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4680
4735
|
finally {
|
|
4681
4736
|
try {
|
|
4682
|
-
if (_e && !_e.done && (
|
|
4737
|
+
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
4683
4738
|
}
|
|
4684
4739
|
finally { if (e_1) throw e_1.error; }
|
|
4685
4740
|
}
|
|
@@ -4710,24 +4765,19 @@ function executeTask(options) {
|
|
|
4710
4765
|
isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
|
|
4711
4766
|
})];
|
|
4712
4767
|
case 3:
|
|
4713
|
-
resultString =
|
|
4768
|
+
resultString = _k.sent();
|
|
4714
4769
|
return [4 /*yield*/, onProgress({
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
isDone: true,
|
|
4719
|
-
taskType: currentTask.taskType,
|
|
4720
|
-
parameterName: currentTask.resultingParameterName,
|
|
4721
|
-
parameterValue: resultString,
|
|
4722
|
-
// <- [🍸]
|
|
4770
|
+
outputParameters: (_h = {},
|
|
4771
|
+
_h[currentTask.resultingParameterName] = resultString,
|
|
4772
|
+
_h),
|
|
4723
4773
|
})];
|
|
4724
4774
|
case 4:
|
|
4725
|
-
|
|
4726
|
-
return [2 /*return*/, Object.freeze((
|
|
4727
|
-
|
|
4775
|
+
_k.sent();
|
|
4776
|
+
return [2 /*return*/, Object.freeze((_j = {},
|
|
4777
|
+
_j[currentTask.resultingParameterName] =
|
|
4728
4778
|
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
4729
4779
|
resultString,
|
|
4730
|
-
|
|
4780
|
+
_j))];
|
|
4731
4781
|
}
|
|
4732
4782
|
});
|
|
4733
4783
|
});
|
|
@@ -4735,9 +4785,6 @@ function executeTask(options) {
|
|
|
4735
4785
|
/**
|
|
4736
4786
|
* TODO: [🤹♂️]
|
|
4737
4787
|
*/
|
|
4738
|
-
/**
|
|
4739
|
-
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4740
|
-
*/
|
|
4741
4788
|
|
|
4742
4789
|
/**
|
|
4743
4790
|
* @@@
|
|
@@ -4999,15 +5046,15 @@ function executePipeline(options) {
|
|
|
4999
5046
|
return [3 /*break*/, 4];
|
|
5000
5047
|
case 3:
|
|
5001
5048
|
unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
|
|
5002
|
-
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (
|
|
5049
|
+
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (newOngoingResult) {
|
|
5003
5050
|
if (isReturned) {
|
|
5004
|
-
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(
|
|
5051
|
+
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)
|
|
5005
5052
|
.split('\n')
|
|
5006
5053
|
.map(function (line) { return "> ".concat(line); })
|
|
5007
5054
|
.join('\n')), "\n "); }));
|
|
5008
5055
|
}
|
|
5009
5056
|
if (onProgress) {
|
|
5010
|
-
onProgress(
|
|
5057
|
+
onProgress(newOngoingResult);
|
|
5011
5058
|
}
|
|
5012
5059
|
}, $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 "); }) }))
|
|
5013
5060
|
.then(function (newParametersToPass) {
|
|
@@ -5110,9 +5157,6 @@ function executePipeline(options) {
|
|
|
5110
5157
|
});
|
|
5111
5158
|
});
|
|
5112
5159
|
}
|
|
5113
|
-
/**
|
|
5114
|
-
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
5115
|
-
*/
|
|
5116
5160
|
|
|
5117
5161
|
/**
|
|
5118
5162
|
* Creates executor function from pipeline and execution tools.
|
|
@@ -5144,7 +5188,7 @@ function createPipelineExecutor(options) {
|
|
|
5144
5188
|
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 "); }));
|
|
5145
5189
|
}
|
|
5146
5190
|
var runCount = 0;
|
|
5147
|
-
var
|
|
5191
|
+
var pipelineExecutorWithCallback = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
5148
5192
|
return __generator(this, function (_a) {
|
|
5149
5193
|
runCount++;
|
|
5150
5194
|
return [2 /*return*/, /* not await */ executePipeline({
|
|
@@ -5169,11 +5213,23 @@ function createPipelineExecutor(options) {
|
|
|
5169
5213
|
})];
|
|
5170
5214
|
});
|
|
5171
5215
|
}); };
|
|
5216
|
+
var pipelineExecutor = function (inputParameters) {
|
|
5217
|
+
return createTask({
|
|
5218
|
+
taskType: 'EXECUTION',
|
|
5219
|
+
taskProcessCallback: function (updateOngoingResult) {
|
|
5220
|
+
var _this = this;
|
|
5221
|
+
return pipelineExecutorWithCallback(inputParameters, function (newOngoingResult) { return __awaiter(_this, void 0, void 0, function () {
|
|
5222
|
+
return __generator(this, function (_a) {
|
|
5223
|
+
updateOngoingResult(newOngoingResult);
|
|
5224
|
+
return [2 /*return*/];
|
|
5225
|
+
});
|
|
5226
|
+
}); });
|
|
5227
|
+
},
|
|
5228
|
+
});
|
|
5229
|
+
};
|
|
5230
|
+
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
5172
5231
|
return pipelineExecutor;
|
|
5173
5232
|
}
|
|
5174
|
-
/**
|
|
5175
|
-
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
5176
|
-
*/
|
|
5177
5233
|
|
|
5178
5234
|
/**
|
|
5179
5235
|
* Async version of Array.forEach
|
|
@@ -5378,10 +5434,9 @@ function preparePersona(personaDescription, tools, options) {
|
|
|
5378
5434
|
return modelName;
|
|
5379
5435
|
})
|
|
5380
5436
|
.join(',');
|
|
5381
|
-
return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription })];
|
|
5437
|
+
return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription }).asPromise()];
|
|
5382
5438
|
case 3:
|
|
5383
5439
|
result = _d.sent();
|
|
5384
|
-
assertsExecutionSuccessful(result);
|
|
5385
5440
|
outputParameters = result.outputParameters;
|
|
5386
5441
|
modelRequirementsRaw = outputParameters.modelRequirements;
|
|
5387
5442
|
modelRequirements = JSON.parse(modelRequirementsRaw);
|
|
@@ -6332,10 +6387,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
6332
6387
|
var content = _a.content;
|
|
6333
6388
|
return content;
|
|
6334
6389
|
}).join('\n\n'),
|
|
6335
|
-
})];
|
|
6390
|
+
}).asPromise()];
|
|
6336
6391
|
case 2:
|
|
6337
6392
|
result = _e.sent();
|
|
6338
|
-
assertsExecutionSuccessful(result);
|
|
6339
6393
|
outputParameters = result.outputParameters;
|
|
6340
6394
|
titleRaw = outputParameters.title;
|
|
6341
6395
|
if (isVerbose) {
|
|
@@ -10515,7 +10569,7 @@ var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
|
|
|
10515
10569
|
*/
|
|
10516
10570
|
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
10517
10571
|
/**
|
|
10518
|
-
* TODO: [
|
|
10572
|
+
* TODO: [🎺]
|
|
10519
10573
|
*/
|
|
10520
10574
|
|
|
10521
10575
|
/**
|
|
@@ -11049,7 +11103,7 @@ var _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
11049
11103
|
*/
|
|
11050
11104
|
var $isRunningInJest = new Function("\n try {\n return process.env.JEST_WORKER_ID !== undefined;\n } catch (e) {\n return false;\n }\n");
|
|
11051
11105
|
/**
|
|
11052
|
-
* TODO: [
|
|
11106
|
+
* TODO: [🎺]
|
|
11053
11107
|
*/
|
|
11054
11108
|
|
|
11055
11109
|
/**
|
|
@@ -11647,5 +11701,5 @@ var PrefixStorage = /** @class */ (function () {
|
|
|
11647
11701
|
return PrefixStorage;
|
|
11648
11702
|
}());
|
|
11649
11703
|
|
|
11650
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage,
|
|
11704
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline, validatePipelineString };
|
|
11651
11705
|
//# sourceMappingURL=index.es.js.map
|