@promptbook/openai 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 +621 -520
  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 +621 -520
  35. package/umd/index.umd.js.map +1 -1
  36. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
package/esm/index.es.js CHANGED
@@ -14,7 +14,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
14
14
  *
15
15
  * @see https://github.com/webgptorg/promptbook
16
16
  */
17
- var PROMPTBOOK_ENGINE_VERSION = '0.78.3';
17
+ var PROMPTBOOK_ENGINE_VERSION = '0.79.0';
18
18
  /**
19
19
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
20
20
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -190,7 +190,7 @@ var PipelineExecutionError = /** @class */ (function (_super) {
190
190
  }(Error));
191
191
 
192
192
  /**
193
- * @@@
193
+ * Freezes the given object and all its nested objects recursively
194
194
  *
195
195
  * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
196
196
  * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
@@ -200,6 +200,9 @@ var PipelineExecutionError = /** @class */ (function (_super) {
200
200
  */
201
201
  function $deepFreeze(objectValue) {
202
202
  var e_1, _a;
203
+ if (Array.isArray(objectValue)) {
204
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
205
+ }
203
206
  var propertyNames = Object.getOwnPropertyNames(objectValue);
204
207
  try {
205
208
  for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
@@ -217,7 +220,8 @@ function $deepFreeze(objectValue) {
217
220
  }
218
221
  finally { if (e_1) throw e_1.error; }
219
222
  }
220
- return Object.freeze(objectValue);
223
+ Object.freeze(objectValue);
224
+ return objectValue;
221
225
  }
222
226
  /**
223
227
  * TODO: [🧠] Is there a way how to meaningfully test this utility
@@ -318,24 +322,6 @@ var ADMIN_GITHUB_NAME = 'hejny';
318
322
  * @private within the repository - too low-level in comparison with other `MAX_...`
319
323
  */
320
324
  var LOOP_LIMIT = 1000;
321
- /**
322
- * Nonce which is used for replacing things in strings
323
- *
324
- * @private within the repository
325
- */
326
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
327
- /**
328
- * @@@
329
- *
330
- * @private within the repository
331
- */
332
- var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
333
- /**
334
- * @@@
335
- *
336
- * @private within the repository
337
- */
338
- var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
339
325
  // <- TODO: [🧜‍♂️]
340
326
  /**
341
327
  * @@@
@@ -349,26 +335,21 @@ Object.freeze({
349
335
  skipEmptyLines: true,
350
336
  });
351
337
  /**
352
- * TODO: Extract `constants.ts` from `config.ts`
353
338
  * Note: [💞] Ignore a discrepancy between file name and entity name
354
339
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
355
340
  */
356
341
 
357
342
  /**
358
- * This error type indicates that some limit was reached
343
+ * Orders JSON object by keys
359
344
  *
360
- * @public exported from `@promptbook/core`
345
+ * @returns The same type of object as the input re-ordered
346
+ * @public exported from `@promptbook/utils`
361
347
  */
362
- var LimitReachedError = /** @class */ (function (_super) {
363
- __extends(LimitReachedError, _super);
364
- function LimitReachedError(message) {
365
- var _this = _super.call(this, message) || this;
366
- _this.name = 'LimitReachedError';
367
- Object.setPrototypeOf(_this, LimitReachedError.prototype);
368
- return _this;
369
- }
370
- return LimitReachedError;
371
- }(Error));
348
+ function orderJson(options) {
349
+ var value = options.value, order = options.order;
350
+ var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
351
+ return orderedValue;
352
+ }
372
353
 
373
354
  /**
374
355
  * Make error report URL for the given error
@@ -404,85 +385,6 @@ var UnexpectedError = /** @class */ (function (_super) {
404
385
  return UnexpectedError;
405
386
  }(Error));
406
387
 
407
- /**
408
- * Replaces parameters in template with values from parameters object
409
- *
410
- * @param template the template with parameters in {curly} braces
411
- * @param parameters the object with parameters
412
- * @returns the template with replaced parameters
413
- * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
414
- * @public exported from `@promptbook/utils`
415
- */
416
- function replaceParameters(template, parameters) {
417
- var e_1, _a;
418
- try {
419
- for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
420
- var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
421
- if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
422
- throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
423
- }
424
- else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
425
- // TODO: [🍵]
426
- throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
427
- }
428
- }
429
- }
430
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
431
- finally {
432
- try {
433
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
434
- }
435
- finally { if (e_1) throw e_1.error; }
436
- }
437
- var replacedTemplates = template;
438
- var match;
439
- var loopLimit = LOOP_LIMIT;
440
- var _loop_1 = function () {
441
- if (loopLimit-- < 0) {
442
- throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
443
- }
444
- var precol = match.groups.precol;
445
- var parameterName = match.groups.parameterName;
446
- if (parameterName === '') {
447
- return "continue";
448
- }
449
- if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
450
- throw new PipelineExecutionError('Parameter is already opened or not closed');
451
- }
452
- if (parameters[parameterName] === undefined) {
453
- throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
454
- }
455
- var parameterValue = parameters[parameterName];
456
- if (parameterValue === undefined) {
457
- throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
458
- }
459
- parameterValue = parameterValue.toString();
460
- if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
461
- parameterValue = parameterValue
462
- .split('\n')
463
- .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
464
- .join('\n');
465
- }
466
- replacedTemplates =
467
- replacedTemplates.substring(0, match.index + precol.length) +
468
- parameterValue +
469
- replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
470
- };
471
- while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
472
- .exec(replacedTemplates))) {
473
- _loop_1();
474
- }
475
- // [💫] Check if there are parameters that are not closed properly
476
- if (/{\w+$/.test(replacedTemplates)) {
477
- throw new PipelineExecutionError('Parameter is not closed');
478
- }
479
- // [💫] Check if there are parameters that are not opened properly
480
- if (/^\w+}/.test(replacedTemplates)) {
481
- throw new PipelineExecutionError('Parameter is not opened');
482
- }
483
- return replacedTemplates;
484
- }
485
-
486
388
  /**
487
389
  * Checks if the value is [🚉] serializable as JSON
488
390
  * If not, throws an UnexpectedError with a rich error message and tracking
@@ -503,8 +405,9 @@ function replaceParameters(template, parameters) {
503
405
  * @throws UnexpectedError if the value is not serializable as JSON
504
406
  * @public exported from `@promptbook/utils`
505
407
  */
506
- function checkSerializableAsJson(name, value) {
408
+ function checkSerializableAsJson(options) {
507
409
  var e_1, _a;
410
+ var value = options.value, name = options.name, message = options.message;
508
411
  if (value === undefined) {
509
412
  throw new UnexpectedError("".concat(name, " is undefined"));
510
413
  }
@@ -528,12 +431,12 @@ function checkSerializableAsJson(name, value) {
528
431
  }
529
432
  else if (typeof value === 'object' && Array.isArray(value)) {
530
433
  for (var i = 0; i < value.length; i++) {
531
- checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
434
+ checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
532
435
  }
533
436
  }
534
437
  else if (typeof value === 'object') {
535
438
  if (value instanceof Date) {
536
- throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
439
+ throw new UnexpectedError(spaceTrim$1(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 "); }));
537
440
  }
538
441
  else if (value instanceof Map) {
539
442
  throw new UnexpectedError("".concat(name, " is Map"));
@@ -545,7 +448,7 @@ function checkSerializableAsJson(name, value) {
545
448
  throw new UnexpectedError("".concat(name, " is RegExp"));
546
449
  }
547
450
  else if (value instanceof Error) {
548
- throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
451
+ throw new UnexpectedError(spaceTrim$1(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 "); }));
549
452
  }
550
453
  else {
551
454
  try {
@@ -555,7 +458,7 @@ function checkSerializableAsJson(name, value) {
555
458
  // Note: undefined in object is serializable - it is just omited
556
459
  continue;
557
460
  }
558
- checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
461
+ checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
559
462
  }
560
463
  }
561
464
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -572,7 +475,7 @@ function checkSerializableAsJson(name, value) {
572
475
  if (!(error instanceof Error)) {
573
476
  throw error;
574
477
  }
575
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
478
+ throw new UnexpectedError(spaceTrim$1(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 "); }));
576
479
  }
577
480
  /*
578
481
  TODO: [0] Is there some more elegant way to check circular references?
@@ -597,35 +500,210 @@ function checkSerializableAsJson(name, value) {
597
500
  }
598
501
  }
599
502
  else {
600
- throw new UnexpectedError("".concat(name, " is unknown"));
503
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
601
504
  }
602
505
  }
603
506
  /**
604
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
507
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
605
508
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
606
509
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
607
510
  */
608
511
 
609
512
  /**
610
- * @@@
611
513
  * @@@
612
514
  *
613
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
515
+ * @public exported from `@promptbook/utils`
516
+ */
517
+ function deepClone(objectValue) {
518
+ return JSON.parse(JSON.stringify(objectValue));
519
+ /*
520
+ !!!!!!!!
521
+ TODO: [🧠] Is there a better implementation?
522
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
523
+ > for (const propertyName of propertyNames) {
524
+ > const value = (objectValue as really_any)[propertyName];
525
+ > if (value && typeof value === 'object') {
526
+ > deepClone(value);
527
+ > }
528
+ > }
529
+ > return Object.assign({}, objectValue);
530
+ */
531
+ }
532
+ /**
533
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
534
+ */
535
+
536
+ /**
537
+ * Utility to export a JSON object from a function
614
538
  *
615
- * @param name - Name of the object for debugging purposes
616
- * @param objectValue - Object to be deeply frozen
617
- * @returns The same object as the input, but deeply frozen
618
- * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
539
+ * 1) Checks if the value is serializable as JSON
540
+ * 2) Makes a deep clone of the object
541
+ * 2) Orders the object properties
542
+ * 2) Deeply freezes the cloned object
543
+ *
544
+ * Note: This function does not mutates the given object
545
+ *
546
+ * @returns The same type of object as the input but read-only and re-ordered
547
+ * @public exported from `@promptbook/utils`
619
548
  */
620
- function $asDeeplyFrozenSerializableJson(name, objectValue) {
621
- checkSerializableAsJson(name, objectValue);
622
- return $deepFreeze(objectValue);
549
+ function exportJson(options) {
550
+ var name = options.name, value = options.value, order = options.order, message = options.message;
551
+ checkSerializableAsJson({ name: name, value: value, message: message });
552
+ var orderedValue =
553
+ // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
554
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
555
+ // @ts-ignore
556
+ order === undefined
557
+ ? deepClone(value)
558
+ : orderJson({
559
+ value: value,
560
+ // <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
561
+ order: order,
562
+ });
563
+ $deepFreeze(orderedValue);
564
+ return orderedValue;
623
565
  }
624
566
  /**
625
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
626
567
  * TODO: [🧠] Is there a way how to meaningfully test this utility
627
568
  */
628
569
 
570
+ /**
571
+ * Nonce which is used for replacing things in strings
572
+ *
573
+ * @private within the repository
574
+ */
575
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
576
+ /**
577
+ * @@@
578
+ *
579
+ * @private within the repository
580
+ */
581
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
582
+ /**
583
+ * @@@
584
+ *
585
+ * @private within the repository
586
+ */
587
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
588
+ /**
589
+ * The names of the parameters that are reserved for special purposes
590
+ *
591
+ * @public exported from `@promptbook/core`
592
+ */
593
+ exportJson({
594
+ name: 'RESERVED_PARAMETER_NAMES',
595
+ message: "The names of the parameters that are reserved for special purposes",
596
+ value: [
597
+ 'content',
598
+ 'context',
599
+ 'knowledge',
600
+ 'examples',
601
+ 'modelName',
602
+ 'currentDate',
603
+ // <- TODO: list here all command names
604
+ // <- TODO: Add more like 'date', 'modelName',...
605
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
606
+ ],
607
+ });
608
+ /**
609
+ * Note: [💞] Ignore a discrepancy between file name and entity name
610
+ */
611
+
612
+ /**
613
+ * This error type indicates that some limit was reached
614
+ *
615
+ * @public exported from `@promptbook/core`
616
+ */
617
+ var LimitReachedError = /** @class */ (function (_super) {
618
+ __extends(LimitReachedError, _super);
619
+ function LimitReachedError(message) {
620
+ var _this = _super.call(this, message) || this;
621
+ _this.name = 'LimitReachedError';
622
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
623
+ return _this;
624
+ }
625
+ return LimitReachedError;
626
+ }(Error));
627
+
628
+ /**
629
+ * Replaces parameters in template with values from parameters object
630
+ *
631
+ * @param template the template with parameters in {curly} braces
632
+ * @param parameters the object with parameters
633
+ * @returns the template with replaced parameters
634
+ * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
635
+ * @public exported from `@promptbook/utils`
636
+ */
637
+ function replaceParameters(template, parameters) {
638
+ var e_1, _a;
639
+ try {
640
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
641
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
642
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
643
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
644
+ }
645
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
646
+ // TODO: [🍵]
647
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
648
+ }
649
+ }
650
+ }
651
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
652
+ finally {
653
+ try {
654
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
655
+ }
656
+ finally { if (e_1) throw e_1.error; }
657
+ }
658
+ var replacedTemplates = template;
659
+ var match;
660
+ var loopLimit = LOOP_LIMIT;
661
+ var _loop_1 = function () {
662
+ if (loopLimit-- < 0) {
663
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
664
+ }
665
+ var precol = match.groups.precol;
666
+ var parameterName = match.groups.parameterName;
667
+ if (parameterName === '') {
668
+ return "continue";
669
+ }
670
+ if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
671
+ throw new PipelineExecutionError('Parameter is already opened or not closed');
672
+ }
673
+ if (parameters[parameterName] === undefined) {
674
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
675
+ }
676
+ var parameterValue = parameters[parameterName];
677
+ if (parameterValue === undefined) {
678
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
679
+ }
680
+ parameterValue = parameterValue.toString();
681
+ if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
682
+ parameterValue = parameterValue
683
+ .split('\n')
684
+ .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
685
+ .join('\n');
686
+ }
687
+ replacedTemplates =
688
+ replacedTemplates.substring(0, match.index + precol.length) +
689
+ parameterValue +
690
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
691
+ };
692
+ while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
693
+ .exec(replacedTemplates))) {
694
+ _loop_1();
695
+ }
696
+ // [💫] Check if there are parameters that are not closed properly
697
+ if (/{\w+$/.test(replacedTemplates)) {
698
+ throw new PipelineExecutionError('Parameter is not closed');
699
+ }
700
+ // [💫] Check if there are parameters that are not opened properly
701
+ if (/^\w+}/.test(replacedTemplates)) {
702
+ throw new PipelineExecutionError('Parameter is not opened');
703
+ }
704
+ return replacedTemplates;
705
+ }
706
+
629
707
  /**
630
708
  * Counts number of characters in the text
631
709
  *
@@ -1033,381 +1111,384 @@ function computeUsage(value) {
1033
1111
  * @see https://openai.com/api/pricing/
1034
1112
  * @public exported from `@promptbook/openai`
1035
1113
  */
1036
- var OPENAI_MODELS = $asDeeplyFrozenSerializableJson('OPENAI_MODELS', [
1037
- /*/
1114
+ var OPENAI_MODELS = exportJson({
1115
+ name: 'OPENAI_MODELS',
1116
+ value: [
1117
+ /*/
1118
+ {
1119
+ modelTitle: 'dall-e-3',
1120
+ modelName: 'dall-e-3',
1121
+ },
1122
+ /**/
1123
+ /*/
1124
+ {
1125
+ modelTitle: 'whisper-1',
1126
+ modelName: 'whisper-1',
1127
+ },
1128
+ /**/
1129
+ /**/
1130
+ {
1131
+ modelVariant: 'COMPLETION',
1132
+ modelTitle: 'davinci-002',
1133
+ modelName: 'davinci-002',
1134
+ pricing: {
1135
+ prompt: computeUsage("$2.00 / 1M tokens"),
1136
+ output: computeUsage("$2.00 / 1M tokens"), // <- not sure
1137
+ },
1138
+ },
1139
+ /**/
1140
+ /*/
1038
1141
  {
1039
- modelTitle: 'dall-e-3',
1040
- modelName: 'dall-e-3',
1142
+ modelTitle: 'dall-e-2',
1143
+ modelName: 'dall-e-2',
1041
1144
  },
1042
1145
  /**/
1043
- /*/
1146
+ /**/
1147
+ {
1148
+ modelVariant: 'CHAT',
1149
+ modelTitle: 'gpt-3.5-turbo-16k',
1150
+ modelName: 'gpt-3.5-turbo-16k',
1151
+ pricing: {
1152
+ prompt: computeUsage("$3.00 / 1M tokens"),
1153
+ output: computeUsage("$4.00 / 1M tokens"),
1154
+ },
1155
+ },
1156
+ /**/
1157
+ /*/
1044
1158
  {
1045
- modelTitle: 'whisper-1',
1046
- modelName: 'whisper-1',
1159
+ modelTitle: 'tts-1-hd-1106',
1160
+ modelName: 'tts-1-hd-1106',
1047
1161
  },
1048
- /**/
1049
- /**/
1050
- {
1051
- modelVariant: 'COMPLETION',
1052
- modelTitle: 'davinci-002',
1053
- modelName: 'davinci-002',
1054
- pricing: {
1055
- prompt: computeUsage("$2.00 / 1M tokens"),
1056
- output: computeUsage("$2.00 / 1M tokens"), // <- not sure
1057
- },
1058
- },
1059
- /**/
1060
- /*/
1061
- {
1062
- modelTitle: 'dall-e-2',
1063
- modelName: 'dall-e-2',
1064
- },
1065
- /**/
1066
- /**/
1067
- {
1068
- modelVariant: 'CHAT',
1069
- modelTitle: 'gpt-3.5-turbo-16k',
1070
- modelName: 'gpt-3.5-turbo-16k',
1071
- pricing: {
1072
- prompt: computeUsage("$3.00 / 1M tokens"),
1073
- output: computeUsage("$4.00 / 1M tokens"),
1074
- },
1075
- },
1076
- /**/
1077
- /*/
1078
- {
1079
- modelTitle: 'tts-1-hd-1106',
1080
- modelName: 'tts-1-hd-1106',
1081
- },
1082
- /**/
1083
- /*/
1084
- {
1085
- modelTitle: 'tts-1-hd',
1086
- modelName: 'tts-1-hd',
1087
- },
1088
- /**/
1089
- /**/
1090
- {
1091
- modelVariant: 'CHAT',
1092
- modelTitle: 'gpt-4',
1093
- modelName: 'gpt-4',
1094
- pricing: {
1095
- prompt: computeUsage("$30.00 / 1M tokens"),
1096
- output: computeUsage("$60.00 / 1M tokens"),
1162
+ /**/
1163
+ /*/
1164
+ {
1165
+ modelTitle: 'tts-1-hd',
1166
+ modelName: 'tts-1-hd',
1167
+ },
1168
+ /**/
1169
+ /**/
1170
+ {
1171
+ modelVariant: 'CHAT',
1172
+ modelTitle: 'gpt-4',
1173
+ modelName: 'gpt-4',
1174
+ pricing: {
1175
+ prompt: computeUsage("$30.00 / 1M tokens"),
1176
+ output: computeUsage("$60.00 / 1M tokens"),
1177
+ },
1097
1178
  },
1098
- },
1099
- /**/
1100
- /**/
1101
- {
1102
- modelVariant: 'CHAT',
1103
- modelTitle: 'gpt-4-32k',
1104
- modelName: 'gpt-4-32k',
1105
- pricing: {
1106
- prompt: computeUsage("$60.00 / 1M tokens"),
1107
- output: computeUsage("$120.00 / 1M tokens"),
1179
+ /**/
1180
+ /**/
1181
+ {
1182
+ modelVariant: 'CHAT',
1183
+ modelTitle: 'gpt-4-32k',
1184
+ modelName: 'gpt-4-32k',
1185
+ pricing: {
1186
+ prompt: computeUsage("$60.00 / 1M tokens"),
1187
+ output: computeUsage("$120.00 / 1M tokens"),
1188
+ },
1108
1189
  },
1109
- },
1110
- /**/
1111
- /*/
1112
- {
1113
- modelVariant: 'CHAT',
1114
- modelTitle: 'gpt-4-0613',
1115
- modelName: 'gpt-4-0613',
1116
- pricing: {
1117
- prompt: computeUsage(` / 1M tokens`),
1118
- output: computeUsage(` / 1M tokens`),
1190
+ /**/
1191
+ /*/
1192
+ {
1193
+ modelVariant: 'CHAT',
1194
+ modelTitle: 'gpt-4-0613',
1195
+ modelName: 'gpt-4-0613',
1196
+ pricing: {
1197
+ prompt: computeUsage(` / 1M tokens`),
1198
+ output: computeUsage(` / 1M tokens`),
1199
+ },
1119
1200
  },
1120
- },
1121
- /**/
1122
- /**/
1123
- {
1124
- modelVariant: 'CHAT',
1125
- modelTitle: 'gpt-4-turbo-2024-04-09',
1126
- modelName: 'gpt-4-turbo-2024-04-09',
1127
- pricing: {
1128
- prompt: computeUsage("$10.00 / 1M tokens"),
1129
- output: computeUsage("$30.00 / 1M tokens"),
1201
+ /**/
1202
+ /**/
1203
+ {
1204
+ modelVariant: 'CHAT',
1205
+ modelTitle: 'gpt-4-turbo-2024-04-09',
1206
+ modelName: 'gpt-4-turbo-2024-04-09',
1207
+ pricing: {
1208
+ prompt: computeUsage("$10.00 / 1M tokens"),
1209
+ output: computeUsage("$30.00 / 1M tokens"),
1210
+ },
1130
1211
  },
1131
- },
1132
- /**/
1133
- /**/
1134
- {
1135
- modelVariant: 'CHAT',
1136
- modelTitle: 'gpt-3.5-turbo-1106',
1137
- modelName: 'gpt-3.5-turbo-1106',
1138
- pricing: {
1139
- prompt: computeUsage("$1.00 / 1M tokens"),
1140
- output: computeUsage("$2.00 / 1M tokens"),
1212
+ /**/
1213
+ /**/
1214
+ {
1215
+ modelVariant: 'CHAT',
1216
+ modelTitle: 'gpt-3.5-turbo-1106',
1217
+ modelName: 'gpt-3.5-turbo-1106',
1218
+ pricing: {
1219
+ prompt: computeUsage("$1.00 / 1M tokens"),
1220
+ output: computeUsage("$2.00 / 1M tokens"),
1221
+ },
1141
1222
  },
1142
- },
1143
- /**/
1144
- /**/
1145
- {
1146
- modelVariant: 'CHAT',
1147
- modelTitle: 'gpt-4-turbo',
1148
- modelName: 'gpt-4-turbo',
1149
- pricing: {
1150
- prompt: computeUsage("$10.00 / 1M tokens"),
1151
- output: computeUsage("$30.00 / 1M tokens"),
1223
+ /**/
1224
+ /**/
1225
+ {
1226
+ modelVariant: 'CHAT',
1227
+ modelTitle: 'gpt-4-turbo',
1228
+ modelName: 'gpt-4-turbo',
1229
+ pricing: {
1230
+ prompt: computeUsage("$10.00 / 1M tokens"),
1231
+ output: computeUsage("$30.00 / 1M tokens"),
1232
+ },
1152
1233
  },
1153
- },
1154
- /**/
1155
- /**/
1156
- {
1157
- modelVariant: 'COMPLETION',
1158
- modelTitle: 'gpt-3.5-turbo-instruct-0914',
1159
- modelName: 'gpt-3.5-turbo-instruct-0914',
1160
- pricing: {
1161
- prompt: computeUsage("$1.50 / 1M tokens"),
1162
- output: computeUsage("$2.00 / 1M tokens"), // <- For gpt-3.5-turbo-instruct
1234
+ /**/
1235
+ /**/
1236
+ {
1237
+ modelVariant: 'COMPLETION',
1238
+ modelTitle: 'gpt-3.5-turbo-instruct-0914',
1239
+ modelName: 'gpt-3.5-turbo-instruct-0914',
1240
+ pricing: {
1241
+ prompt: computeUsage("$1.50 / 1M tokens"),
1242
+ output: computeUsage("$2.00 / 1M tokens"), // <- For gpt-3.5-turbo-instruct
1243
+ },
1163
1244
  },
1164
- },
1165
- /**/
1166
- /**/
1167
- {
1168
- modelVariant: 'COMPLETION',
1169
- modelTitle: 'gpt-3.5-turbo-instruct',
1170
- modelName: 'gpt-3.5-turbo-instruct',
1171
- pricing: {
1172
- prompt: computeUsage("$1.50 / 1M tokens"),
1173
- output: computeUsage("$2.00 / 1M tokens"),
1245
+ /**/
1246
+ /**/
1247
+ {
1248
+ modelVariant: 'COMPLETION',
1249
+ modelTitle: 'gpt-3.5-turbo-instruct',
1250
+ modelName: 'gpt-3.5-turbo-instruct',
1251
+ pricing: {
1252
+ prompt: computeUsage("$1.50 / 1M tokens"),
1253
+ output: computeUsage("$2.00 / 1M tokens"),
1254
+ },
1174
1255
  },
1175
- },
1176
- /**/
1177
- /*/
1178
- {
1179
- modelTitle: 'tts-1',
1180
- modelName: 'tts-1',
1181
- },
1182
- /**/
1183
- /**/
1184
- {
1185
- modelVariant: 'CHAT',
1186
- modelTitle: 'gpt-3.5-turbo',
1187
- modelName: 'gpt-3.5-turbo',
1188
- pricing: {
1189
- prompt: computeUsage("$3.00 / 1M tokens"),
1190
- output: computeUsage("$6.00 / 1M tokens"), // <- Not sure, refer to gpt-3.5-turbo in Fine-tuning models
1256
+ /**/
1257
+ /*/
1258
+ {
1259
+ modelTitle: 'tts-1',
1260
+ modelName: 'tts-1',
1261
+ },
1262
+ /**/
1263
+ /**/
1264
+ {
1265
+ modelVariant: 'CHAT',
1266
+ modelTitle: 'gpt-3.5-turbo',
1267
+ modelName: 'gpt-3.5-turbo',
1268
+ pricing: {
1269
+ prompt: computeUsage("$3.00 / 1M tokens"),
1270
+ output: computeUsage("$6.00 / 1M tokens"), // <- Not sure, refer to gpt-3.5-turbo in Fine-tuning models
1271
+ },
1191
1272
  },
1192
- },
1193
- /**/
1194
- /**/
1195
- {
1196
- modelVariant: 'CHAT',
1197
- modelTitle: 'gpt-3.5-turbo-0301',
1198
- modelName: 'gpt-3.5-turbo-0301',
1199
- pricing: {
1200
- prompt: computeUsage("$1.50 / 1M tokens"),
1201
- output: computeUsage("$2.00 / 1M tokens"),
1273
+ /**/
1274
+ /**/
1275
+ {
1276
+ modelVariant: 'CHAT',
1277
+ modelTitle: 'gpt-3.5-turbo-0301',
1278
+ modelName: 'gpt-3.5-turbo-0301',
1279
+ pricing: {
1280
+ prompt: computeUsage("$1.50 / 1M tokens"),
1281
+ output: computeUsage("$2.00 / 1M tokens"),
1282
+ },
1202
1283
  },
1203
- },
1204
- /**/
1205
- /**/
1206
- {
1207
- modelVariant: 'COMPLETION',
1208
- modelTitle: 'babbage-002',
1209
- modelName: 'babbage-002',
1210
- pricing: {
1211
- prompt: computeUsage("$0.40 / 1M tokens"),
1212
- output: computeUsage("$0.40 / 1M tokens"), // <- Not sure
1284
+ /**/
1285
+ /**/
1286
+ {
1287
+ modelVariant: 'COMPLETION',
1288
+ modelTitle: 'babbage-002',
1289
+ modelName: 'babbage-002',
1290
+ pricing: {
1291
+ prompt: computeUsage("$0.40 / 1M tokens"),
1292
+ output: computeUsage("$0.40 / 1M tokens"), // <- Not sure
1293
+ },
1213
1294
  },
1214
- },
1215
- /**/
1216
- /**/
1217
- {
1218
- modelVariant: 'CHAT',
1219
- modelTitle: 'gpt-4-1106-preview',
1220
- modelName: 'gpt-4-1106-preview',
1221
- pricing: {
1222
- prompt: computeUsage("$10.00 / 1M tokens"),
1223
- output: computeUsage("$30.00 / 1M tokens"),
1295
+ /**/
1296
+ /**/
1297
+ {
1298
+ modelVariant: 'CHAT',
1299
+ modelTitle: 'gpt-4-1106-preview',
1300
+ modelName: 'gpt-4-1106-preview',
1301
+ pricing: {
1302
+ prompt: computeUsage("$10.00 / 1M tokens"),
1303
+ output: computeUsage("$30.00 / 1M tokens"),
1304
+ },
1224
1305
  },
1225
- },
1226
- /**/
1227
- /**/
1228
- {
1229
- modelVariant: 'CHAT',
1230
- modelTitle: 'gpt-4-0125-preview',
1231
- modelName: 'gpt-4-0125-preview',
1232
- pricing: {
1233
- prompt: computeUsage("$10.00 / 1M tokens"),
1234
- output: computeUsage("$30.00 / 1M tokens"),
1306
+ /**/
1307
+ /**/
1308
+ {
1309
+ modelVariant: 'CHAT',
1310
+ modelTitle: 'gpt-4-0125-preview',
1311
+ modelName: 'gpt-4-0125-preview',
1312
+ pricing: {
1313
+ prompt: computeUsage("$10.00 / 1M tokens"),
1314
+ output: computeUsage("$30.00 / 1M tokens"),
1315
+ },
1235
1316
  },
1236
- },
1237
- /**/
1238
- /*/
1239
- {
1240
- modelTitle: 'tts-1-1106',
1241
- modelName: 'tts-1-1106',
1242
- },
1243
- /**/
1244
- /**/
1245
- {
1246
- modelVariant: 'CHAT',
1247
- modelTitle: 'gpt-3.5-turbo-0125',
1248
- modelName: 'gpt-3.5-turbo-0125',
1249
- pricing: {
1250
- prompt: computeUsage("$0.50 / 1M tokens"),
1251
- output: computeUsage("$1.50 / 1M tokens"),
1317
+ /**/
1318
+ /*/
1319
+ {
1320
+ modelTitle: 'tts-1-1106',
1321
+ modelName: 'tts-1-1106',
1322
+ },
1323
+ /**/
1324
+ /**/
1325
+ {
1326
+ modelVariant: 'CHAT',
1327
+ modelTitle: 'gpt-3.5-turbo-0125',
1328
+ modelName: 'gpt-3.5-turbo-0125',
1329
+ pricing: {
1330
+ prompt: computeUsage("$0.50 / 1M tokens"),
1331
+ output: computeUsage("$1.50 / 1M tokens"),
1332
+ },
1252
1333
  },
1253
- },
1254
- /**/
1255
- /**/
1256
- {
1257
- modelVariant: 'CHAT',
1258
- modelTitle: 'gpt-4-turbo-preview',
1259
- modelName: 'gpt-4-turbo-preview',
1260
- pricing: {
1261
- prompt: computeUsage("$10.00 / 1M tokens"),
1262
- output: computeUsage("$30.00 / 1M tokens"), // <- Not sure, just for gpt-4-turbo
1334
+ /**/
1335
+ /**/
1336
+ {
1337
+ modelVariant: 'CHAT',
1338
+ modelTitle: 'gpt-4-turbo-preview',
1339
+ modelName: 'gpt-4-turbo-preview',
1340
+ pricing: {
1341
+ prompt: computeUsage("$10.00 / 1M tokens"),
1342
+ output: computeUsage("$30.00 / 1M tokens"), // <- Not sure, just for gpt-4-turbo
1343
+ },
1263
1344
  },
1264
- },
1265
- /**/
1266
- /**/
1267
- {
1268
- modelVariant: 'EMBEDDING',
1269
- modelTitle: 'text-embedding-3-large',
1270
- modelName: 'text-embedding-3-large',
1271
- pricing: {
1272
- prompt: computeUsage("$0.13 / 1M tokens"),
1273
- // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1274
- output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1345
+ /**/
1346
+ /**/
1347
+ {
1348
+ modelVariant: 'EMBEDDING',
1349
+ modelTitle: 'text-embedding-3-large',
1350
+ modelName: 'text-embedding-3-large',
1351
+ pricing: {
1352
+ prompt: computeUsage("$0.13 / 1M tokens"),
1353
+ // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1354
+ output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1355
+ },
1275
1356
  },
1276
- },
1277
- /**/
1278
- /**/
1279
- {
1280
- modelVariant: 'EMBEDDING',
1281
- modelTitle: 'text-embedding-3-small',
1282
- modelName: 'text-embedding-3-small',
1283
- pricing: {
1284
- prompt: computeUsage("$0.02 / 1M tokens"),
1285
- // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1286
- output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1357
+ /**/
1358
+ /**/
1359
+ {
1360
+ modelVariant: 'EMBEDDING',
1361
+ modelTitle: 'text-embedding-3-small',
1362
+ modelName: 'text-embedding-3-small',
1363
+ pricing: {
1364
+ prompt: computeUsage("$0.02 / 1M tokens"),
1365
+ // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1366
+ output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1367
+ },
1287
1368
  },
1288
- },
1289
- /**/
1290
- /**/
1291
- {
1292
- modelVariant: 'CHAT',
1293
- modelTitle: 'gpt-3.5-turbo-0613',
1294
- modelName: 'gpt-3.5-turbo-0613',
1295
- pricing: {
1296
- prompt: computeUsage("$1.50 / 1M tokens"),
1297
- output: computeUsage("$2.00 / 1M tokens"),
1369
+ /**/
1370
+ /**/
1371
+ {
1372
+ modelVariant: 'CHAT',
1373
+ modelTitle: 'gpt-3.5-turbo-0613',
1374
+ modelName: 'gpt-3.5-turbo-0613',
1375
+ pricing: {
1376
+ prompt: computeUsage("$1.50 / 1M tokens"),
1377
+ output: computeUsage("$2.00 / 1M tokens"),
1378
+ },
1298
1379
  },
1299
- },
1300
- /**/
1301
- /**/
1302
- {
1303
- modelVariant: 'EMBEDDING',
1304
- modelTitle: 'text-embedding-ada-002',
1305
- modelName: 'text-embedding-ada-002',
1306
- pricing: {
1307
- prompt: computeUsage("$0.1 / 1M tokens"),
1308
- // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1309
- output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1380
+ /**/
1381
+ /**/
1382
+ {
1383
+ modelVariant: 'EMBEDDING',
1384
+ modelTitle: 'text-embedding-ada-002',
1385
+ modelName: 'text-embedding-ada-002',
1386
+ pricing: {
1387
+ prompt: computeUsage("$0.1 / 1M tokens"),
1388
+ // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1389
+ output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1390
+ },
1310
1391
  },
1311
- },
1312
- /**/
1313
- /*/
1314
- {
1315
- modelVariant: 'CHAT',
1316
- modelTitle: 'gpt-4-1106-vision-preview',
1317
- modelName: 'gpt-4-1106-vision-preview',
1318
- },
1319
- /**/
1320
- /*/
1321
- {
1322
- modelVariant: 'CHAT',
1323
- modelTitle: 'gpt-4-vision-preview',
1324
- modelName: 'gpt-4-vision-preview',
1325
- pricing: {
1326
- prompt: computeUsage(`$10.00 / 1M tokens`),
1327
- output: computeUsage(`$30.00 / 1M tokens`),
1392
+ /**/
1393
+ /*/
1394
+ {
1395
+ modelVariant: 'CHAT',
1396
+ modelTitle: 'gpt-4-1106-vision-preview',
1397
+ modelName: 'gpt-4-1106-vision-preview',
1328
1398
  },
1329
- },
1330
- /**/
1331
- /**/
1332
- {
1333
- modelVariant: 'CHAT',
1334
- modelTitle: 'gpt-4o-2024-05-13',
1335
- modelName: 'gpt-4o-2024-05-13',
1336
- pricing: {
1337
- prompt: computeUsage("$5.00 / 1M tokens"),
1338
- output: computeUsage("$15.00 / 1M tokens"),
1399
+ /**/
1400
+ /*/
1401
+ {
1402
+ modelVariant: 'CHAT',
1403
+ modelTitle: 'gpt-4-vision-preview',
1404
+ modelName: 'gpt-4-vision-preview',
1405
+ pricing: {
1406
+ prompt: computeUsage(`$10.00 / 1M tokens`),
1407
+ output: computeUsage(`$30.00 / 1M tokens`),
1408
+ },
1409
+ },
1410
+ /**/
1411
+ /**/
1412
+ {
1413
+ modelVariant: 'CHAT',
1414
+ modelTitle: 'gpt-4o-2024-05-13',
1415
+ modelName: 'gpt-4o-2024-05-13',
1416
+ pricing: {
1417
+ prompt: computeUsage("$5.00 / 1M tokens"),
1418
+ output: computeUsage("$15.00 / 1M tokens"),
1419
+ },
1420
+ //TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
1339
1421
  },
1340
- //TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
1341
- },
1342
- /**/
1343
- /**/
1344
- {
1345
- modelVariant: 'CHAT',
1346
- modelTitle: 'gpt-4o',
1347
- modelName: 'gpt-4o',
1348
- pricing: {
1349
- prompt: computeUsage("$5.00 / 1M tokens"),
1350
- output: computeUsage("$15.00 / 1M tokens"),
1422
+ /**/
1423
+ /**/
1424
+ {
1425
+ modelVariant: 'CHAT',
1426
+ modelTitle: 'gpt-4o',
1427
+ modelName: 'gpt-4o',
1428
+ pricing: {
1429
+ prompt: computeUsage("$5.00 / 1M tokens"),
1430
+ output: computeUsage("$15.00 / 1M tokens"),
1431
+ },
1351
1432
  },
1352
- },
1353
- /**/
1354
- /**/
1355
- {
1356
- modelVariant: 'CHAT',
1357
- modelTitle: 'o1-preview',
1358
- modelName: 'o1-preview',
1359
- pricing: {
1360
- prompt: computeUsage("$15.00 / 1M tokens"),
1361
- output: computeUsage("$60.00 / 1M tokens"),
1433
+ /**/
1434
+ /**/
1435
+ {
1436
+ modelVariant: 'CHAT',
1437
+ modelTitle: 'o1-preview',
1438
+ modelName: 'o1-preview',
1439
+ pricing: {
1440
+ prompt: computeUsage("$15.00 / 1M tokens"),
1441
+ output: computeUsage("$60.00 / 1M tokens"),
1442
+ },
1362
1443
  },
1363
- },
1364
- /**/
1365
- /**/
1366
- {
1367
- modelVariant: 'CHAT',
1368
- modelTitle: 'o1-preview-2024-09-12',
1369
- modelName: 'o1-preview-2024-09-12',
1370
- // <- TODO: [💩] Some better system to organize theese date suffixes and versions
1371
- pricing: {
1372
- prompt: computeUsage("$15.00 / 1M tokens"),
1373
- output: computeUsage("$60.00 / 1M tokens"),
1444
+ /**/
1445
+ /**/
1446
+ {
1447
+ modelVariant: 'CHAT',
1448
+ modelTitle: 'o1-preview-2024-09-12',
1449
+ modelName: 'o1-preview-2024-09-12',
1450
+ // <- TODO: [💩] Some better system to organize theese date suffixes and versions
1451
+ pricing: {
1452
+ prompt: computeUsage("$15.00 / 1M tokens"),
1453
+ output: computeUsage("$60.00 / 1M tokens"),
1454
+ },
1374
1455
  },
1375
- },
1376
- /**/
1377
- /**/
1378
- {
1379
- modelVariant: 'CHAT',
1380
- modelTitle: 'o1-mini',
1381
- modelName: 'o1-mini',
1382
- pricing: {
1383
- prompt: computeUsage("$3.00 / 1M tokens"),
1384
- output: computeUsage("$12.00 / 1M tokens"),
1456
+ /**/
1457
+ /**/
1458
+ {
1459
+ modelVariant: 'CHAT',
1460
+ modelTitle: 'o1-mini',
1461
+ modelName: 'o1-mini',
1462
+ pricing: {
1463
+ prompt: computeUsage("$3.00 / 1M tokens"),
1464
+ output: computeUsage("$12.00 / 1M tokens"),
1465
+ },
1385
1466
  },
1386
- },
1387
- /**/
1388
- /**/
1389
- {
1390
- modelVariant: 'CHAT',
1391
- modelTitle: 'o1-mini-2024-09-12',
1392
- modelName: 'o1-mini-2024-09-12',
1393
- pricing: {
1394
- prompt: computeUsage("$3.00 / 1M tokens"),
1395
- output: computeUsage("$12.00 / 1M tokens"),
1467
+ /**/
1468
+ /**/
1469
+ {
1470
+ modelVariant: 'CHAT',
1471
+ modelTitle: 'o1-mini-2024-09-12',
1472
+ modelName: 'o1-mini-2024-09-12',
1473
+ pricing: {
1474
+ prompt: computeUsage("$3.00 / 1M tokens"),
1475
+ output: computeUsage("$12.00 / 1M tokens"),
1476
+ },
1396
1477
  },
1397
- },
1398
- /**/
1399
- /**/
1400
- {
1401
- modelVariant: 'CHAT',
1402
- modelTitle: 'gpt-3.5-turbo-16k-0613',
1403
- modelName: 'gpt-3.5-turbo-16k-0613',
1404
- pricing: {
1405
- prompt: computeUsage("$3.00 / 1M tokens"),
1406
- output: computeUsage("$4.00 / 1M tokens"),
1478
+ /**/
1479
+ /**/
1480
+ {
1481
+ modelVariant: 'CHAT',
1482
+ modelTitle: 'gpt-3.5-turbo-16k-0613',
1483
+ modelName: 'gpt-3.5-turbo-16k-0613',
1484
+ pricing: {
1485
+ prompt: computeUsage("$3.00 / 1M tokens"),
1486
+ output: computeUsage("$4.00 / 1M tokens"),
1487
+ },
1407
1488
  },
1408
- },
1409
- /**/
1410
- ]);
1489
+ /**/
1490
+ ],
1491
+ });
1411
1492
  /**
1412
1493
  * Note: [🤖] Add models of new variant
1413
1494
  * TODO: [🧠] Some mechanism to propagate unsureness
@@ -1623,18 +1704,23 @@ var OpenAiExecutionTools = /** @class */ (function () {
1623
1704
  if (resultContent === null) {
1624
1705
  throw new PipelineExecutionError('No response message from OpenAI');
1625
1706
  }
1626
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools ChatPromptResult', {
1627
- content: resultContent,
1628
- modelName: rawResponse.model || modelName,
1629
- timing: {
1630
- start: start,
1631
- complete: complete,
1707
+ return [2 /*return*/, exportJson({
1708
+ name: 'promptResult',
1709
+ message: "Result of `OpenAiExecutionTools.callChatModel`",
1710
+ order: [],
1711
+ value: {
1712
+ content: resultContent,
1713
+ modelName: rawResponse.model || modelName,
1714
+ timing: {
1715
+ start: start,
1716
+ complete: complete,
1717
+ },
1718
+ usage: usage,
1719
+ rawPromptContent: rawPromptContent,
1720
+ rawRequest: rawRequest,
1721
+ rawResponse: rawResponse,
1722
+ // <- [🗯]
1632
1723
  },
1633
- usage: usage,
1634
- rawPromptContent: rawPromptContent,
1635
- rawRequest: rawRequest,
1636
- rawResponse: rawResponse,
1637
- // <- [🗯]
1638
1724
  })];
1639
1725
  }
1640
1726
  });
@@ -1699,18 +1785,23 @@ var OpenAiExecutionTools = /** @class */ (function () {
1699
1785
  // eslint-disable-next-line prefer-const
1700
1786
  complete = $getCurrentDate();
1701
1787
  usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
1702
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools CompletionPromptResult', {
1703
- content: resultContent,
1704
- modelName: rawResponse.model || modelName,
1705
- timing: {
1706
- start: start,
1707
- complete: complete,
1788
+ return [2 /*return*/, exportJson({
1789
+ name: 'promptResult',
1790
+ message: "Result of `OpenAiExecutionTools.callCompletionModel`",
1791
+ order: [],
1792
+ value: {
1793
+ content: resultContent,
1794
+ modelName: rawResponse.model || modelName,
1795
+ timing: {
1796
+ start: start,
1797
+ complete: complete,
1798
+ },
1799
+ usage: usage,
1800
+ rawPromptContent: rawPromptContent,
1801
+ rawRequest: rawRequest,
1802
+ rawResponse: rawResponse,
1803
+ // <- [🗯]
1708
1804
  },
1709
- usage: usage,
1710
- rawPromptContent: rawPromptContent,
1711
- rawRequest: rawRequest,
1712
- rawResponse: rawResponse,
1713
- // <- [🗯]
1714
1805
  })];
1715
1806
  }
1716
1807
  });
@@ -1767,18 +1858,23 @@ var OpenAiExecutionTools = /** @class */ (function () {
1767
1858
  usage = computeOpenAiUsage(content || '', '',
1768
1859
  // <- Note: Embedding does not have result content
1769
1860
  rawResponse);
1770
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools EmbeddingPromptResult', {
1771
- content: resultContent,
1772
- modelName: rawResponse.model || modelName,
1773
- timing: {
1774
- start: start,
1775
- complete: complete,
1861
+ return [2 /*return*/, exportJson({
1862
+ name: 'promptResult',
1863
+ message: "Result of `OpenAiExecutionTools.callEmbeddingModel`",
1864
+ order: [],
1865
+ value: {
1866
+ content: resultContent,
1867
+ modelName: rawResponse.model || modelName,
1868
+ timing: {
1869
+ start: start,
1870
+ complete: complete,
1871
+ },
1872
+ usage: usage,
1873
+ rawPromptContent: rawPromptContent,
1874
+ rawRequest: rawRequest,
1875
+ rawResponse: rawResponse,
1876
+ // <- [🗯]
1776
1877
  },
1777
- usage: usage,
1778
- rawPromptContent: rawPromptContent,
1779
- rawRequest: rawRequest,
1780
- rawResponse: rawResponse,
1781
- // <- [🗯]
1782
1878
  })];
1783
1879
  }
1784
1880
  });
@@ -1974,20 +2070,25 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
1974
2070
  if (resultContent === null) {
1975
2071
  throw new PipelineExecutionError('No response message from OpenAI');
1976
2072
  }
1977
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiAssistantExecutionTools ChatPromptResult', {
1978
- content: resultContent,
1979
- modelName: 'assistant',
1980
- // <- TODO: [🥘] Detect used model in assistant
1981
- // ?> model: rawResponse.model || modelName,
1982
- timing: {
1983
- start: start,
1984
- complete: complete,
2073
+ return [2 /*return*/, exportJson({
2074
+ name: 'promptResult',
2075
+ message: "Result of `OpenAiAssistantExecutionTools.callChatModel`",
2076
+ order: [],
2077
+ value: {
2078
+ content: resultContent,
2079
+ modelName: 'assistant',
2080
+ // <- TODO: [🥘] Detect used model in assistant
2081
+ // ?> model: rawResponse.model || modelName,
2082
+ timing: {
2083
+ start: start,
2084
+ complete: complete,
2085
+ },
2086
+ usage: usage,
2087
+ rawPromptContent: rawPromptContent,
2088
+ rawRequest: rawRequest,
2089
+ rawResponse: rawResponse,
2090
+ // <- [🗯]
1985
2091
  },
1986
- usage: usage,
1987
- rawPromptContent: rawPromptContent,
1988
- rawRequest: rawRequest,
1989
- rawResponse: rawResponse,
1990
- // <- [🗯]
1991
2092
  })];
1992
2093
  }
1993
2094
  });