@promptbook/vercel 0.78.4 → 0.80.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.
Files changed (36) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +225 -143
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +4 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
  9. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -2
  10. package/esm/typings/src/config.d.ts +0 -25
  11. package/esm/typings/src/constants.d.ts +35 -0
  12. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  13. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  14. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +6 -1
  15. package/esm/typings/src/formfactors/index.d.ts +12 -2
  16. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +6 -1
  17. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
  18. package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
  19. package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
  20. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
  21. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  22. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  23. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
  24. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  25. package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
  26. package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
  27. package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
  28. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  29. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
  30. package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
  31. package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
  32. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
  33. package/package.json +2 -2
  34. package/umd/index.umd.js +225 -143
  35. package/umd/index.umd.js.map +1 -1
  36. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
package/README.md CHANGED
@@ -23,6 +23,10 @@
23
23
 
24
24
 
25
25
 
26
+ <blockquote style="color: #ff8811">
27
+ <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>.
28
+ </blockquote>
29
+
26
30
  ## 📦 Package `@promptbook/vercel`
27
31
 
28
32
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
package/esm/index.es.js CHANGED
@@ -13,7 +13,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
13
13
  *
14
14
  * @see https://github.com/webgptorg/promptbook
15
15
  */
16
- var PROMPTBOOK_ENGINE_VERSION = '0.78.3';
16
+ var PROMPTBOOK_ENGINE_VERSION = '0.79.0';
17
17
  /**
18
18
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
19
19
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -155,7 +155,7 @@ var PipelineExecutionError = /** @class */ (function (_super) {
155
155
  }(Error));
156
156
 
157
157
  /**
158
- * @@@
158
+ * Freezes the given object and all its nested objects recursively
159
159
  *
160
160
  * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
161
161
  * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
@@ -165,6 +165,9 @@ var PipelineExecutionError = /** @class */ (function (_super) {
165
165
  */
166
166
  function $deepFreeze(objectValue) {
167
167
  var e_1, _a;
168
+ if (Array.isArray(objectValue)) {
169
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
170
+ }
168
171
  var propertyNames = Object.getOwnPropertyNames(objectValue);
169
172
  try {
170
173
  for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
@@ -182,7 +185,8 @@ function $deepFreeze(objectValue) {
182
185
  }
183
186
  finally { if (e_1) throw e_1.error; }
184
187
  }
185
- return Object.freeze(objectValue);
188
+ Object.freeze(objectValue);
189
+ return objectValue;
186
190
  }
187
191
  /**
188
192
  * TODO: [🧠] Is there a way how to meaningfully test this utility
@@ -283,24 +287,6 @@ var ADMIN_GITHUB_NAME = 'hejny';
283
287
  * @private within the repository - too low-level in comparison with other `MAX_...`
284
288
  */
285
289
  var LOOP_LIMIT = 1000;
286
- /**
287
- * Nonce which is used for replacing things in strings
288
- *
289
- * @private within the repository
290
- */
291
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
292
- /**
293
- * @@@
294
- *
295
- * @private within the repository
296
- */
297
- var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
298
- /**
299
- * @@@
300
- *
301
- * @private within the repository
302
- */
303
- var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
304
290
  // <- TODO: [🧜‍♂️]
305
291
  /**
306
292
  * @@@
@@ -314,26 +300,21 @@ Object.freeze({
314
300
  skipEmptyLines: true,
315
301
  });
316
302
  /**
317
- * TODO: Extract `constants.ts` from `config.ts`
318
303
  * Note: [💞] Ignore a discrepancy between file name and entity name
319
304
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
320
305
  */
321
306
 
322
307
  /**
323
- * This error type indicates that some limit was reached
308
+ * Orders JSON object by keys
324
309
  *
325
- * @public exported from `@promptbook/core`
310
+ * @returns The same type of object as the input re-ordered
311
+ * @public exported from `@promptbook/utils`
326
312
  */
327
- var LimitReachedError = /** @class */ (function (_super) {
328
- __extends(LimitReachedError, _super);
329
- function LimitReachedError(message) {
330
- var _this = _super.call(this, message) || this;
331
- _this.name = 'LimitReachedError';
332
- Object.setPrototypeOf(_this, LimitReachedError.prototype);
333
- return _this;
334
- }
335
- return LimitReachedError;
336
- }(Error));
313
+ function orderJson(options) {
314
+ var value = options.value, order = options.order;
315
+ var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
316
+ return orderedValue;
317
+ }
337
318
 
338
319
  /**
339
320
  * Make error report URL for the given error
@@ -369,85 +350,6 @@ var UnexpectedError = /** @class */ (function (_super) {
369
350
  return UnexpectedError;
370
351
  }(Error));
371
352
 
372
- /**
373
- * Replaces parameters in template with values from parameters object
374
- *
375
- * @param template the template with parameters in {curly} braces
376
- * @param parameters the object with parameters
377
- * @returns the template with replaced parameters
378
- * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
379
- * @public exported from `@promptbook/utils`
380
- */
381
- function replaceParameters(template, parameters) {
382
- var e_1, _a;
383
- try {
384
- for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
385
- var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
386
- if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
387
- throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
388
- }
389
- else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
390
- // TODO: [🍵]
391
- throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
392
- }
393
- }
394
- }
395
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
396
- finally {
397
- try {
398
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
399
- }
400
- finally { if (e_1) throw e_1.error; }
401
- }
402
- var replacedTemplates = template;
403
- var match;
404
- var loopLimit = LOOP_LIMIT;
405
- var _loop_1 = function () {
406
- if (loopLimit-- < 0) {
407
- throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
408
- }
409
- var precol = match.groups.precol;
410
- var parameterName = match.groups.parameterName;
411
- if (parameterName === '') {
412
- return "continue";
413
- }
414
- if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
415
- throw new PipelineExecutionError('Parameter is already opened or not closed');
416
- }
417
- if (parameters[parameterName] === undefined) {
418
- throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
419
- }
420
- var parameterValue = parameters[parameterName];
421
- if (parameterValue === undefined) {
422
- throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
423
- }
424
- parameterValue = parameterValue.toString();
425
- if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
426
- parameterValue = parameterValue
427
- .split('\n')
428
- .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
429
- .join('\n');
430
- }
431
- replacedTemplates =
432
- replacedTemplates.substring(0, match.index + precol.length) +
433
- parameterValue +
434
- replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
435
- };
436
- while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
437
- .exec(replacedTemplates))) {
438
- _loop_1();
439
- }
440
- // [💫] Check if there are parameters that are not closed properly
441
- if (/{\w+$/.test(replacedTemplates)) {
442
- throw new PipelineExecutionError('Parameter is not closed');
443
- }
444
- // [💫] Check if there are parameters that are not opened properly
445
- if (/^\w+}/.test(replacedTemplates)) {
446
- throw new PipelineExecutionError('Parameter is not opened');
447
- }
448
- return replacedTemplates;
449
- }
450
-
451
353
  /**
452
354
  * Checks if the value is [🚉] serializable as JSON
453
355
  * If not, throws an UnexpectedError with a rich error message and tracking
@@ -468,8 +370,9 @@ function replaceParameters(template, parameters) {
468
370
  * @throws UnexpectedError if the value is not serializable as JSON
469
371
  * @public exported from `@promptbook/utils`
470
372
  */
471
- function checkSerializableAsJson(name, value) {
373
+ function checkSerializableAsJson(options) {
472
374
  var e_1, _a;
375
+ var value = options.value, name = options.name, message = options.message;
473
376
  if (value === undefined) {
474
377
  throw new UnexpectedError("".concat(name, " is undefined"));
475
378
  }
@@ -493,12 +396,12 @@ function checkSerializableAsJson(name, value) {
493
396
  }
494
397
  else if (typeof value === 'object' && Array.isArray(value)) {
495
398
  for (var i = 0; i < value.length; i++) {
496
- checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
399
+ checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
497
400
  }
498
401
  }
499
402
  else if (typeof value === 'object') {
500
403
  if (value instanceof Date) {
501
- throw new UnexpectedError(spaceTrim("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
404
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is Date\n\n Use `string_date_iso8601` instead\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
502
405
  }
503
406
  else if (value instanceof Map) {
504
407
  throw new UnexpectedError("".concat(name, " is Map"));
@@ -510,7 +413,7 @@ function checkSerializableAsJson(name, value) {
510
413
  throw new UnexpectedError("".concat(name, " is RegExp"));
511
414
  }
512
415
  else if (value instanceof Error) {
513
- throw new UnexpectedError(spaceTrim("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
416
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is unserialized Error\n\n Use function `serializeError`\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n\n "); }));
514
417
  }
515
418
  else {
516
419
  try {
@@ -520,7 +423,7 @@ function checkSerializableAsJson(name, value) {
520
423
  // Note: undefined in object is serializable - it is just omited
521
424
  continue;
522
425
  }
523
- checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
426
+ checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
524
427
  }
525
428
  }
526
429
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -537,7 +440,7 @@ function checkSerializableAsJson(name, value) {
537
440
  if (!(error instanceof Error)) {
538
441
  throw error;
539
442
  }
540
- throw new UnexpectedError(spaceTrim(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
443
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.toString()), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
541
444
  }
542
445
  /*
543
446
  TODO: [0] Is there some more elegant way to check circular references?
@@ -562,35 +465,210 @@ function checkSerializableAsJson(name, value) {
562
465
  }
563
466
  }
564
467
  else {
565
- throw new UnexpectedError("".concat(name, " is unknown"));
468
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
566
469
  }
567
470
  }
568
471
  /**
569
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
472
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
570
473
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
571
474
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
572
475
  */
573
476
 
574
477
  /**
575
- * @@@
576
478
  * @@@
577
479
  *
578
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
480
+ * @public exported from `@promptbook/utils`
481
+ */
482
+ function deepClone(objectValue) {
483
+ return JSON.parse(JSON.stringify(objectValue));
484
+ /*
485
+ !!!!!!!!
486
+ TODO: [🧠] Is there a better implementation?
487
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
488
+ > for (const propertyName of propertyNames) {
489
+ > const value = (objectValue as really_any)[propertyName];
490
+ > if (value && typeof value === 'object') {
491
+ > deepClone(value);
492
+ > }
493
+ > }
494
+ > return Object.assign({}, objectValue);
495
+ */
496
+ }
497
+ /**
498
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
499
+ */
500
+
501
+ /**
502
+ * Utility to export a JSON object from a function
579
503
  *
580
- * @param name - Name of the object for debugging purposes
581
- * @param objectValue - Object to be deeply frozen
582
- * @returns The same object as the input, but deeply frozen
583
- * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
504
+ * 1) Checks if the value is serializable as JSON
505
+ * 2) Makes a deep clone of the object
506
+ * 2) Orders the object properties
507
+ * 2) Deeply freezes the cloned object
508
+ *
509
+ * Note: This function does not mutates the given object
510
+ *
511
+ * @returns The same type of object as the input but read-only and re-ordered
512
+ * @public exported from `@promptbook/utils`
584
513
  */
585
- function $asDeeplyFrozenSerializableJson(name, objectValue) {
586
- checkSerializableAsJson(name, objectValue);
587
- return $deepFreeze(objectValue);
514
+ function exportJson(options) {
515
+ var name = options.name, value = options.value, order = options.order, message = options.message;
516
+ checkSerializableAsJson({ name: name, value: value, message: message });
517
+ var orderedValue =
518
+ // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
519
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
520
+ // @ts-ignore
521
+ order === undefined
522
+ ? deepClone(value)
523
+ : orderJson({
524
+ value: value,
525
+ // <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
526
+ order: order,
527
+ });
528
+ $deepFreeze(orderedValue);
529
+ return orderedValue;
588
530
  }
589
531
  /**
590
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
591
532
  * TODO: [🧠] Is there a way how to meaningfully test this utility
592
533
  */
593
534
 
535
+ /**
536
+ * Nonce which is used for replacing things in strings
537
+ *
538
+ * @private within the repository
539
+ */
540
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
541
+ /**
542
+ * @@@
543
+ *
544
+ * @private within the repository
545
+ */
546
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
547
+ /**
548
+ * @@@
549
+ *
550
+ * @private within the repository
551
+ */
552
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
553
+ /**
554
+ * The names of the parameters that are reserved for special purposes
555
+ *
556
+ * @public exported from `@promptbook/core`
557
+ */
558
+ exportJson({
559
+ name: 'RESERVED_PARAMETER_NAMES',
560
+ message: "The names of the parameters that are reserved for special purposes",
561
+ value: [
562
+ 'content',
563
+ 'context',
564
+ 'knowledge',
565
+ 'examples',
566
+ 'modelName',
567
+ 'currentDate',
568
+ // <- TODO: list here all command names
569
+ // <- TODO: Add more like 'date', 'modelName',...
570
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
571
+ ],
572
+ });
573
+ /**
574
+ * Note: [💞] Ignore a discrepancy between file name and entity name
575
+ */
576
+
577
+ /**
578
+ * This error type indicates that some limit was reached
579
+ *
580
+ * @public exported from `@promptbook/core`
581
+ */
582
+ var LimitReachedError = /** @class */ (function (_super) {
583
+ __extends(LimitReachedError, _super);
584
+ function LimitReachedError(message) {
585
+ var _this = _super.call(this, message) || this;
586
+ _this.name = 'LimitReachedError';
587
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
588
+ return _this;
589
+ }
590
+ return LimitReachedError;
591
+ }(Error));
592
+
593
+ /**
594
+ * Replaces parameters in template with values from parameters object
595
+ *
596
+ * @param template the template with parameters in {curly} braces
597
+ * @param parameters the object with parameters
598
+ * @returns the template with replaced parameters
599
+ * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
600
+ * @public exported from `@promptbook/utils`
601
+ */
602
+ function replaceParameters(template, parameters) {
603
+ var e_1, _a;
604
+ try {
605
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
606
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
607
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
608
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
609
+ }
610
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
611
+ // TODO: [🍵]
612
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
613
+ }
614
+ }
615
+ }
616
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
617
+ finally {
618
+ try {
619
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
620
+ }
621
+ finally { if (e_1) throw e_1.error; }
622
+ }
623
+ var replacedTemplates = template;
624
+ var match;
625
+ var loopLimit = LOOP_LIMIT;
626
+ var _loop_1 = function () {
627
+ if (loopLimit-- < 0) {
628
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
629
+ }
630
+ var precol = match.groups.precol;
631
+ var parameterName = match.groups.parameterName;
632
+ if (parameterName === '') {
633
+ return "continue";
634
+ }
635
+ if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
636
+ throw new PipelineExecutionError('Parameter is already opened or not closed');
637
+ }
638
+ if (parameters[parameterName] === undefined) {
639
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
640
+ }
641
+ var parameterValue = parameters[parameterName];
642
+ if (parameterValue === undefined) {
643
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
644
+ }
645
+ parameterValue = parameterValue.toString();
646
+ if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
647
+ parameterValue = parameterValue
648
+ .split('\n')
649
+ .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
650
+ .join('\n');
651
+ }
652
+ replacedTemplates =
653
+ replacedTemplates.substring(0, match.index + precol.length) +
654
+ parameterValue +
655
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
656
+ };
657
+ while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
658
+ .exec(replacedTemplates))) {
659
+ _loop_1();
660
+ }
661
+ // [💫] Check if there are parameters that are not closed properly
662
+ if (/{\w+$/.test(replacedTemplates)) {
663
+ throw new PipelineExecutionError('Parameter is not closed');
664
+ }
665
+ // [💫] Check if there are parameters that are not opened properly
666
+ if (/^\w+}/.test(replacedTemplates)) {
667
+ throw new PipelineExecutionError('Parameter is not opened');
668
+ }
669
+ return replacedTemplates;
670
+ }
671
+
594
672
  /**
595
673
  * Function `asSerializable` will convert values which are not serializable to serializable values
596
674
  * It walks deeply through the object and converts all values
@@ -670,7 +748,7 @@ function createExecutionToolsFromVercelProvider(options) {
670
748
  return modelVariant === 'CHAT';
671
749
  })) === null || _a === void 0 ? void 0 : _a.modelName);
672
750
  if (!modelName) {
673
- throw new PipelineExecutionError(spaceTrim("\n Can not determine which model to use.\n\n You need to provide at least one of:\n 1) In `createExecutionToolsFromVercelProvider` options, provide `availableModels` with at least one model\n 2) In `prompt.modelRequirements`, provide `modelName` with the name of the model to use\n \n "));
751
+ throw new PipelineExecutionError(spaceTrim("\n Can not determine which model to use.\n\n You need to provide at least one of:\n 1) In `createExecutionToolsFromVercelProvider` options, provide `availableModels` with at least one model\n 2) In `prompt.modelRequirements`, provide `modelName` with the name of the model to use\n\n "));
674
752
  }
675
753
  return [4 /*yield*/, vercelProvider.chat(modelName, __assign({ user: (userId === null || userId === void 0 ? void 0 : userId.toString()) || undefined }, additionalChatSettings))];
676
754
  case 1:
@@ -733,18 +811,22 @@ function createExecutionToolsFromVercelProvider(options) {
733
811
  }
734
812
  complete = $getCurrentDate();
735
813
  usage = UNCERTAIN_USAGE;
736
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('createExecutionToolsFromVercelProvider ChatPromptResult', {
737
- content: rawResponse.text,
738
- modelName: modelName,
739
- timing: {
740
- start: start,
741
- complete: complete,
814
+ return [2 /*return*/, exportJson({
815
+ name: 'promptResult',
816
+ message: "Result of `createExecutionToolsFromVercelProvider.callChatModel`",
817
+ value: {
818
+ content: rawResponse.text,
819
+ modelName: modelName,
820
+ timing: {
821
+ start: start,
822
+ complete: complete,
823
+ },
824
+ usage: usage,
825
+ rawPromptContent: rawPromptContent,
826
+ rawRequest: rawRequest,
827
+ rawResponse: asSerializable(rawResponse),
828
+ // <- [🗯]
742
829
  },
743
- usage: usage,
744
- rawPromptContent: rawPromptContent,
745
- rawRequest: rawRequest,
746
- rawResponse: asSerializable(rawResponse),
747
- // <- [🗯]
748
830
  })];
749
831
  }
750
832
  });