@promptbook/remote-client 0.82.0-0 → 0.82.0-3
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 +390 -363
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/remote-client.index.d.ts +9 -3
- package/esm/typings/src/_packages/remote-server.index.d.ts +8 -2
- package/esm/typings/src/_packages/types.index.d.ts +16 -26
- package/esm/typings/src/collection/PipelineCollection.d.ts +2 -0
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +6 -3
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +3 -7
- package/esm/typings/src/other/templates/getBookTemplates.d.ts +5 -3
- package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +5 -2
- package/esm/typings/src/remote-server/createRemoteClient.d.ts +10 -0
- package/esm/typings/src/remote-server/{interfaces → socket-types/_common}/PromptbookServer_Error.d.ts +3 -3
- package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Progress.d.ts +10 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +49 -0
- package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +17 -0
- package/esm/typings/src/remote-server/{interfaces → socket-types/listModels}/PromptbookServer_ListModels_Response.d.ts +4 -2
- package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +17 -0
- package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Response.d.ts +12 -0
- package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +17 -0
- package/esm/typings/src/remote-server/{interfaces → socket-types/prompt}/PromptbookServer_Prompt_Response.d.ts +3 -3
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +3 -2
- package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +32 -0
- package/esm/typings/src/types/Arrayable.d.ts +1 -0
- package/esm/typings/src/types/NonEmptyArray.d.ts +8 -0
- package/package.json +2 -2
- package/umd/index.umd.js +393 -366
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/remote-server/interfaces/PromptbookServer_ListModels_Request.d.ts +0 -38
- package/esm/typings/src/remote-server/interfaces/PromptbookServer_Prompt_Progress.d.ts +0 -12
- package/esm/typings/src/remote-server/interfaces/PromptbookServer_Prompt_Request.d.ts +0 -45
- package/esm/typings/src/remote-server/interfaces/RemoteLlmExecutionToolsOptions.d.ts +0 -54
- /package/esm/typings/src/remote-server/{interfaces → types}/RemoteServerOptions.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
2
|
+
import { io } from 'socket.io-client';
|
|
2
3
|
import { SHA256 } from 'crypto-js';
|
|
3
4
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
4
5
|
import { unparse, parse } from 'papaparse';
|
|
5
6
|
import { basename } from 'path';
|
|
6
|
-
import { io } from 'socket.io-client';
|
|
7
7
|
|
|
8
8
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
9
9
|
/**
|
|
@@ -19,7 +19,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
19
19
|
* @generated
|
|
20
20
|
* @see https://github.com/webgptorg/promptbook
|
|
21
21
|
*/
|
|
22
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
22
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.82.0-2';
|
|
23
23
|
/**
|
|
24
24
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
25
25
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -145,24 +145,155 @@ function __spreadArray(to, from, pack) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
148
|
+
* This error indicates problems parsing the format value
|
|
149
149
|
*
|
|
150
|
-
*
|
|
150
|
+
* For example, when the format value is not a valid JSON or CSV
|
|
151
|
+
* This is not thrown directly but in extended classes
|
|
151
152
|
*
|
|
152
|
-
*
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
* @public exported from `@promptbook/core`
|
|
154
|
+
*/
|
|
155
|
+
var AbstractFormatError = /** @class */ (function (_super) {
|
|
156
|
+
__extends(AbstractFormatError, _super);
|
|
157
|
+
// Note: To allow instanceof do not put here error `name`
|
|
158
|
+
// public readonly name = 'AbstractFormatError';
|
|
159
|
+
function AbstractFormatError(message) {
|
|
160
|
+
var _this = _super.call(this, message) || this;
|
|
161
|
+
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
162
|
+
return _this;
|
|
163
|
+
}
|
|
164
|
+
return AbstractFormatError;
|
|
165
|
+
}(Error));
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* This error indicates problem with parsing of CSV
|
|
155
169
|
*
|
|
156
|
-
* @public exported from `@promptbook/
|
|
170
|
+
* @public exported from `@promptbook/core`
|
|
157
171
|
*/
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
172
|
+
var CsvFormatError = /** @class */ (function (_super) {
|
|
173
|
+
__extends(CsvFormatError, _super);
|
|
174
|
+
function CsvFormatError(message) {
|
|
175
|
+
var _this = _super.call(this, message) || this;
|
|
176
|
+
_this.name = 'CsvFormatError';
|
|
177
|
+
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
178
|
+
return _this;
|
|
179
|
+
}
|
|
180
|
+
return CsvFormatError;
|
|
181
|
+
}(AbstractFormatError));
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
185
|
+
*
|
|
186
|
+
* @public exported from `@promptbook/core`
|
|
187
|
+
*/
|
|
188
|
+
var CollectionError = /** @class */ (function (_super) {
|
|
189
|
+
__extends(CollectionError, _super);
|
|
190
|
+
function CollectionError(message) {
|
|
191
|
+
var _this = _super.call(this, message) || this;
|
|
192
|
+
_this.name = 'CollectionError';
|
|
193
|
+
Object.setPrototypeOf(_this, CollectionError.prototype);
|
|
194
|
+
return _this;
|
|
195
|
+
}
|
|
196
|
+
return CollectionError;
|
|
197
|
+
}(Error));
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
201
|
+
*
|
|
202
|
+
* @public exported from `@promptbook/core`
|
|
203
|
+
*/
|
|
204
|
+
var EnvironmentMismatchError = /** @class */ (function (_super) {
|
|
205
|
+
__extends(EnvironmentMismatchError, _super);
|
|
206
|
+
function EnvironmentMismatchError(message) {
|
|
207
|
+
var _this = _super.call(this, message) || this;
|
|
208
|
+
_this.name = 'EnvironmentMismatchError';
|
|
209
|
+
Object.setPrototypeOf(_this, EnvironmentMismatchError.prototype);
|
|
210
|
+
return _this;
|
|
211
|
+
}
|
|
212
|
+
return EnvironmentMismatchError;
|
|
213
|
+
}(Error));
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
217
|
+
*
|
|
218
|
+
* @public exported from `@promptbook/core`
|
|
219
|
+
* Note: Do not throw this error, its reserved for `checkExpectations` and `createPipelineExecutor` and public ONLY to be serializable through remote server
|
|
220
|
+
* Note: Always thrown in `checkExpectations` and catched in `createPipelineExecutor` and rethrown as `PipelineExecutionError`
|
|
221
|
+
* Note: This is a kindof subtype of PipelineExecutionError
|
|
222
|
+
*/
|
|
223
|
+
var ExpectError = /** @class */ (function (_super) {
|
|
224
|
+
__extends(ExpectError, _super);
|
|
225
|
+
function ExpectError(message) {
|
|
226
|
+
var _this = _super.call(this, message) || this;
|
|
227
|
+
_this.name = 'ExpectError';
|
|
228
|
+
Object.setPrototypeOf(_this, ExpectError.prototype);
|
|
229
|
+
return _this;
|
|
230
|
+
}
|
|
231
|
+
return ExpectError;
|
|
232
|
+
}(Error));
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* This error indicates that the promptbook can not retrieve knowledge from external sources
|
|
236
|
+
*
|
|
237
|
+
* @public exported from `@promptbook/core`
|
|
238
|
+
*/
|
|
239
|
+
var KnowledgeScrapeError = /** @class */ (function (_super) {
|
|
240
|
+
__extends(KnowledgeScrapeError, _super);
|
|
241
|
+
function KnowledgeScrapeError(message) {
|
|
242
|
+
var _this = _super.call(this, message) || this;
|
|
243
|
+
_this.name = 'KnowledgeScrapeError';
|
|
244
|
+
Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
|
|
245
|
+
return _this;
|
|
246
|
+
}
|
|
247
|
+
return KnowledgeScrapeError;
|
|
248
|
+
}(Error));
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* This error type indicates that some limit was reached
|
|
252
|
+
*
|
|
253
|
+
* @public exported from `@promptbook/core`
|
|
254
|
+
*/
|
|
255
|
+
var LimitReachedError = /** @class */ (function (_super) {
|
|
256
|
+
__extends(LimitReachedError, _super);
|
|
257
|
+
function LimitReachedError(message) {
|
|
258
|
+
var _this = _super.call(this, message) || this;
|
|
259
|
+
_this.name = 'LimitReachedError';
|
|
260
|
+
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
261
|
+
return _this;
|
|
262
|
+
}
|
|
263
|
+
return LimitReachedError;
|
|
264
|
+
}(Error));
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
268
|
+
*
|
|
269
|
+
* @public exported from `@promptbook/core`
|
|
270
|
+
*/
|
|
271
|
+
var MissingToolsError = /** @class */ (function (_super) {
|
|
272
|
+
__extends(MissingToolsError, _super);
|
|
273
|
+
function MissingToolsError(message) {
|
|
274
|
+
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: You have probbably forgot to provide some tools for pipeline execution or preparation\n\n "); })) || this;
|
|
275
|
+
_this.name = 'MissingToolsError';
|
|
276
|
+
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
277
|
+
return _this;
|
|
278
|
+
}
|
|
279
|
+
return MissingToolsError;
|
|
280
|
+
}(Error));
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* This error indicates that promptbook not found in the collection
|
|
284
|
+
*
|
|
285
|
+
* @public exported from `@promptbook/core`
|
|
286
|
+
*/
|
|
287
|
+
var NotFoundError = /** @class */ (function (_super) {
|
|
288
|
+
__extends(NotFoundError, _super);
|
|
289
|
+
function NotFoundError(message) {
|
|
290
|
+
var _this = _super.call(this, message) || this;
|
|
291
|
+
_this.name = 'NotFoundError';
|
|
292
|
+
Object.setPrototypeOf(_this, NotFoundError.prototype);
|
|
293
|
+
return _this;
|
|
294
|
+
}
|
|
295
|
+
return NotFoundError;
|
|
296
|
+
}(Error));
|
|
166
297
|
|
|
167
298
|
/**
|
|
168
299
|
* This error type indicates that some part of the code is not implemented yet
|
|
@@ -199,6 +330,54 @@ var ParseError = /** @class */ (function (_super) {
|
|
|
199
330
|
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
200
331
|
*/
|
|
201
332
|
|
|
333
|
+
/**
|
|
334
|
+
* This error indicates errors during the execution of the pipeline
|
|
335
|
+
*
|
|
336
|
+
* @public exported from `@promptbook/core`
|
|
337
|
+
*/
|
|
338
|
+
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
339
|
+
__extends(PipelineExecutionError, _super);
|
|
340
|
+
function PipelineExecutionError(message) {
|
|
341
|
+
var _this = _super.call(this, message) || this;
|
|
342
|
+
_this.name = 'PipelineExecutionError';
|
|
343
|
+
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
344
|
+
return _this;
|
|
345
|
+
}
|
|
346
|
+
return PipelineExecutionError;
|
|
347
|
+
}(Error));
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
|
|
351
|
+
*
|
|
352
|
+
* @public exported from `@promptbook/core`
|
|
353
|
+
*/
|
|
354
|
+
var PipelineLogicError = /** @class */ (function (_super) {
|
|
355
|
+
__extends(PipelineLogicError, _super);
|
|
356
|
+
function PipelineLogicError(message) {
|
|
357
|
+
var _this = _super.call(this, message) || this;
|
|
358
|
+
_this.name = 'PipelineLogicError';
|
|
359
|
+
Object.setPrototypeOf(_this, PipelineLogicError.prototype);
|
|
360
|
+
return _this;
|
|
361
|
+
}
|
|
362
|
+
return PipelineLogicError;
|
|
363
|
+
}(Error));
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* This error indicates errors in referencing promptbooks between each other
|
|
367
|
+
*
|
|
368
|
+
* @public exported from `@promptbook/core`
|
|
369
|
+
*/
|
|
370
|
+
var PipelineUrlError = /** @class */ (function (_super) {
|
|
371
|
+
__extends(PipelineUrlError, _super);
|
|
372
|
+
function PipelineUrlError(message) {
|
|
373
|
+
var _this = _super.call(this, message) || this;
|
|
374
|
+
_this.name = 'PipelineUrlError';
|
|
375
|
+
Object.setPrototypeOf(_this, PipelineUrlError.prototype);
|
|
376
|
+
return _this;
|
|
377
|
+
}
|
|
378
|
+
return PipelineUrlError;
|
|
379
|
+
}(Error));
|
|
380
|
+
|
|
202
381
|
/**
|
|
203
382
|
* Returns the same value that is passed as argument.
|
|
204
383
|
* No side effects.
|
|
@@ -245,6 +424,12 @@ var ADMIN_GITHUB_NAME = 'hejny';
|
|
|
245
424
|
* @public exported from `@promptbook/core`
|
|
246
425
|
*/
|
|
247
426
|
var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
|
|
427
|
+
/**
|
|
428
|
+
* When the title of task is not provided, the default title is used
|
|
429
|
+
*
|
|
430
|
+
* @public exported from `@promptbook/core`
|
|
431
|
+
*/
|
|
432
|
+
var DEFAULT_TASK_TITLE = "Task";
|
|
248
433
|
/**
|
|
249
434
|
* Timeout for the connections in milliseconds
|
|
250
435
|
*
|
|
@@ -309,6 +494,161 @@ var UnexpectedError = /** @class */ (function (_super) {
|
|
|
309
494
|
return UnexpectedError;
|
|
310
495
|
}(Error));
|
|
311
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Index of all custom errors
|
|
499
|
+
*
|
|
500
|
+
* @public exported from `@promptbook/core`
|
|
501
|
+
*/
|
|
502
|
+
var PROMPTBOOK_ERRORS = {
|
|
503
|
+
AbstractFormatError: AbstractFormatError,
|
|
504
|
+
CsvFormatError: CsvFormatError,
|
|
505
|
+
CollectionError: CollectionError,
|
|
506
|
+
EnvironmentMismatchError: EnvironmentMismatchError,
|
|
507
|
+
ExpectError: ExpectError,
|
|
508
|
+
KnowledgeScrapeError: KnowledgeScrapeError,
|
|
509
|
+
LimitReachedError: LimitReachedError,
|
|
510
|
+
MissingToolsError: MissingToolsError,
|
|
511
|
+
NotFoundError: NotFoundError,
|
|
512
|
+
NotYetImplementedError: NotYetImplementedError,
|
|
513
|
+
ParseError: ParseError,
|
|
514
|
+
PipelineExecutionError: PipelineExecutionError,
|
|
515
|
+
PipelineLogicError: PipelineLogicError,
|
|
516
|
+
PipelineUrlError: PipelineUrlError,
|
|
517
|
+
UnexpectedError: UnexpectedError,
|
|
518
|
+
// TODO: [🪑]> VersionMismatchError,
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* Index of all javascript errors
|
|
522
|
+
*
|
|
523
|
+
* @private for internal usage
|
|
524
|
+
*/
|
|
525
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
526
|
+
Error: Error,
|
|
527
|
+
EvalError: EvalError,
|
|
528
|
+
RangeError: RangeError,
|
|
529
|
+
ReferenceError: ReferenceError,
|
|
530
|
+
SyntaxError: SyntaxError,
|
|
531
|
+
TypeError: TypeError,
|
|
532
|
+
URIError: URIError,
|
|
533
|
+
AggregateError: AggregateError,
|
|
534
|
+
/*
|
|
535
|
+
Note: Not widely supported
|
|
536
|
+
> InternalError,
|
|
537
|
+
> ModuleError,
|
|
538
|
+
> HeapError,
|
|
539
|
+
> WebAssemblyCompileError,
|
|
540
|
+
> WebAssemblyRuntimeError,
|
|
541
|
+
*/
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* Index of all errors
|
|
545
|
+
*
|
|
546
|
+
* @private for internal usage
|
|
547
|
+
*/
|
|
548
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
549
|
+
/**
|
|
550
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
551
|
+
*/
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Deserializes the error object
|
|
555
|
+
*
|
|
556
|
+
* @public exported from `@promptbook/utils`
|
|
557
|
+
*/
|
|
558
|
+
function deserializeError(error) {
|
|
559
|
+
var name = error.name, stack = error.stack;
|
|
560
|
+
var message = error.message;
|
|
561
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
562
|
+
if (ErrorClass === undefined) {
|
|
563
|
+
ErrorClass = Error;
|
|
564
|
+
message = "".concat(name, ": ").concat(message);
|
|
565
|
+
}
|
|
566
|
+
if (stack !== undefined && stack !== '') {
|
|
567
|
+
message = spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Original stack trace:\n ").concat(block(stack || ''), "\n "); });
|
|
568
|
+
}
|
|
569
|
+
return new ErrorClass(message);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Creates a connection to the remote proxy server.
|
|
574
|
+
*
|
|
575
|
+
* Note: This function creates a connection to the remote server and returns a socket but responsibility of closing the connection is on the caller
|
|
576
|
+
*
|
|
577
|
+
* @private internal utility function
|
|
578
|
+
*/
|
|
579
|
+
function createRemoteClient(options) {
|
|
580
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
581
|
+
var remoteUrl, path;
|
|
582
|
+
return __generator(this, function (_a) {
|
|
583
|
+
remoteUrl = options.remoteUrl, path = options.path;
|
|
584
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
585
|
+
var socket = io(remoteUrl, {
|
|
586
|
+
retries: CONNECTION_RETRIES_LIMIT,
|
|
587
|
+
timeout: CONNECTION_TIMEOUT_MS,
|
|
588
|
+
path: path,
|
|
589
|
+
// path: `${this.remoteUrl.pathname}/socket.io`,
|
|
590
|
+
transports: [/*'websocket', <- TODO: [🌬] Make websocket transport work */ 'polling'],
|
|
591
|
+
});
|
|
592
|
+
// console.log('Connecting to', this.options.remoteUrl.href, { socket });
|
|
593
|
+
socket.on('connect', function () {
|
|
594
|
+
resolve(socket);
|
|
595
|
+
});
|
|
596
|
+
// TODO: [💩] Better timeout handling
|
|
597
|
+
setTimeout(function () {
|
|
598
|
+
reject(new Error("Timeout while connecting to ".concat(remoteUrl)));
|
|
599
|
+
}, CONNECTION_TIMEOUT_MS);
|
|
600
|
+
})];
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Prepare pipeline on remote server
|
|
607
|
+
*
|
|
608
|
+
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
609
|
+
*
|
|
610
|
+
* Note: This function does not validate logic of the pipeline
|
|
611
|
+
* Note: This function acts as part of compilation process
|
|
612
|
+
* Note: When the pipeline is already prepared, it returns the same pipeline
|
|
613
|
+
*
|
|
614
|
+
* @public exported from `@promptbook/remote-client`
|
|
615
|
+
*/
|
|
616
|
+
function preparePipelineOnRemoteServer(pipeline, options) {
|
|
617
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
618
|
+
var socket, preparedPipeline;
|
|
619
|
+
return __generator(this, function (_a) {
|
|
620
|
+
switch (_a.label) {
|
|
621
|
+
case 0:
|
|
622
|
+
return [4 /*yield*/, createRemoteClient(options)];
|
|
623
|
+
case 1:
|
|
624
|
+
socket = _a.sent();
|
|
625
|
+
socket.emit('preparePipeline-request', {
|
|
626
|
+
identification: options.identification,
|
|
627
|
+
pipeline: pipeline,
|
|
628
|
+
} /* <- Note: [🤛] */);
|
|
629
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
630
|
+
socket.on('preparePipeline-response', function (response) {
|
|
631
|
+
resolve(response.preparedPipeline);
|
|
632
|
+
socket.disconnect();
|
|
633
|
+
});
|
|
634
|
+
socket.on('error', function (error) {
|
|
635
|
+
reject(deserializeError(error));
|
|
636
|
+
socket.disconnect();
|
|
637
|
+
});
|
|
638
|
+
})];
|
|
639
|
+
case 2:
|
|
640
|
+
preparedPipeline = _a.sent();
|
|
641
|
+
socket.disconnect();
|
|
642
|
+
// TODO: !!!!!! do $exportJson
|
|
643
|
+
return [2 /*return*/, preparedPipeline];
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* TODO: !!!! Do not return Promise<PipelineJson> But PreparePipelineTask
|
|
650
|
+
*/
|
|
651
|
+
|
|
312
652
|
/**
|
|
313
653
|
* All available task types
|
|
314
654
|
*
|
|
@@ -1459,61 +1799,25 @@ var expectCommandParser = {
|
|
|
1459
1799
|
throw new ParseError("Already defined maximum ".concat($taskJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1460
1800
|
}
|
|
1461
1801
|
$taskJson.expectations[unit].max = command.amount;
|
|
1462
|
-
}
|
|
1463
|
-
},
|
|
1464
|
-
/**
|
|
1465
|
-
* Converts the FORMAT command back to string
|
|
1466
|
-
*
|
|
1467
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
1468
|
-
*/
|
|
1469
|
-
stringify: function (command) {
|
|
1470
|
-
return "---"; // <- TODO: [🛋] Implement
|
|
1471
|
-
},
|
|
1472
|
-
/**
|
|
1473
|
-
* Reads the FORMAT command from the `TaskJson`
|
|
1474
|
-
*
|
|
1475
|
-
* Note: This is used in `pipelineJsonToString` utility
|
|
1476
|
-
*/
|
|
1477
|
-
takeFromTaskJson: function ($taskJson) {
|
|
1478
|
-
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
1479
|
-
},
|
|
1480
|
-
};
|
|
1481
|
-
|
|
1482
|
-
/**
|
|
1483
|
-
* This error indicates problems parsing the format value
|
|
1484
|
-
*
|
|
1485
|
-
* For example, when the format value is not a valid JSON or CSV
|
|
1486
|
-
* This is not thrown directly but in extended classes
|
|
1487
|
-
*
|
|
1488
|
-
* @public exported from `@promptbook/core`
|
|
1489
|
-
*/
|
|
1490
|
-
var AbstractFormatError = /** @class */ (function (_super) {
|
|
1491
|
-
__extends(AbstractFormatError, _super);
|
|
1492
|
-
// Note: To allow instanceof do not put here error `name`
|
|
1493
|
-
// public readonly name = 'AbstractFormatError';
|
|
1494
|
-
function AbstractFormatError(message) {
|
|
1495
|
-
var _this = _super.call(this, message) || this;
|
|
1496
|
-
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
1497
|
-
return _this;
|
|
1498
|
-
}
|
|
1499
|
-
return AbstractFormatError;
|
|
1500
|
-
}(Error));
|
|
1501
|
-
|
|
1502
|
-
/**
|
|
1503
|
-
* This error indicates problem with parsing of CSV
|
|
1504
|
-
*
|
|
1505
|
-
* @public exported from `@promptbook/core`
|
|
1506
|
-
*/
|
|
1507
|
-
var CsvFormatError = /** @class */ (function (_super) {
|
|
1508
|
-
__extends(CsvFormatError, _super);
|
|
1509
|
-
function CsvFormatError(message) {
|
|
1510
|
-
var _this = _super.call(this, message) || this;
|
|
1511
|
-
_this.name = 'CsvFormatError';
|
|
1512
|
-
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
1513
|
-
return _this;
|
|
1514
|
-
}
|
|
1515
|
-
return CsvFormatError;
|
|
1516
|
-
}(AbstractFormatError));
|
|
1802
|
+
}
|
|
1803
|
+
},
|
|
1804
|
+
/**
|
|
1805
|
+
* Converts the FORMAT command back to string
|
|
1806
|
+
*
|
|
1807
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
1808
|
+
*/
|
|
1809
|
+
stringify: function (command) {
|
|
1810
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
1811
|
+
},
|
|
1812
|
+
/**
|
|
1813
|
+
* Reads the FORMAT command from the `TaskJson`
|
|
1814
|
+
*
|
|
1815
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
1816
|
+
*/
|
|
1817
|
+
takeFromTaskJson: function ($taskJson) {
|
|
1818
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
1819
|
+
},
|
|
1820
|
+
};
|
|
1517
1821
|
|
|
1518
1822
|
/**
|
|
1519
1823
|
* @@@
|
|
@@ -4965,8 +5269,8 @@ function parsePipeline(pipelineString) {
|
|
|
4965
5269
|
isSectionTypeSet: false,
|
|
4966
5270
|
isTask: true,
|
|
4967
5271
|
taskType: undefined /* <- Note: [🍙] Putting here placeholder to keep `taskType` on top at final JSON */,
|
|
4968
|
-
name: getUniqueSectionName(section.title),
|
|
4969
|
-
title: section.title,
|
|
5272
|
+
name: getUniqueSectionName(section.title || DEFAULT_TASK_TITLE),
|
|
5273
|
+
title: section.title || DEFAULT_TASK_TITLE,
|
|
4970
5274
|
description: description_1,
|
|
4971
5275
|
content: content,
|
|
4972
5276
|
// <- TODO: [🍙] Some standard order of properties
|
|
@@ -5234,7 +5538,7 @@ function parsePipeline(pipelineString) {
|
|
|
5234
5538
|
* Note: This function acts as compilation process
|
|
5235
5539
|
*
|
|
5236
5540
|
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
5237
|
-
* @param options -
|
|
5541
|
+
* @param options - Configuration of the remote server
|
|
5238
5542
|
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
5239
5543
|
* @throws {ParseError} if the promptbook string is not valid
|
|
5240
5544
|
* @public exported from `@promptbook/remote-client`
|
|
@@ -5246,7 +5550,7 @@ function compilePipelineOnRemoteServer(pipelineString, options) {
|
|
|
5246
5550
|
switch (_a.label) {
|
|
5247
5551
|
case 0:
|
|
5248
5552
|
pipelineJson = parsePipeline(pipelineString);
|
|
5249
|
-
return [4 /*yield*/, preparePipelineOnRemoteServer(pipelineJson)];
|
|
5553
|
+
return [4 /*yield*/, preparePipelineOnRemoteServer(pipelineJson, options)];
|
|
5250
5554
|
case 1:
|
|
5251
5555
|
pipelineJson = _a.sent();
|
|
5252
5556
|
// Note: No need to use `$exportJson` because `parsePipeline` and `preparePipeline` already do that
|
|
@@ -5255,238 +5559,9 @@ function compilePipelineOnRemoteServer(pipelineString, options) {
|
|
|
5255
5559
|
});
|
|
5256
5560
|
});
|
|
5257
5561
|
}
|
|
5258
|
-
|
|
5259
|
-
/**
|
|
5260
|
-
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
5261
|
-
*
|
|
5262
|
-
* @public exported from `@promptbook/core`
|
|
5263
|
-
*/
|
|
5264
|
-
var CollectionError = /** @class */ (function (_super) {
|
|
5265
|
-
__extends(CollectionError, _super);
|
|
5266
|
-
function CollectionError(message) {
|
|
5267
|
-
var _this = _super.call(this, message) || this;
|
|
5268
|
-
_this.name = 'CollectionError';
|
|
5269
|
-
Object.setPrototypeOf(_this, CollectionError.prototype);
|
|
5270
|
-
return _this;
|
|
5271
|
-
}
|
|
5272
|
-
return CollectionError;
|
|
5273
|
-
}(Error));
|
|
5274
|
-
|
|
5275
|
-
/**
|
|
5276
|
-
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
5277
|
-
*
|
|
5278
|
-
* @public exported from `@promptbook/core`
|
|
5279
|
-
*/
|
|
5280
|
-
var EnvironmentMismatchError = /** @class */ (function (_super) {
|
|
5281
|
-
__extends(EnvironmentMismatchError, _super);
|
|
5282
|
-
function EnvironmentMismatchError(message) {
|
|
5283
|
-
var _this = _super.call(this, message) || this;
|
|
5284
|
-
_this.name = 'EnvironmentMismatchError';
|
|
5285
|
-
Object.setPrototypeOf(_this, EnvironmentMismatchError.prototype);
|
|
5286
|
-
return _this;
|
|
5287
|
-
}
|
|
5288
|
-
return EnvironmentMismatchError;
|
|
5289
|
-
}(Error));
|
|
5290
|
-
|
|
5291
|
-
/**
|
|
5292
|
-
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
5293
|
-
*
|
|
5294
|
-
* @public exported from `@promptbook/core`
|
|
5295
|
-
* Note: Do not throw this error, its reserved for `checkExpectations` and `createPipelineExecutor` and public ONLY to be serializable through remote server
|
|
5296
|
-
* Note: Always thrown in `checkExpectations` and catched in `createPipelineExecutor` and rethrown as `PipelineExecutionError`
|
|
5297
|
-
* Note: This is a kindof subtype of PipelineExecutionError
|
|
5298
|
-
*/
|
|
5299
|
-
var ExpectError = /** @class */ (function (_super) {
|
|
5300
|
-
__extends(ExpectError, _super);
|
|
5301
|
-
function ExpectError(message) {
|
|
5302
|
-
var _this = _super.call(this, message) || this;
|
|
5303
|
-
_this.name = 'ExpectError';
|
|
5304
|
-
Object.setPrototypeOf(_this, ExpectError.prototype);
|
|
5305
|
-
return _this;
|
|
5306
|
-
}
|
|
5307
|
-
return ExpectError;
|
|
5308
|
-
}(Error));
|
|
5309
|
-
|
|
5310
|
-
/**
|
|
5311
|
-
* This error indicates that the promptbook can not retrieve knowledge from external sources
|
|
5312
|
-
*
|
|
5313
|
-
* @public exported from `@promptbook/core`
|
|
5314
|
-
*/
|
|
5315
|
-
var KnowledgeScrapeError = /** @class */ (function (_super) {
|
|
5316
|
-
__extends(KnowledgeScrapeError, _super);
|
|
5317
|
-
function KnowledgeScrapeError(message) {
|
|
5318
|
-
var _this = _super.call(this, message) || this;
|
|
5319
|
-
_this.name = 'KnowledgeScrapeError';
|
|
5320
|
-
Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
|
|
5321
|
-
return _this;
|
|
5322
|
-
}
|
|
5323
|
-
return KnowledgeScrapeError;
|
|
5324
|
-
}(Error));
|
|
5325
|
-
|
|
5326
|
-
/**
|
|
5327
|
-
* This error type indicates that some limit was reached
|
|
5328
|
-
*
|
|
5329
|
-
* @public exported from `@promptbook/core`
|
|
5330
|
-
*/
|
|
5331
|
-
var LimitReachedError = /** @class */ (function (_super) {
|
|
5332
|
-
__extends(LimitReachedError, _super);
|
|
5333
|
-
function LimitReachedError(message) {
|
|
5334
|
-
var _this = _super.call(this, message) || this;
|
|
5335
|
-
_this.name = 'LimitReachedError';
|
|
5336
|
-
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
5337
|
-
return _this;
|
|
5338
|
-
}
|
|
5339
|
-
return LimitReachedError;
|
|
5340
|
-
}(Error));
|
|
5341
|
-
|
|
5342
|
-
/**
|
|
5343
|
-
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
5344
|
-
*
|
|
5345
|
-
* @public exported from `@promptbook/core`
|
|
5346
|
-
*/
|
|
5347
|
-
var MissingToolsError = /** @class */ (function (_super) {
|
|
5348
|
-
__extends(MissingToolsError, _super);
|
|
5349
|
-
function MissingToolsError(message) {
|
|
5350
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: You have probbably forgot to provide some tools for pipeline execution or preparation\n\n "); })) || this;
|
|
5351
|
-
_this.name = 'MissingToolsError';
|
|
5352
|
-
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
5353
|
-
return _this;
|
|
5354
|
-
}
|
|
5355
|
-
return MissingToolsError;
|
|
5356
|
-
}(Error));
|
|
5357
|
-
|
|
5358
|
-
/**
|
|
5359
|
-
* This error indicates that promptbook not found in the collection
|
|
5360
|
-
*
|
|
5361
|
-
* @public exported from `@promptbook/core`
|
|
5362
|
-
*/
|
|
5363
|
-
var NotFoundError = /** @class */ (function (_super) {
|
|
5364
|
-
__extends(NotFoundError, _super);
|
|
5365
|
-
function NotFoundError(message) {
|
|
5366
|
-
var _this = _super.call(this, message) || this;
|
|
5367
|
-
_this.name = 'NotFoundError';
|
|
5368
|
-
Object.setPrototypeOf(_this, NotFoundError.prototype);
|
|
5369
|
-
return _this;
|
|
5370
|
-
}
|
|
5371
|
-
return NotFoundError;
|
|
5372
|
-
}(Error));
|
|
5373
|
-
|
|
5374
|
-
/**
|
|
5375
|
-
* This error indicates errors during the execution of the pipeline
|
|
5376
|
-
*
|
|
5377
|
-
* @public exported from `@promptbook/core`
|
|
5378
|
-
*/
|
|
5379
|
-
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
5380
|
-
__extends(PipelineExecutionError, _super);
|
|
5381
|
-
function PipelineExecutionError(message) {
|
|
5382
|
-
var _this = _super.call(this, message) || this;
|
|
5383
|
-
_this.name = 'PipelineExecutionError';
|
|
5384
|
-
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
5385
|
-
return _this;
|
|
5386
|
-
}
|
|
5387
|
-
return PipelineExecutionError;
|
|
5388
|
-
}(Error));
|
|
5389
|
-
|
|
5390
|
-
/**
|
|
5391
|
-
* This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
|
|
5392
|
-
*
|
|
5393
|
-
* @public exported from `@promptbook/core`
|
|
5394
|
-
*/
|
|
5395
|
-
var PipelineLogicError = /** @class */ (function (_super) {
|
|
5396
|
-
__extends(PipelineLogicError, _super);
|
|
5397
|
-
function PipelineLogicError(message) {
|
|
5398
|
-
var _this = _super.call(this, message) || this;
|
|
5399
|
-
_this.name = 'PipelineLogicError';
|
|
5400
|
-
Object.setPrototypeOf(_this, PipelineLogicError.prototype);
|
|
5401
|
-
return _this;
|
|
5402
|
-
}
|
|
5403
|
-
return PipelineLogicError;
|
|
5404
|
-
}(Error));
|
|
5405
|
-
|
|
5406
|
-
/**
|
|
5407
|
-
* This error indicates errors in referencing promptbooks between each other
|
|
5408
|
-
*
|
|
5409
|
-
* @public exported from `@promptbook/core`
|
|
5410
|
-
*/
|
|
5411
|
-
var PipelineUrlError = /** @class */ (function (_super) {
|
|
5412
|
-
__extends(PipelineUrlError, _super);
|
|
5413
|
-
function PipelineUrlError(message) {
|
|
5414
|
-
var _this = _super.call(this, message) || this;
|
|
5415
|
-
_this.name = 'PipelineUrlError';
|
|
5416
|
-
Object.setPrototypeOf(_this, PipelineUrlError.prototype);
|
|
5417
|
-
return _this;
|
|
5418
|
-
}
|
|
5419
|
-
return PipelineUrlError;
|
|
5420
|
-
}(Error));
|
|
5421
|
-
|
|
5422
|
-
/**
|
|
5423
|
-
* Index of all custom errors
|
|
5424
|
-
*
|
|
5425
|
-
* @public exported from `@promptbook/core`
|
|
5426
|
-
*/
|
|
5427
|
-
var PROMPTBOOK_ERRORS = {
|
|
5428
|
-
AbstractFormatError: AbstractFormatError,
|
|
5429
|
-
CsvFormatError: CsvFormatError,
|
|
5430
|
-
CollectionError: CollectionError,
|
|
5431
|
-
EnvironmentMismatchError: EnvironmentMismatchError,
|
|
5432
|
-
ExpectError: ExpectError,
|
|
5433
|
-
KnowledgeScrapeError: KnowledgeScrapeError,
|
|
5434
|
-
LimitReachedError: LimitReachedError,
|
|
5435
|
-
MissingToolsError: MissingToolsError,
|
|
5436
|
-
NotFoundError: NotFoundError,
|
|
5437
|
-
NotYetImplementedError: NotYetImplementedError,
|
|
5438
|
-
ParseError: ParseError,
|
|
5439
|
-
PipelineExecutionError: PipelineExecutionError,
|
|
5440
|
-
PipelineLogicError: PipelineLogicError,
|
|
5441
|
-
PipelineUrlError: PipelineUrlError,
|
|
5442
|
-
UnexpectedError: UnexpectedError,
|
|
5443
|
-
// TODO: [🪑]> VersionMismatchError,
|
|
5444
|
-
};
|
|
5445
|
-
/**
|
|
5446
|
-
* Index of all javascript errors
|
|
5447
|
-
*
|
|
5448
|
-
* @private for internal usage
|
|
5449
|
-
*/
|
|
5450
|
-
var COMMON_JAVASCRIPT_ERRORS = {
|
|
5451
|
-
Error: Error,
|
|
5452
|
-
EvalError: EvalError,
|
|
5453
|
-
RangeError: RangeError,
|
|
5454
|
-
ReferenceError: ReferenceError,
|
|
5455
|
-
SyntaxError: SyntaxError,
|
|
5456
|
-
TypeError: TypeError,
|
|
5457
|
-
URIError: URIError,
|
|
5458
|
-
AggregateError: AggregateError,
|
|
5459
|
-
/*
|
|
5460
|
-
Note: Not widely supported
|
|
5461
|
-
> InternalError,
|
|
5462
|
-
> ModuleError,
|
|
5463
|
-
> HeapError,
|
|
5464
|
-
> WebAssemblyCompileError,
|
|
5465
|
-
> WebAssemblyRuntimeError,
|
|
5466
|
-
*/
|
|
5467
|
-
};
|
|
5468
|
-
/**
|
|
5469
|
-
* Index of all errors
|
|
5470
|
-
*
|
|
5471
|
-
* @private for internal usage
|
|
5472
|
-
*/
|
|
5473
|
-
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
5474
|
-
/**
|
|
5475
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5476
|
-
*/
|
|
5477
|
-
|
|
5478
5562
|
/**
|
|
5479
|
-
*
|
|
5480
|
-
*
|
|
5481
|
-
* @public exported from `@promptbook/utils`
|
|
5563
|
+
* TODO: !!!! Do not return Promise<PipelineJson> But PreparePipelineTask
|
|
5482
5564
|
*/
|
|
5483
|
-
function deserializeError(error) {
|
|
5484
|
-
var ErrorClass = ALL_ERRORS[error.name];
|
|
5485
|
-
if (ErrorClass === undefined) {
|
|
5486
|
-
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
5487
|
-
}
|
|
5488
|
-
return new ErrorClass(error.message);
|
|
5489
|
-
}
|
|
5490
5565
|
|
|
5491
5566
|
/**
|
|
5492
5567
|
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
@@ -5525,7 +5600,7 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
|
|
|
5525
5600
|
var socket;
|
|
5526
5601
|
return __generator(this, function (_a) {
|
|
5527
5602
|
switch (_a.label) {
|
|
5528
|
-
case 0: return [4 /*yield*/, this.
|
|
5603
|
+
case 0: return [4 /*yield*/, createRemoteClient(this.options)];
|
|
5529
5604
|
case 1:
|
|
5530
5605
|
socket = _a.sent();
|
|
5531
5606
|
socket.disconnect();
|
|
@@ -5542,24 +5617,12 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
|
|
|
5542
5617
|
var socket, promptResult;
|
|
5543
5618
|
return __generator(this, function (_a) {
|
|
5544
5619
|
switch (_a.label) {
|
|
5545
|
-
case 0: return [4 /*yield*/, this.
|
|
5620
|
+
case 0: return [4 /*yield*/, createRemoteClient(this.options)];
|
|
5546
5621
|
case 1:
|
|
5547
5622
|
socket = _a.sent();
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
userId: this.options.userId,
|
|
5552
|
-
llmToolsConfiguration: this.options.llmToolsConfiguration,
|
|
5553
|
-
} /* <- Note: [🤛] */);
|
|
5554
|
-
}
|
|
5555
|
-
else {
|
|
5556
|
-
socket.emit('listModels-request', {
|
|
5557
|
-
isAnonymous: false,
|
|
5558
|
-
appId: this.options.appId,
|
|
5559
|
-
userId: this.options.userId,
|
|
5560
|
-
customOptions: this.options.customOptions,
|
|
5561
|
-
} /* <- Note: [🤛] */);
|
|
5562
|
-
}
|
|
5623
|
+
socket.emit('listModels-request', {
|
|
5624
|
+
identification: this.options.identification,
|
|
5625
|
+
} /* <- Note: [🤛] */);
|
|
5563
5626
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
5564
5627
|
socket.on('listModels-response', function (response) {
|
|
5565
5628
|
resolve(response.models);
|
|
@@ -5578,29 +5641,6 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
|
|
|
5578
5641
|
});
|
|
5579
5642
|
});
|
|
5580
5643
|
};
|
|
5581
|
-
/**
|
|
5582
|
-
* Creates a connection to the remote proxy server.
|
|
5583
|
-
*/
|
|
5584
|
-
RemoteLlmExecutionTools.prototype.makeConnection = function () {
|
|
5585
|
-
var _this = this;
|
|
5586
|
-
return new Promise(function (resolve, reject) {
|
|
5587
|
-
var socket = io(_this.options.remoteUrl, {
|
|
5588
|
-
retries: CONNECTION_RETRIES_LIMIT,
|
|
5589
|
-
timeout: CONNECTION_TIMEOUT_MS,
|
|
5590
|
-
path: _this.options.path,
|
|
5591
|
-
// path: `${this.remoteUrl.pathname}/socket.io`,
|
|
5592
|
-
transports: [/*'websocket', <- TODO: [🌬] Make websocket transport work */ 'polling'],
|
|
5593
|
-
});
|
|
5594
|
-
// console.log('Connecting to', this.options.remoteUrl.href, { socket });
|
|
5595
|
-
socket.on('connect', function () {
|
|
5596
|
-
resolve(socket);
|
|
5597
|
-
});
|
|
5598
|
-
// TODO: [💩] Better timeout handling
|
|
5599
|
-
setTimeout(function () {
|
|
5600
|
-
reject(new Error("Timeout while connecting to ".concat(_this.options.remoteUrl)));
|
|
5601
|
-
}, CONNECTION_TIMEOUT_MS);
|
|
5602
|
-
});
|
|
5603
|
-
};
|
|
5604
5644
|
/**
|
|
5605
5645
|
* Calls remote proxy server to use a chat model
|
|
5606
5646
|
*/
|
|
@@ -5637,26 +5677,13 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
|
|
|
5637
5677
|
var socket, promptResult;
|
|
5638
5678
|
return __generator(this, function (_a) {
|
|
5639
5679
|
switch (_a.label) {
|
|
5640
|
-
case 0: return [4 /*yield*/, this.
|
|
5680
|
+
case 0: return [4 /*yield*/, createRemoteClient(this.options)];
|
|
5641
5681
|
case 1:
|
|
5642
5682
|
socket = _a.sent();
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
llmToolsConfiguration: this.options.llmToolsConfiguration,
|
|
5648
|
-
prompt: prompt,
|
|
5649
|
-
} /* <- Note: [🤛] */);
|
|
5650
|
-
}
|
|
5651
|
-
else {
|
|
5652
|
-
socket.emit('prompt-request', {
|
|
5653
|
-
isAnonymous: false,
|
|
5654
|
-
appId: this.options.appId,
|
|
5655
|
-
userId: this.options.userId,
|
|
5656
|
-
customOptions: this.options.customOptions,
|
|
5657
|
-
prompt: prompt,
|
|
5658
|
-
} /* <- Note: [🤛] */);
|
|
5659
|
-
}
|
|
5683
|
+
socket.emit('prompt-request', {
|
|
5684
|
+
identification: this.options.identification,
|
|
5685
|
+
prompt: prompt,
|
|
5686
|
+
} /* <- Note: [🤛] */);
|
|
5660
5687
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
5661
5688
|
socket.on('prompt-response', function (response) {
|
|
5662
5689
|
resolve(response.promptResult);
|