@promptbook/remote-server 0.85.0-3 → 0.85.0-4
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 +38 -21
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/execution/ExecutionTask.d.ts +7 -3
- package/package.json +2 -2
- package/umd/index.umd.js +38 -21
- package/umd/index.umd.js.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
2
|
import { PartialDeep } from 'type-fest';
|
|
3
|
-
import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
4
3
|
import type { task_id } from '../types/typeAliases';
|
|
4
|
+
import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
5
5
|
import type { AbstractTaskResult } from './AbstractTaskResult';
|
|
6
6
|
import type { PipelineExecutorResult } from './PipelineExecutorResult';
|
|
7
7
|
/**
|
|
@@ -30,7 +30,7 @@ export declare function createTask<TTaskResult extends AbstractTaskResult>(optio
|
|
|
30
30
|
*/
|
|
31
31
|
export type ExecutionTask = AbstractTask<PipelineExecutorResult> & {
|
|
32
32
|
readonly taskType: 'EXECUTION';
|
|
33
|
-
readonly taskId: `
|
|
33
|
+
readonly taskId: `exec-${task_id}`;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* Represents a task that prepares a pipeline
|
|
@@ -38,7 +38,7 @@ export type ExecutionTask = AbstractTask<PipelineExecutorResult> & {
|
|
|
38
38
|
*/
|
|
39
39
|
export type PreparationTask = AbstractTask<PipelineExecutorResult> & {
|
|
40
40
|
readonly taskType: 'PREPARATION';
|
|
41
|
-
readonly taskId: `
|
|
41
|
+
readonly taskId: `prep-${task_id}`;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Base interface for all task types
|
|
@@ -62,6 +62,10 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
|
|
|
62
62
|
* Gets an observable stream of partial task results
|
|
63
63
|
*/
|
|
64
64
|
asObservable(): Observable<PartialDeep<TTaskResult>>;
|
|
65
|
+
/**
|
|
66
|
+
* Gets just the current value which is mutated during the task processing
|
|
67
|
+
*/
|
|
68
|
+
currentValue: PartialDeep<TTaskResult>;
|
|
65
69
|
};
|
|
66
70
|
export type Task = ExecutionTask | PreparationTask;
|
|
67
71
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-server",
|
|
3
|
-
"version": "0.85.0-
|
|
3
|
+
"version": "0.85.0-4",
|
|
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/remote-server.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.85.0-
|
|
50
|
+
"@promptbook/core": "0.85.0-4"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-
|
|
31
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-3';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2006,7 +2006,7 @@
|
|
|
2006
2006
|
*/
|
|
2007
2007
|
function createTask(options) {
|
|
2008
2008
|
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2009
|
-
var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(
|
|
2009
|
+
var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: !!! To global config + Use Base58 to avoid simmilar char conflicts */));
|
|
2010
2010
|
var partialResultSubject = new rxjs.BehaviorSubject({});
|
|
2011
2011
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2012
2012
|
partialResultSubject.next(newOngoingResult);
|
|
@@ -2038,6 +2038,9 @@
|
|
|
2038
2038
|
isCrashedOnError: true,
|
|
2039
2039
|
})));
|
|
2040
2040
|
},
|
|
2041
|
+
get currentValue() {
|
|
2042
|
+
return partialResultSubject.value;
|
|
2043
|
+
},
|
|
2041
2044
|
};
|
|
2042
2045
|
}
|
|
2043
2046
|
/**
|
|
@@ -6956,27 +6959,29 @@
|
|
|
6956
6959
|
app.get("".concat(rootPath, "/executions/:taskId"), function (request, response) { return __awaiter(_this, void 0, void 0, function () {
|
|
6957
6960
|
var taskId, execution;
|
|
6958
6961
|
return __generator(this, function (_a) {
|
|
6959
|
-
taskId = request.
|
|
6962
|
+
taskId = request.params.taskId;
|
|
6960
6963
|
execution = runningExecutionTasks.find(function (executionTask) { return executionTask.taskId === taskId; });
|
|
6961
6964
|
if (execution === undefined) {
|
|
6962
6965
|
response.status(404).send("Execution \"".concat(taskId, "\" not found"));
|
|
6963
6966
|
return [2 /*return*/];
|
|
6964
6967
|
}
|
|
6965
|
-
response.send(execution);
|
|
6968
|
+
response.send(execution.currentValue);
|
|
6966
6969
|
return [2 /*return*/];
|
|
6967
6970
|
});
|
|
6968
6971
|
}); });
|
|
6969
6972
|
app.post("".concat(rootPath, "/executions/new"), function (request, response) { return __awaiter(_this, void 0, void 0, function () {
|
|
6970
|
-
var inputParameters, pipelineUrl, pipeline, llm, fs, executables, tools, pipelineExecutor, executionTask;
|
|
6973
|
+
var inputParameters, pipelineUrl, pipeline, llm, fs, executables, tools, pipelineExecutor, executionTask, error_1;
|
|
6971
6974
|
var _a;
|
|
6972
6975
|
return __generator(this, function (_b) {
|
|
6973
6976
|
switch (_b.label) {
|
|
6974
6977
|
case 0:
|
|
6978
|
+
_b.trys.push([0, 5, , 6]);
|
|
6975
6979
|
inputParameters = request.body.inputParameters;
|
|
6976
6980
|
pipelineUrl = request.body.pipelineUrl || request.body.book;
|
|
6977
6981
|
return [4 /*yield*/, (collection === null || collection === void 0 ? void 0 : collection.getPipelineByUrl(pipelineUrl))];
|
|
6978
6982
|
case 1:
|
|
6979
6983
|
pipeline = _b.sent();
|
|
6984
|
+
// <- TODO: !!!!!! NotFoundError
|
|
6980
6985
|
if (pipeline === undefined) {
|
|
6981
6986
|
response.status(404).send("Pipeline \"".concat(pipelineUrl, "\" not found"));
|
|
6982
6987
|
return [2 /*return*/];
|
|
@@ -7004,7 +7009,19 @@
|
|
|
7004
7009
|
executionTask = pipelineExecutor(inputParameters);
|
|
7005
7010
|
runningExecutionTasks.push(executionTask);
|
|
7006
7011
|
response.send(executionTask);
|
|
7007
|
-
|
|
7012
|
+
// TODO: !!!!!! Remove this:
|
|
7013
|
+
executionTask.asObservable().subscribe(function (_) {
|
|
7014
|
+
console.log('!!!', _);
|
|
7015
|
+
});
|
|
7016
|
+
return [3 /*break*/, 6];
|
|
7017
|
+
case 5:
|
|
7018
|
+
error_1 = _b.sent();
|
|
7019
|
+
if (!(error_1 instanceof Error)) {
|
|
7020
|
+
throw error_1;
|
|
7021
|
+
}
|
|
7022
|
+
response.status(400).send({ error: serializeError(error_1) });
|
|
7023
|
+
return [3 /*break*/, 6];
|
|
7024
|
+
case 6: return [2 /*return*/];
|
|
7008
7025
|
}
|
|
7009
7026
|
});
|
|
7010
7027
|
}); });
|
|
@@ -7069,7 +7086,7 @@
|
|
|
7069
7086
|
}); };
|
|
7070
7087
|
// -----------
|
|
7071
7088
|
socket.on('prompt-request', function (request) { return __awaiter(_this, void 0, void 0, function () {
|
|
7072
|
-
var identification, prompt, executionTools, llm, _a, promptResult, _b,
|
|
7089
|
+
var identification, prompt, executionTools, llm, _a, promptResult, _b, error_2;
|
|
7073
7090
|
return __generator(this, function (_c) {
|
|
7074
7091
|
switch (_c.label) {
|
|
7075
7092
|
case 0:
|
|
@@ -7138,11 +7155,11 @@
|
|
|
7138
7155
|
socket.emit('prompt-response', { promptResult: promptResult } /* <- Note: [🤛] */);
|
|
7139
7156
|
return [3 /*break*/, 15];
|
|
7140
7157
|
case 13:
|
|
7141
|
-
|
|
7142
|
-
if (!(
|
|
7143
|
-
throw
|
|
7158
|
+
error_2 = _c.sent();
|
|
7159
|
+
if (!(error_2 instanceof Error)) {
|
|
7160
|
+
throw error_2;
|
|
7144
7161
|
}
|
|
7145
|
-
socket.emit('error', serializeError(
|
|
7162
|
+
socket.emit('error', serializeError(error_2) /* <- Note: [🤛] */);
|
|
7146
7163
|
return [3 /*break*/, 15];
|
|
7147
7164
|
case 14:
|
|
7148
7165
|
socket.disconnect();
|
|
@@ -7154,7 +7171,7 @@
|
|
|
7154
7171
|
// -----------
|
|
7155
7172
|
// TODO: [👒] Listing models (and checking configuration) probbably should go through REST API not Socket.io
|
|
7156
7173
|
socket.on('listModels-request', function (request) { return __awaiter(_this, void 0, void 0, function () {
|
|
7157
|
-
var identification, executionTools, llm, models,
|
|
7174
|
+
var identification, executionTools, llm, models, error_3;
|
|
7158
7175
|
return __generator(this, function (_a) {
|
|
7159
7176
|
switch (_a.label) {
|
|
7160
7177
|
case 0:
|
|
@@ -7175,11 +7192,11 @@
|
|
|
7175
7192
|
socket.emit('listModels-response', { models: models } /* <- Note: [🤛] */);
|
|
7176
7193
|
return [3 /*break*/, 6];
|
|
7177
7194
|
case 4:
|
|
7178
|
-
|
|
7179
|
-
if (!(
|
|
7180
|
-
throw
|
|
7195
|
+
error_3 = _a.sent();
|
|
7196
|
+
if (!(error_3 instanceof Error)) {
|
|
7197
|
+
throw error_3;
|
|
7181
7198
|
}
|
|
7182
|
-
socket.emit('error', serializeError(
|
|
7199
|
+
socket.emit('error', serializeError(error_3));
|
|
7183
7200
|
return [3 /*break*/, 6];
|
|
7184
7201
|
case 5:
|
|
7185
7202
|
socket.disconnect();
|
|
@@ -7191,7 +7208,7 @@
|
|
|
7191
7208
|
// -----------
|
|
7192
7209
|
// TODO: [👒] Listing models (and checking configuration) probbably should go through REST API not Socket.io
|
|
7193
7210
|
socket.on('preparePipeline-request', function (request) { return __awaiter(_this, void 0, void 0, function () {
|
|
7194
|
-
var identification, pipeline, executionTools, preparedPipeline,
|
|
7211
|
+
var identification, pipeline, executionTools, preparedPipeline, error_4;
|
|
7195
7212
|
return __generator(this, function (_a) {
|
|
7196
7213
|
switch (_a.label) {
|
|
7197
7214
|
case 0:
|
|
@@ -7211,11 +7228,11 @@
|
|
|
7211
7228
|
socket.emit('preparePipeline-response', { preparedPipeline: preparedPipeline } /* <- Note: [🤛] */);
|
|
7212
7229
|
return [3 /*break*/, 6];
|
|
7213
7230
|
case 4:
|
|
7214
|
-
|
|
7215
|
-
if (!(
|
|
7216
|
-
throw
|
|
7231
|
+
error_4 = _a.sent();
|
|
7232
|
+
if (!(error_4 instanceof Error)) {
|
|
7233
|
+
throw error_4;
|
|
7217
7234
|
}
|
|
7218
|
-
socket.emit('error', serializeError(
|
|
7235
|
+
socket.emit('error', serializeError(error_4));
|
|
7219
7236
|
return [3 /*break*/, 6];
|
|
7220
7237
|
case 5:
|
|
7221
7238
|
socket.disconnect();
|