@promptbook/cli 0.85.0-2 → 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.
@@ -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: `execution-${task_id}`;
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: `preparation-${task_id}`;
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/cli",
3
- "version": "0.85.0-2",
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,
package/umd/index.umd.js CHANGED
@@ -53,7 +53,7 @@
53
53
  * @generated
54
54
  * @see https://github.com/webgptorg/promptbook
55
55
  */
56
- var PROMPTBOOK_ENGINE_VERSION = '0.85.0-1';
56
+ var PROMPTBOOK_ENGINE_VERSION = '0.85.0-3';
57
57
  /**
58
58
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
59
59
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4930,7 +4930,7 @@
4930
4930
  */
4931
4931
  function createTask(options) {
4932
4932
  var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
4933
- var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
4933
+ var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: !!! To global config + Use Base58 to avoid simmilar char conflicts */));
4934
4934
  var partialResultSubject = new rxjs.BehaviorSubject({});
4935
4935
  var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
4936
4936
  partialResultSubject.next(newOngoingResult);
@@ -4962,6 +4962,9 @@
4962
4962
  isCrashedOnError: true,
4963
4963
  })));
4964
4964
  },
4965
+ get currentValue() {
4966
+ return partialResultSubject.value;
4967
+ },
4965
4968
  };
4966
4969
  }
4967
4970
  /**
@@ -13868,27 +13871,29 @@
13868
13871
  app.get("".concat(rootPath, "/executions/:taskId"), function (request, response) { return __awaiter(_this, void 0, void 0, function () {
13869
13872
  var taskId, execution;
13870
13873
  return __generator(this, function (_a) {
13871
- taskId = request.query.taskId;
13874
+ taskId = request.params.taskId;
13872
13875
  execution = runningExecutionTasks.find(function (executionTask) { return executionTask.taskId === taskId; });
13873
13876
  if (execution === undefined) {
13874
13877
  response.status(404).send("Execution \"".concat(taskId, "\" not found"));
13875
13878
  return [2 /*return*/];
13876
13879
  }
13877
- response.send(execution);
13880
+ response.send(execution.currentValue);
13878
13881
  return [2 /*return*/];
13879
13882
  });
13880
13883
  }); });
13881
13884
  app.post("".concat(rootPath, "/executions/new"), function (request, response) { return __awaiter(_this, void 0, void 0, function () {
13882
- var inputParameters, pipelineUrl, pipeline, llm, fs, executables, tools, pipelineExecutor, executionTask;
13885
+ var inputParameters, pipelineUrl, pipeline, llm, fs, executables, tools, pipelineExecutor, executionTask, error_1;
13883
13886
  var _a;
13884
13887
  return __generator(this, function (_b) {
13885
13888
  switch (_b.label) {
13886
13889
  case 0:
13890
+ _b.trys.push([0, 5, , 6]);
13887
13891
  inputParameters = request.body.inputParameters;
13888
13892
  pipelineUrl = request.body.pipelineUrl || request.body.book;
13889
13893
  return [4 /*yield*/, (collection === null || collection === void 0 ? void 0 : collection.getPipelineByUrl(pipelineUrl))];
13890
13894
  case 1:
13891
13895
  pipeline = _b.sent();
13896
+ // <- TODO: !!!!!! NotFoundError
13892
13897
  if (pipeline === undefined) {
13893
13898
  response.status(404).send("Pipeline \"".concat(pipelineUrl, "\" not found"));
13894
13899
  return [2 /*return*/];
@@ -13916,7 +13921,19 @@
13916
13921
  executionTask = pipelineExecutor(inputParameters);
13917
13922
  runningExecutionTasks.push(executionTask);
13918
13923
  response.send(executionTask);
13919
- return [2 /*return*/];
13924
+ // TODO: !!!!!! Remove this:
13925
+ executionTask.asObservable().subscribe(function (_) {
13926
+ console.log('!!!', _);
13927
+ });
13928
+ return [3 /*break*/, 6];
13929
+ case 5:
13930
+ error_1 = _b.sent();
13931
+ if (!(error_1 instanceof Error)) {
13932
+ throw error_1;
13933
+ }
13934
+ response.status(400).send({ error: serializeError(error_1) });
13935
+ return [3 /*break*/, 6];
13936
+ case 6: return [2 /*return*/];
13920
13937
  }
13921
13938
  });
13922
13939
  }); });
@@ -13981,7 +13998,7 @@
13981
13998
  }); };
13982
13999
  // -----------
13983
14000
  socket.on('prompt-request', function (request) { return __awaiter(_this, void 0, void 0, function () {
13984
- var identification, prompt, executionTools, llm, _a, promptResult, _b, error_1;
14001
+ var identification, prompt, executionTools, llm, _a, promptResult, _b, error_2;
13985
14002
  return __generator(this, function (_c) {
13986
14003
  switch (_c.label) {
13987
14004
  case 0:
@@ -14050,11 +14067,11 @@
14050
14067
  socket.emit('prompt-response', { promptResult: promptResult } /* <- Note: [🤛] */);
14051
14068
  return [3 /*break*/, 15];
14052
14069
  case 13:
14053
- error_1 = _c.sent();
14054
- if (!(error_1 instanceof Error)) {
14055
- throw error_1;
14070
+ error_2 = _c.sent();
14071
+ if (!(error_2 instanceof Error)) {
14072
+ throw error_2;
14056
14073
  }
14057
- socket.emit('error', serializeError(error_1) /* <- Note: [🤛] */);
14074
+ socket.emit('error', serializeError(error_2) /* <- Note: [🤛] */);
14058
14075
  return [3 /*break*/, 15];
14059
14076
  case 14:
14060
14077
  socket.disconnect();
@@ -14066,7 +14083,7 @@
14066
14083
  // -----------
14067
14084
  // TODO: [👒] Listing models (and checking configuration) probbably should go through REST API not Socket.io
14068
14085
  socket.on('listModels-request', function (request) { return __awaiter(_this, void 0, void 0, function () {
14069
- var identification, executionTools, llm, models, error_2;
14086
+ var identification, executionTools, llm, models, error_3;
14070
14087
  return __generator(this, function (_a) {
14071
14088
  switch (_a.label) {
14072
14089
  case 0:
@@ -14087,11 +14104,11 @@
14087
14104
  socket.emit('listModels-response', { models: models } /* <- Note: [🤛] */);
14088
14105
  return [3 /*break*/, 6];
14089
14106
  case 4:
14090
- error_2 = _a.sent();
14091
- if (!(error_2 instanceof Error)) {
14092
- throw error_2;
14107
+ error_3 = _a.sent();
14108
+ if (!(error_3 instanceof Error)) {
14109
+ throw error_3;
14093
14110
  }
14094
- socket.emit('error', serializeError(error_2));
14111
+ socket.emit('error', serializeError(error_3));
14095
14112
  return [3 /*break*/, 6];
14096
14113
  case 5:
14097
14114
  socket.disconnect();
@@ -14103,7 +14120,7 @@
14103
14120
  // -----------
14104
14121
  // TODO: [👒] Listing models (and checking configuration) probbably should go through REST API not Socket.io
14105
14122
  socket.on('preparePipeline-request', function (request) { return __awaiter(_this, void 0, void 0, function () {
14106
- var identification, pipeline, executionTools, preparedPipeline, error_3;
14123
+ var identification, pipeline, executionTools, preparedPipeline, error_4;
14107
14124
  return __generator(this, function (_a) {
14108
14125
  switch (_a.label) {
14109
14126
  case 0:
@@ -14123,11 +14140,11 @@
14123
14140
  socket.emit('preparePipeline-response', { preparedPipeline: preparedPipeline } /* <- Note: [🤛] */);
14124
14141
  return [3 /*break*/, 6];
14125
14142
  case 4:
14126
- error_3 = _a.sent();
14127
- if (!(error_3 instanceof Error)) {
14128
- throw error_3;
14143
+ error_4 = _a.sent();
14144
+ if (!(error_4 instanceof Error)) {
14145
+ throw error_4;
14129
14146
  }
14130
- socket.emit('error', serializeError(error_3));
14147
+ socket.emit('error', serializeError(error_4));
14131
14148
  return [3 /*break*/, 6];
14132
14149
  case 5:
14133
14150
  socket.disconnect();