@promptbook/google 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/google`
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
@@ -164,7 +164,7 @@ var PipelineExecutionError = /** @class */ (function (_super) {
164
164
  }(Error));
165
165
 
166
166
  /**
167
- * @@@
167
+ * Freezes the given object and all its nested objects recursively
168
168
  *
169
169
  * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
170
170
  * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
@@ -174,6 +174,9 @@ var PipelineExecutionError = /** @class */ (function (_super) {
174
174
  */
175
175
  function $deepFreeze(objectValue) {
176
176
  var e_1, _a;
177
+ if (Array.isArray(objectValue)) {
178
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
179
+ }
177
180
  var propertyNames = Object.getOwnPropertyNames(objectValue);
178
181
  try {
179
182
  for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
@@ -191,7 +194,8 @@ function $deepFreeze(objectValue) {
191
194
  }
192
195
  finally { if (e_1) throw e_1.error; }
193
196
  }
194
- return Object.freeze(objectValue);
197
+ Object.freeze(objectValue);
198
+ return objectValue;
195
199
  }
196
200
  /**
197
201
  * TODO: [🧠] Is there a way how to meaningfully test this utility
@@ -292,24 +296,6 @@ var ADMIN_GITHUB_NAME = 'hejny';
292
296
  * @private within the repository - too low-level in comparison with other `MAX_...`
293
297
  */
294
298
  var LOOP_LIMIT = 1000;
295
- /**
296
- * Nonce which is used for replacing things in strings
297
- *
298
- * @private within the repository
299
- */
300
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
301
- /**
302
- * @@@
303
- *
304
- * @private within the repository
305
- */
306
- var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
307
- /**
308
- * @@@
309
- *
310
- * @private within the repository
311
- */
312
- var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
313
299
  // <- TODO: [🧜‍♂️]
314
300
  /**
315
301
  * @@@
@@ -323,26 +309,21 @@ Object.freeze({
323
309
  skipEmptyLines: true,
324
310
  });
325
311
  /**
326
- * TODO: Extract `constants.ts` from `config.ts`
327
312
  * Note: [💞] Ignore a discrepancy between file name and entity name
328
313
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
329
314
  */
330
315
 
331
316
  /**
332
- * This error type indicates that some limit was reached
317
+ * Orders JSON object by keys
333
318
  *
334
- * @public exported from `@promptbook/core`
319
+ * @returns The same type of object as the input re-ordered
320
+ * @public exported from `@promptbook/utils`
335
321
  */
336
- var LimitReachedError = /** @class */ (function (_super) {
337
- __extends(LimitReachedError, _super);
338
- function LimitReachedError(message) {
339
- var _this = _super.call(this, message) || this;
340
- _this.name = 'LimitReachedError';
341
- Object.setPrototypeOf(_this, LimitReachedError.prototype);
342
- return _this;
343
- }
344
- return LimitReachedError;
345
- }(Error));
322
+ function orderJson(options) {
323
+ var value = options.value, order = options.order;
324
+ var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
325
+ return orderedValue;
326
+ }
346
327
 
347
328
  /**
348
329
  * Make error report URL for the given error
@@ -378,85 +359,6 @@ var UnexpectedError = /** @class */ (function (_super) {
378
359
  return UnexpectedError;
379
360
  }(Error));
380
361
 
381
- /**
382
- * Replaces parameters in template with values from parameters object
383
- *
384
- * @param template the template with parameters in {curly} braces
385
- * @param parameters the object with parameters
386
- * @returns the template with replaced parameters
387
- * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
388
- * @public exported from `@promptbook/utils`
389
- */
390
- function replaceParameters(template, parameters) {
391
- var e_1, _a;
392
- try {
393
- for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
394
- var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
395
- if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
396
- throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
397
- }
398
- else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
399
- // TODO: [🍵]
400
- throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
401
- }
402
- }
403
- }
404
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
405
- finally {
406
- try {
407
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
408
- }
409
- finally { if (e_1) throw e_1.error; }
410
- }
411
- var replacedTemplates = template;
412
- var match;
413
- var loopLimit = LOOP_LIMIT;
414
- var _loop_1 = function () {
415
- if (loopLimit-- < 0) {
416
- throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
417
- }
418
- var precol = match.groups.precol;
419
- var parameterName = match.groups.parameterName;
420
- if (parameterName === '') {
421
- return "continue";
422
- }
423
- if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
424
- throw new PipelineExecutionError('Parameter is already opened or not closed');
425
- }
426
- if (parameters[parameterName] === undefined) {
427
- throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
428
- }
429
- var parameterValue = parameters[parameterName];
430
- if (parameterValue === undefined) {
431
- throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
432
- }
433
- parameterValue = parameterValue.toString();
434
- if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
435
- parameterValue = parameterValue
436
- .split('\n')
437
- .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
438
- .join('\n');
439
- }
440
- replacedTemplates =
441
- replacedTemplates.substring(0, match.index + precol.length) +
442
- parameterValue +
443
- replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
444
- };
445
- while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
446
- .exec(replacedTemplates))) {
447
- _loop_1();
448
- }
449
- // [💫] Check if there are parameters that are not closed properly
450
- if (/{\w+$/.test(replacedTemplates)) {
451
- throw new PipelineExecutionError('Parameter is not closed');
452
- }
453
- // [💫] Check if there are parameters that are not opened properly
454
- if (/^\w+}/.test(replacedTemplates)) {
455
- throw new PipelineExecutionError('Parameter is not opened');
456
- }
457
- return replacedTemplates;
458
- }
459
-
460
362
  /**
461
363
  * Checks if the value is [🚉] serializable as JSON
462
364
  * If not, throws an UnexpectedError with a rich error message and tracking
@@ -477,8 +379,9 @@ function replaceParameters(template, parameters) {
477
379
  * @throws UnexpectedError if the value is not serializable as JSON
478
380
  * @public exported from `@promptbook/utils`
479
381
  */
480
- function checkSerializableAsJson(name, value) {
382
+ function checkSerializableAsJson(options) {
481
383
  var e_1, _a;
384
+ var value = options.value, name = options.name, message = options.message;
482
385
  if (value === undefined) {
483
386
  throw new UnexpectedError("".concat(name, " is undefined"));
484
387
  }
@@ -502,12 +405,12 @@ function checkSerializableAsJson(name, value) {
502
405
  }
503
406
  else if (typeof value === 'object' && Array.isArray(value)) {
504
407
  for (var i = 0; i < value.length; i++) {
505
- checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
408
+ checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
506
409
  }
507
410
  }
508
411
  else if (typeof value === 'object') {
509
412
  if (value instanceof Date) {
510
- throw new UnexpectedError(spaceTrim("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
413
+ 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 "); }));
511
414
  }
512
415
  else if (value instanceof Map) {
513
416
  throw new UnexpectedError("".concat(name, " is Map"));
@@ -519,7 +422,7 @@ function checkSerializableAsJson(name, value) {
519
422
  throw new UnexpectedError("".concat(name, " is RegExp"));
520
423
  }
521
424
  else if (value instanceof Error) {
522
- throw new UnexpectedError(spaceTrim("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
425
+ 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 "); }));
523
426
  }
524
427
  else {
525
428
  try {
@@ -529,7 +432,7 @@ function checkSerializableAsJson(name, value) {
529
432
  // Note: undefined in object is serializable - it is just omited
530
433
  continue;
531
434
  }
532
- checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
435
+ checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
533
436
  }
534
437
  }
535
438
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -546,7 +449,7 @@ function checkSerializableAsJson(name, value) {
546
449
  if (!(error instanceof Error)) {
547
450
  throw error;
548
451
  }
549
- throw new UnexpectedError(spaceTrim(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
452
+ 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 "); }));
550
453
  }
551
454
  /*
552
455
  TODO: [0] Is there some more elegant way to check circular references?
@@ -571,35 +474,210 @@ function checkSerializableAsJson(name, value) {
571
474
  }
572
475
  }
573
476
  else {
574
- throw new UnexpectedError("".concat(name, " is unknown"));
477
+ 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 "); }));
575
478
  }
576
479
  }
577
480
  /**
578
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
481
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
579
482
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
580
483
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
581
484
  */
582
485
 
583
486
  /**
584
- * @@@
585
487
  * @@@
586
488
  *
587
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
489
+ * @public exported from `@promptbook/utils`
490
+ */
491
+ function deepClone(objectValue) {
492
+ return JSON.parse(JSON.stringify(objectValue));
493
+ /*
494
+ !!!!!!!!
495
+ TODO: [🧠] Is there a better implementation?
496
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
497
+ > for (const propertyName of propertyNames) {
498
+ > const value = (objectValue as really_any)[propertyName];
499
+ > if (value && typeof value === 'object') {
500
+ > deepClone(value);
501
+ > }
502
+ > }
503
+ > return Object.assign({}, objectValue);
504
+ */
505
+ }
506
+ /**
507
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
508
+ */
509
+
510
+ /**
511
+ * Utility to export a JSON object from a function
588
512
  *
589
- * @param name - Name of the object for debugging purposes
590
- * @param objectValue - Object to be deeply frozen
591
- * @returns The same object as the input, but deeply frozen
592
- * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
513
+ * 1) Checks if the value is serializable as JSON
514
+ * 2) Makes a deep clone of the object
515
+ * 2) Orders the object properties
516
+ * 2) Deeply freezes the cloned object
517
+ *
518
+ * Note: This function does not mutates the given object
519
+ *
520
+ * @returns The same type of object as the input but read-only and re-ordered
521
+ * @public exported from `@promptbook/utils`
593
522
  */
594
- function $asDeeplyFrozenSerializableJson(name, objectValue) {
595
- checkSerializableAsJson(name, objectValue);
596
- return $deepFreeze(objectValue);
523
+ function exportJson(options) {
524
+ var name = options.name, value = options.value, order = options.order, message = options.message;
525
+ checkSerializableAsJson({ name: name, value: value, message: message });
526
+ var orderedValue =
527
+ // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
528
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
529
+ // @ts-ignore
530
+ order === undefined
531
+ ? deepClone(value)
532
+ : orderJson({
533
+ value: value,
534
+ // <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
535
+ order: order,
536
+ });
537
+ $deepFreeze(orderedValue);
538
+ return orderedValue;
597
539
  }
598
540
  /**
599
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
600
541
  * TODO: [🧠] Is there a way how to meaningfully test this utility
601
542
  */
602
543
 
544
+ /**
545
+ * Nonce which is used for replacing things in strings
546
+ *
547
+ * @private within the repository
548
+ */
549
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
550
+ /**
551
+ * @@@
552
+ *
553
+ * @private within the repository
554
+ */
555
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
556
+ /**
557
+ * @@@
558
+ *
559
+ * @private within the repository
560
+ */
561
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
562
+ /**
563
+ * The names of the parameters that are reserved for special purposes
564
+ *
565
+ * @public exported from `@promptbook/core`
566
+ */
567
+ exportJson({
568
+ name: 'RESERVED_PARAMETER_NAMES',
569
+ message: "The names of the parameters that are reserved for special purposes",
570
+ value: [
571
+ 'content',
572
+ 'context',
573
+ 'knowledge',
574
+ 'examples',
575
+ 'modelName',
576
+ 'currentDate',
577
+ // <- TODO: list here all command names
578
+ // <- TODO: Add more like 'date', 'modelName',...
579
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
580
+ ],
581
+ });
582
+ /**
583
+ * Note: [💞] Ignore a discrepancy between file name and entity name
584
+ */
585
+
586
+ /**
587
+ * This error type indicates that some limit was reached
588
+ *
589
+ * @public exported from `@promptbook/core`
590
+ */
591
+ var LimitReachedError = /** @class */ (function (_super) {
592
+ __extends(LimitReachedError, _super);
593
+ function LimitReachedError(message) {
594
+ var _this = _super.call(this, message) || this;
595
+ _this.name = 'LimitReachedError';
596
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
597
+ return _this;
598
+ }
599
+ return LimitReachedError;
600
+ }(Error));
601
+
602
+ /**
603
+ * Replaces parameters in template with values from parameters object
604
+ *
605
+ * @param template the template with parameters in {curly} braces
606
+ * @param parameters the object with parameters
607
+ * @returns the template with replaced parameters
608
+ * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
609
+ * @public exported from `@promptbook/utils`
610
+ */
611
+ function replaceParameters(template, parameters) {
612
+ var e_1, _a;
613
+ try {
614
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
615
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
616
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
617
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
618
+ }
619
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
620
+ // TODO: [🍵]
621
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
622
+ }
623
+ }
624
+ }
625
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
626
+ finally {
627
+ try {
628
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
629
+ }
630
+ finally { if (e_1) throw e_1.error; }
631
+ }
632
+ var replacedTemplates = template;
633
+ var match;
634
+ var loopLimit = LOOP_LIMIT;
635
+ var _loop_1 = function () {
636
+ if (loopLimit-- < 0) {
637
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
638
+ }
639
+ var precol = match.groups.precol;
640
+ var parameterName = match.groups.parameterName;
641
+ if (parameterName === '') {
642
+ return "continue";
643
+ }
644
+ if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
645
+ throw new PipelineExecutionError('Parameter is already opened or not closed');
646
+ }
647
+ if (parameters[parameterName] === undefined) {
648
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
649
+ }
650
+ var parameterValue = parameters[parameterName];
651
+ if (parameterValue === undefined) {
652
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
653
+ }
654
+ parameterValue = parameterValue.toString();
655
+ if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
656
+ parameterValue = parameterValue
657
+ .split('\n')
658
+ .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
659
+ .join('\n');
660
+ }
661
+ replacedTemplates =
662
+ replacedTemplates.substring(0, match.index + precol.length) +
663
+ parameterValue +
664
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
665
+ };
666
+ while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
667
+ .exec(replacedTemplates))) {
668
+ _loop_1();
669
+ }
670
+ // [💫] Check if there are parameters that are not closed properly
671
+ if (/{\w+$/.test(replacedTemplates)) {
672
+ throw new PipelineExecutionError('Parameter is not closed');
673
+ }
674
+ // [💫] Check if there are parameters that are not opened properly
675
+ if (/^\w+}/.test(replacedTemplates)) {
676
+ throw new PipelineExecutionError('Parameter is not opened');
677
+ }
678
+ return replacedTemplates;
679
+ }
680
+
603
681
  /**
604
682
  * Function `asSerializable` will convert values which are not serializable to serializable values
605
683
  * It walks deeply through the object and converts all values
@@ -679,7 +757,7 @@ function createExecutionToolsFromVercelProvider(options) {
679
757
  return modelVariant === 'CHAT';
680
758
  })) === null || _a === void 0 ? void 0 : _a.modelName);
681
759
  if (!modelName) {
682
- 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 "));
760
+ 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 "));
683
761
  }
684
762
  return [4 /*yield*/, vercelProvider.chat(modelName, __assign({ user: (userId === null || userId === void 0 ? void 0 : userId.toString()) || undefined }, additionalChatSettings))];
685
763
  case 1:
@@ -742,18 +820,22 @@ function createExecutionToolsFromVercelProvider(options) {
742
820
  }
743
821
  complete = $getCurrentDate();
744
822
  usage = UNCERTAIN_USAGE;
745
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('createExecutionToolsFromVercelProvider ChatPromptResult', {
746
- content: rawResponse.text,
747
- modelName: modelName,
748
- timing: {
749
- start: start,
750
- complete: complete,
823
+ return [2 /*return*/, exportJson({
824
+ name: 'promptResult',
825
+ message: "Result of `createExecutionToolsFromVercelProvider.callChatModel`",
826
+ value: {
827
+ content: rawResponse.text,
828
+ modelName: modelName,
829
+ timing: {
830
+ start: start,
831
+ complete: complete,
832
+ },
833
+ usage: usage,
834
+ rawPromptContent: rawPromptContent,
835
+ rawRequest: rawRequest,
836
+ rawResponse: asSerializable(rawResponse),
837
+ // <- [🗯]
751
838
  },
752
- usage: usage,
753
- rawPromptContent: rawPromptContent,
754
- rawRequest: rawRequest,
755
- rawResponse: asSerializable(rawResponse),
756
- // <- [🗯]
757
839
  })];
758
840
  }
759
841
  });